@@ -244,7 +244,7 @@ void CDockAreaTabBar::setCurrentIndex(int index)
244244 return ;
245245 }
246246
247- if (index < 0 || index > (count () - 1 ))
247+ if (index < - 1 || index > (count () - 1 ))
248248 {
249249 qWarning () << Q_FUNC_INFO << " Invalid index" << index;
250250 return ;
@@ -275,7 +275,7 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
275275 emit tabInserted (Index);
276276 if (Index <= d->CurrentIndex )
277277 {
278- setCurrentIndex (d->CurrentIndex ++ );
278+ setCurrentIndex (d->CurrentIndex + 1 );
279279 }
280280}
281281
@@ -352,7 +352,14 @@ int CDockAreaTabBar::currentIndex() const
352352// ===========================================================================
353353CDockWidgetTab* CDockAreaTabBar::currentTab () const
354354{
355- return qobject_cast<CDockWidgetTab*>(d->TabsLayout ->itemAt (d->CurrentIndex )->widget ());
355+ if (d->CurrentIndex < 0 )
356+ {
357+ return nullptr ;
358+ }
359+ else
360+ {
361+ return qobject_cast<CDockWidgetTab*>(d->TabsLayout ->itemAt (d->CurrentIndex )->widget ());
362+ }
356363}
357364
358365
@@ -378,9 +385,9 @@ void CDockAreaTabBar::onTabClicked()
378385// ===========================================================================
379386CDockWidgetTab* CDockAreaTabBar::tab (int Index) const
380387{
381- if (Index >= count ())
388+ if (Index >= count () || Index < 0 )
382389 {
383- return 0 ;
390+ return nullptr ;
384391 }
385392 return qobject_cast<CDockWidgetTab*>(d->TabsLayout ->itemAt (Index)->widget ());
386393}
@@ -456,7 +463,7 @@ void CDockAreaTabBar::closeTab(int Index)
456463 }
457464
458465 auto Tab = tab (Index);
459- if (! Tab->isVisibleTo ( this ))
466+ if (Tab->isHidden ( ))
460467 {
461468 return ;
462469 }
@@ -497,7 +504,7 @@ bool CDockAreaTabBar::isTabOpen(int Index) const
497504 return false ;
498505 }
499506
500- return tab (Index)->isVisibleTo ( this );
507+ return ! tab (Index)->isHidden ( );
501508}
502509} // namespace ads
503510
0 commit comments