Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-104003

QTabBar/QTabWidget crashes when closing last tab and there are hidden tabs

    XMLWordPrintable

Details

    • Windows
    • ac80cee846 (qt/qtbase/dev) ac80cee846 (qt/tqtc-qtbase/dev) 3a542c57ed (qt/qtbase/6.3) 3a542c57ed (qt/tqtc-qtbase/6.3) 9b68302e2c (qt/tqtc-qtbase/6.2) dabd025173 (qt/qtbase/6.4) dabd025173 (qt/tqtc-qtbase/6.4)

    Description

      If a QTabWidget contains some tab that was hidden using setTabVisible(index, false) and I close the last (visible, of course) tab, the app will crash.

      The crash is caused by QTabBar's d->lastVisible being -1 which causes the qBound() on line 1085 (Qt 6.3.0) to fail an assert check:

       

      // in QTabBar::removeTab(int index):
      case SelectRightTab:
       newIndex = qBound(d->firstVisible, index, d->lastVisible); // <<< ASSERT FAILS
       break;
      

        

      To reproduce it using the attached sample app:

      1. press the "hide current tab" button
      2. close all tabs using the close button on the tabs
      3. it should fail when the last tab is closed (but will worked fine on my Qt 5.15.2 build)

      In my tests it didn't matter which tab got hidden and in what order I closed them.

       

      Full error message: 

      ASSERT: "!(max < min)" in file C:\Users\qt\work\qt\qtbase\include\QtCore\../../src/corelib/global/qglobal.h, line 1025
      

       

      Call stack:

      1 qt_message_fatal qlogging.cpp 1872 0x7ff82b984cf4 
      2 QMessageLogger::fatal qlogging.cpp 882 0x7ff82b983198 
      3 qt_assert qglobal.cpp 3304 0x7ff82b9700d9 
      4 qBound<int> qglobal.h 1026 0x7ff82c806b40 
      5 QTabBar::removeTab qtabbar.cpp 1085 0x7ff82ccd85e7 
      6 QtPrivate::FunctorCall<QtPrivate::IndexesList<0>,QtPrivate::List<int>,void,void (__cdecl QTabBar:: *)(int)>::call qobjectdefs_impl.h 171 0x7ff7350b36aa 
      7 QtPrivate::FunctionPointer<void (__cdecl QTabBar:: *)(int)>::call<QtPrivate::List<int>,void> qobjectdefs_impl.h 209 0x7ff7350b2cad 
      8 QtPrivate::QSlotObject<void (__cdecl QTabBar:: *)(int),QtPrivate::List<int>,void>::impl qobjectdefs_impl.h 420 0x7ff7350b3793 
      9 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 399 0x7ff82baa8ce3 
      10 doActivate<0> qobject.cpp 3919 0x7ff82bb4d038 
      11 QMetaObject::activate qobject.cpp 3980 0x7ff82bb34a48 
      12 QTabBar::tabCloseRequested moc_qtabbar.cpp 325 0x7ff82ccdb559 
      13 QTabBarPrivate::_q_closeTab qtabbar.cpp 820 0x7ff82cce05d0 
      14 QTabBar::qt_static_metacall moc_qtabbar.cpp 173 0x7ff82ccd7256 
      15 doActivate<0> qobject.cpp 3934 0x7ff82bb4d16a 
      16 QMetaObject::activate qobject.cpp 3980 0x7ff82bb34a48 
      17 QAbstractButton::clicked moc_qabstractbutton.cpp 288 0x7ff82cae30d9 
      18 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 416 0x7ff82cae55f7 
      19 QAbstractButtonPrivate::click qabstractbutton.cpp 408 0x7ff82cae440e 
      20 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1012 0x7ff82cae3966 
      ... <More>

       

      Attachments

        Activity

          People

            vhilshei Volker Hilsheimer
            hippydream Fabrizio Angius
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: