Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Random crash during setup(ui), retranslante step



  • Hi there,
    These are few days now I am getting stucked with this issue.
    In my app, from the "menu" ui, I create a new UI, I come back to menu, create a new one, and so on. (Consulting a list from a DB)
    After the ~10th time, it crash. After some investigations, this is what I have:
    Error from debug:
    ASSERT: "w" in file accessible\qaccessiblewidget.cpp, line 228
    Going deeper, I found out this come during: ui->setupUi(this);
    And more precisely during: retranslateUi(myUi); Despite the fact that myUi.h is generated by QtCreator, when I comment retranslateUi(myUi); , no more issue.
    I cannot make relation between this translation step and window() function from qaccessiblewidget.

    Could anyone give me a tip please ?
    Thanks a lot !


  • Lifetime Qt Champion

    @Match0um Hi!
    You should post the whole stack trace after the crash.



  • Ji @jsulm

    Thanks for helping.
    Is this what you expect ?
    I am not familiar with stack trace :(

    Stopped.
    115importPlainDumpers off
    Stopped: Unknown signal (Signal ?).
    116-thread-info
    117-stack-select-frame 1
    118python theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["watch","inspect","return","local"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"","passexceptions":0,"qobjectnames":1,"resultvarname":"","stringcutoff":"10000","timestamps":0,"token":118,"typeformats":{},"watchers":[{"exp":"6b65795043","iname":"watch.0"}]})
    119python theDumper.fetchStack({"limit":20,"nativemixed":0,"token":119})
    <Rebuild Watchmodel 6 @ 11:45:06.080 [697430ms] >
    120-stack-select-frame 1
    121python theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["watch","inspect","return","local"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"","passexceptions":0,"qobjectnames":1,"resultvarname":"","stringcutoff":"10000","timestamps":0,"token":121,"typeformats":{},"watchers":[{"exp":"6b65795043","iname":"watch.0"}]})
    <Rebuild Watchmodel 7 @ 11:45:06.146 [66ms] >
    

  • Lifetime Qt Champion

    @Match0um No, this isn't. The stack trace is what you will see in the debugger. It is basically the call sequence, so you can see what was called.



  • @jsulm said in Random crash during setup(ui), retranslante step:
    Sorry for that. I think think is better :)

    1   RaiseFailFastException                                                           0x7ffae7ae0c0f 
    2   qt_message_fatal                             qlogging.cpp                   1892 0x6b78f454     
    3   QMessageLogger::fatal                        qlogging.cpp                   887  0x6b78fe2b     
    4   qt_assert_x                                  qglobal.cpp                    3209 0x6b78afc5     
    5   QVector<QString>::operator[]                 qvector.h                      437  0x9a56d8       
    6   CatalogueSerrure::loadModel                  catalogueSerrure.cpp           532  0x6cf88f       
    7   CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       133  0x7abf05       
    8   QMetaObject::activate                        qobject.cpp                    3795 0x6b9412a8     
    9   QMetaObject::activate                        qobject.cpp                    3648 0x6b9415c6     
    10  QItemSelectionModel::currentChanged          moc_qitemselectionmodel.cpp    465  0x6b8f0bd2     
    11  QItemSelectionModel::setCurrentIndex         qitemselectionmodel.cpp        1414 0x6b8f0e2d     
    12  QAbstractItemView::setCurrentIndex           qabstractitemview.cpp          1087 0x2b1eeed8     
    13  CatalogueSerrure::lectureBDD                 catalogueSerrure.cpp           481  0x6cefd4       
    14  CatalogueSerrure::refresh                    catalogueSerrure.cpp           604  0x6d02bb       
    15  CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       135  0x7abf27       
    16  QMetaCallEvent::placeMetaCall                qobject.cpp                    520  0x6b93d42d     
    17  QObject::event                               qobject.cpp                    1260 0x6b941a72     
    18  QWidget::event                               qwidget.cpp                    9388 0x2affb2b6     
    19  QApplicationPrivate::notify_helper           qapplication.cpp               3736 0x2afb818e     
    20  QApplication::notify                         qapplication.cpp               3687 0x2afc0ee0     
    21  QCoreApplication::notifyInternal2            qcoreapplication.cpp           1060 0x6b917768     
    22  QCoreApplication::sendEvent                  qcoreapplication.cpp           1450 0x6b917990     
    23  QCoreApplicationPrivate::sendPostedEvents    qcoreapplication.cpp           1799 0x6b91cf73     
    24  QEventDispatcherWin32::sendPostedEvents      qeventdispatcher_win.cpp       1092 0x6b9691b3     
    25  QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 81   0x39e36f30     
    26  qt_internal_proc                             qeventdispatcher_win.cpp       245  0x6b96c219     
    27  USER32!CallWindowProcW                                                           0x7ffae8b95c1d 
    28  USER32!DispatchMessageW                                                          0x7ffae8b95612 
    29  QEventDispatcherWin32::processEvents         qeventdispatcher_win.cpp       639  0x6b96b98d     
    30  QWindowsGuiEventDispatcher::processEvents    qwindowsguieventdispatcher.cpp 74   0x39e36f17     
    31  QCoreApplication::processEvents              qcoreapplication.cpp           1279 0x6b91785e     
    32  CatalogueSerrure::loadModel                  catalogueSerrure.cpp           548  0x6cf9f1       
    33  CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       133  0x7abf05       
    34  QMetaObject::activate                        qobject.cpp                    3795 0x6b9412a8     
    35  QMetaObject::activate                        qobject.cpp                    3648 0x6b9415c6     
    36  QItemSelectionModel::currentChanged          moc_qitemselectionmodel.cpp    465  0x6b8f0bd2     
    37  QItemSelectionModel::setCurrentIndex         qitemselectionmodel.cpp        1414 0x6b8f0e2d     
    38  QAbstractItemView::setCurrentIndex           qabstractitemview.cpp          1087 0x2b1eeed8     
    39  CatalogueSerrure::lectureBDD                 catalogueSerrure.cpp           481  0x6cefd4       
    40  CatalogueSerrure::refresh                    catalogueSerrure.cpp           604  0x6d02bb       
    41  CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       135  0x7abf27       
    42  QMetaCallEvent::placeMetaCall                qobject.cpp                    520  0x6b93d42d     
    43  QObject::event                               qobject.cpp                    1260 0x6b941a72     
    44  QWidget::event                               qwidget.cpp                    9388 0x2affb2b6     
    45  QApplicationPrivate::notify_helper           qapplication.cpp               3736 0x2afb818e     
    46  QApplication::notify                         qapplication.cpp               3687 0x2afc0ee0     
    47  QCoreApplication::notifyInternal2            qcoreapplication.cpp           1060 0x6b917768     
    48  QCoreApplication::sendEvent                  qcoreapplication.cpp           1450 0x6b917990     
    49  QCoreApplicationPrivate::sendPostedEvents    qcoreapplication.cpp           1799 0x6b91cf73     
    50  QEventDispatcherWin32::sendPostedEvents      qeventdispatcher_win.cpp       1092 0x6b9691b3     
    51  QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 81   0x39e36f30     
    52  qt_internal_proc                             qeventdispatcher_win.cpp       245  0x6b96c219     
    53  USER32!CallWindowProcW                                                           0x7ffae8b95c1d 
    54  USER32!DispatchMessageW                                                          0x7ffae8b95612 
    55  QEventDispatcherWin32::processEvents         qeventdispatcher_win.cpp       639  0x6b96b98d     
    56  QWindowsGuiEventDispatcher::processEvents    qwindowsguieventdispatcher.cpp 74   0x39e36f17     
    57  QCoreApplication::processEvents              qcoreapplication.cpp           1279 0x6b91785e     
    58  CatalogueSerrure::loadModel                  catalogueSerrure.cpp           548  0x6cf9f1       
    59  CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       133  0x7abf05       
    60  QMetaObject::activate                        qobject.cpp                    3795 0x6b9412a8     
    61  QMetaObject::activate                        qobject.cpp                    3648 0x6b9415c6     
    62  QItemSelectionModel::currentChanged          moc_qitemselectionmodel.cpp    465  0x6b8f0bd2     
    63  QItemSelectionModel::setCurrentIndex         qitemselectionmodel.cpp        1414 0x6b8f0e2d     
    64  QAbstractItemView::setCurrentIndex           qabstractitemview.cpp          1087 0x2b1eeed8     
    65  CatalogueSerrure::lectureBDD                 catalogueSerrure.cpp           481  0x6cefd4       
    66  CatalogueSerrure::refresh                    catalogueSerrure.cpp           604  0x6d02bb       
    67  CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       135  0x7abf27       
    68  QMetaCallEvent::placeMetaCall                qobject.cpp                    520  0x6b93d42d     
    69  QObject::event                               qobject.cpp                    1260 0x6b941a72     
    70  QWidget::event                               qwidget.cpp                    9388 0x2affb2b6     
    71  QApplicationPrivate::notify_helper           qapplication.cpp               3736 0x2afb818e     
    72  QApplication::notify                         qapplication.cpp               3687 0x2afc0ee0     
    73  QCoreApplication::notifyInternal2            qcoreapplication.cpp           1060 0x6b917768     
    74  QCoreApplication::sendEvent                  qcoreapplication.cpp           1450 0x6b917990     
    75  QCoreApplicationPrivate::sendPostedEvents    qcoreapplication.cpp           1799 0x6b91cf73     
    76  QEventDispatcherWin32::sendPostedEvents      qeventdispatcher_win.cpp       1092 0x6b9691b3     
    77  QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 81   0x39e36f30     
    78  qt_internal_proc                             qeventdispatcher_win.cpp       245  0x6b96c219     
    79  USER32!CallWindowProcW                                                           0x7ffae8b95c1d 
    80  USER32!DispatchMessageW                                                          0x7ffae8b95612 
    81  QEventDispatcherWin32::processEvents         qeventdispatcher_win.cpp       639  0x6b96b98d     
    82  QWindowsGuiEventDispatcher::processEvents    qwindowsguieventdispatcher.cpp 74   0x39e36f17     
    83  QCoreApplication::processEvents              qcoreapplication.cpp           1279 0x6b91785e     
    84  CatalogueSerrure::loadModel                  catalogueSerrure.cpp           548  0x6cf9f1       
    85  CatalogueSerrure::refresh                    catalogueSerrure.cpp           611  0x6d03e7       
    86  CatalogueSerrure::qt_static_metacall         moc_catalogueSerrure.cpp       135  0x7abf27       
    87  QMetaCallEvent::placeMetaCall                qobject.cpp                    520  0x6b93d42d     
    88  QObject::event                               qobject.cpp                    1260 0x6b941a72     
    89  QWidget::event                               qwidget.cpp                    9388 0x2affb2b6     
    90  QApplicationPrivate::notify_helper           qapplication.cpp               3736 0x2afb818e     
    91  QApplication::notify                         qapplication.cpp               3687 0x2afc0ee0     
    92  QCoreApplication::notifyInternal2            qcoreapplication.cpp           1060 0x6b917768     
    93  QCoreApplication::sendEvent                  qcoreapplication.cpp           1450 0x6b917990     
    94  QCoreApplicationPrivate::sendPostedEvents    qcoreapplication.cpp           1799 0x6b91cf73     
    95  QEventDispatcherWin32::sendPostedEvents      qeventdispatcher_win.cpp       1092 0x6b9691b3     
    96  QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 81   0x39e36f30     
    97  qt_internal_proc                             qeventdispatcher_win.cpp       245  0x6b96c219     
    98  USER32!CallWindowProcW                                                           0x7ffae8b95c1d 
    99  USER32!DispatchMessageW                                                          0x7ffae8b95612 
    100 QEventDispatcherWin32::processEvents         qeventdispatcher_win.cpp       639  0x6b96b98d     
    101 QWindowsGuiEventDispatcher::processEvents    qwindowsguieventdispatcher.cpp 74   0x39e36f17     
    102 QEventLoop::processEvents                    qeventloop.cpp                 138  0x6b915e27     
    103 QEventLoop::exec                             qeventloop.cpp                 225  0x6b916245     
    104 QCoreApplication::exec                       qcoreapplication.cpp           1363 0x6b91ee1a     
    105 QGuiApplication::exec                        qguiapplication.cpp            1779 0x132423bf     
    106 QApplication::exec                           qapplication.cpp               2893 0x2afb8070     
    107 qMain                                        main.cpp                       117  0x4027c9       
    108 WinMain                                      qtmain_win.cpp                 97   0x7b796a       
    109 __tmainCRTStartup                                                                0x4013c7       
    110 WinMainCRTStartup                                                                0x4014cb       
    
    

  • Lifetime Qt Champion

    @Match0um said in Random crash during setup(ui), retranslante step:

    CatalogueSerrure::loadModel

    Can you show the code in this method? It looks like you're out of bounds when accessing a QVector.



  • Well I am accessing a vector on line 532 through a query. Errors should be handled right after with the if..else.. ? :(

    I hid some names by xx.

    The weird thing is that my menu is CatalogueSerrure and it is when creating an UI from this menu that the app crash. So I was focused on the created UI, not the parent :(

    void CatalogueSerrure::loadModel(QModelIndex idx)
    {
         if (idx.row()<0)
        {
            _lastIdxTable=0;
            idx = _modelItemCylindre->index(_lastIdxTable, 0);
        }
    
        QApplication::setOverrideCursor(Qt::WaitCursor);
        clearGrid2();
    
        QSqlQuery q;
        q.exec(QString("SELECT * FROM xx WHERE xx='%1' ORDER BY xx").arg(_myVector[idx.row()]));  //L532
    
        if (q.lastError().type()==QSqlError::NoError)
        {
            while (q.next())
            {
                xx(q);
            }
        }
        else
        {
            qDebug("error q");
            return;
        }

  • Lifetime Qt Champion

    @Match0um said in Random crash during setup(ui), retranslante step:

    myVector[idx.row()]

    You really should check if you don't access out-of-bounds here...



  • @Match0um said in Random crash during setup(ui), retranslante step:

    Errors should be handled right after with the if..else.. ? :(

    Umm, no! If _myVector[idx.row()] is out of bounds, you get a crash on that line, as you can see.... C++ doesn't go ahead and execute the string (how could it?) and then let you know about an error later on :)



  • @Christian-Ehrlicher
    Thanks for the tip. To make sure I wasn't, I replaced my arg by a fixed value. Behavior is the same :(

    Furthermore, my code is executed a bit further and this line given my debug messages.


  • Lifetime Qt Champion

    @Match0um said in Random crash during setup(ui), retranslante step:

    I replaced my arg by a fixed value. Behavior is the same :(

    I never told you to do so. As @JonB and I suggested you should check if the index you pass to operator[] is out-of-bounds - i.e. if the vector is big enough. For sure it isn't.



  • @Christian-Ehrlicher said in Random crash during setup(ui), retranslante step:

    suggested you should check if the index you pass to operator[] is out-of-bounds

    OK. By replacing

    arg(_myVector[idx.row()]))
    

    by

    arg(cst)
    

    the index and the vector are not used anymore ? No more out-of-bounds possibility, right ? But the problem subsists.


  • Lifetime Qt Champion

    @Match0um said in Random crash during setup(ui), retranslante step:

    But the problem subsists.

    No, the crash must be on another place now since you now no longer call the function which crashes according your old backtrace. Take a look at the backtrace.



  • OK so now backtrace is leading me back to qaccessiblewidget...

    1  RaiseFailFastException                                                                  0x7ffae7ae0c0f 
    2  qt_message_fatal                                    qlogging.cpp                   1892 0x6b78f454     
    3  QMessageLogger::fatal                               qlogging.cpp                   887  0x6b78fe2b     
    4  qt_assert                                           qglobal.cpp                    3201 0x6b78acd1     
    5  QAccessibleWidget::window                           qaccessiblewidget.cpp          228  0x2a8f982f     
    6  QWindowsUiAutomation::hwndForAccessible             qwindowsuiautils.cpp           89   0x39e43667     
    7  QWindowsUiaMainProvider::get_HostRawElementProvider qwindowsuiamainprovider.cpp    434  0x39e38689     
    8  UiaHostProviderFromHwnd                                                                 0x7ffac16af003 
    9  UiaHostProviderFromHwnd                                                                 0x7ffac16b07d3 
    10 UiaHostProviderFromHwnd                                                                 0x7ffac16aec5a 
    11 UiaRaiseAutomationEvent                                                                 0x7ffac16ad744 
    12 UiaRaiseAutomationEvent                                                                 0x7ffac16ad3fc 
    13 QWindowsUiaWrapper::raiseAutomationEvent            qwindowsuiawrapper.cpp         113  0x39eef364     
    14 QWindowsUiaMainProvider::notifyTextChange           qwindowsuiamainprovider.cpp    171  0x39e375ba     
    15 QWindowsUiaAccessibility::notifyAccessibilityUpdate qwindowsuiaaccessibility.cpp   123  0x39e36aa9     
    16 QAccessible::updateAccessibility                    qaccessible.cpp                875  0xf43569c      
    17 QWidgetLineControl::emitCursorPositionChanged       qwidgetlinecontrol.cpp         1436 0x2a8150e0     
    18 QWidgetLineControl::finishChange                    qwidgetlinecontrol.cpp         749  0x2a816cb5     
    19 QWidgetLineControl::internalSetText                 qwidgetlinecontrol.cpp         776  0x2a8170f1     
    20 QWidgetLineControl::setText                         qwidgetlinecontrol_p.h         255  0x2a80be8a     
    21 QLineEdit::setText                                  qlineedit.cpp                  318  0x2a80be8a     
    22 QAbstractSpinBoxPrivate::updateEdit                 qabstractspinbox.cpp           1813 0x2a862ff3     
    23 QDoubleSpinBox::setSuffix                           qspinbox.cpp                   764  0x2a865106     
    24 Ui_FicheSerrure::retranslateUi                      ui_ficheSerrure.h              3098 0x821094       
    25 Ui_FicheSerrure::setupUi                            ui_ficheSerrure.h              3039 0x843a45       
    26 FicheSerrure::nouvelle_ConfigGUI                    ficheSerrure.cpp               194  0x71278c       
    27 FicheSerrure::initialisations                       ficheSerrure.cpp               86   0x711d9c       
    28 FicheSerrure::FicheSerrure                          ficheSerrure.cpp               27   0x71198d       
    29 CatalogueSerrure::loadView                          catalogueSerrure.cpp           583  0x6d0033       
    30 CatalogueSerrure::qt_static_metacall                moc_catalogueSerrure.cpp       134  0x7ac196       
    31 QMetaObject::activate                               qobject.cpp                    3795 0x6b9412a8     
    32 QMetaObject::activate                               qobject.cpp                    3648 0x6b9415c6     
    33 QAbstractButton::clicked                            moc_qabstractbutton.cpp        312  0x2a7c0ee7     
    34 ToolButton::event                                   structure.cpp                  1325 0x426ef8       
    35 QApplicationPrivate::notify_helper                  qapplication.cpp               3736 0x2a6d818e     
    36 QApplication::notify                                qapplication.cpp               3197 0x2a6df418     
    37 QCoreApplication::notifyInternal2                   qcoreapplication.cpp           1060 0x6b917768     
    38 QCoreApplication::sendSpontaneousEvent              qcoreapplication.cpp           1462 0x6b9179ae     
    39 QApplicationPrivate::sendMouseEvent                 qapplication.cpp               2683 0x2a6de7bc     
    40 QWidgetWindow::handleMouseEvent                     qwidgetwindow.cpp              662  0x2a72fbe2     
    41 QWidgetWindow::event                                qwidgetwindow.cpp              281  0x2a73206b     
    42 QApplicationPrivate::notify_helper                  qapplication.cpp               3736 0x2a6d818e     
    43 QApplication::notify                                qapplication.cpp               3093 0x2a6df139     
    44 QCoreApplication::notifyInternal2                   qcoreapplication.cpp           1060 0x6b917768     
    45 QCoreApplication::sendSpontaneousEvent              qcoreapplication.cpp           1462 0x6b9179ae     
    46 QGuiApplicationPrivate::processMouseEvent           qguiapplication.cpp            2102 0xf45b3e9      
    47 QGuiApplicationPrivate::processWindowSystemEvent    qguiapplication.cpp            1837 0xf45c85e      
    48 QWindowSystemInterface::sendWindowSystemEvents      qwindowsysteminterface.cpp     1151 0xf440503      
    49 QWindowsGuiEventDispatcher::sendPostedEvents        qwindowsguieventdispatcher.cpp 82   0x39e46f39     
    50 qt_internal_proc                                    qeventdispatcher_win.cpp       245  0x6b96c219     
    51 USER32!CallWindowProcW                                                                  0x7ffae8b95c1d 
    52 USER32!DispatchMessageW                                                                 0x7ffae8b95612 
    53 QEventDispatcherWin32::processEvents                qeventdispatcher_win.cpp       639  0x6b96b98d     
    54 QWindowsGuiEventDispatcher::processEvents           qwindowsguieventdispatcher.cpp 74   0x39e46f17     
    55 QEventLoop::processEvents                           qeventloop.cpp                 138  0x6b915e27     
    56 QEventLoop::exec                                    qeventloop.cpp                 225  0x6b916245     
    57 QCoreApplication::exec                              qcoreapplication.cpp           1363 0x6b91ee1a     
    58 QGuiApplication::exec                               qguiapplication.cpp            1779 0xf4523bf      
    59 QApplication::exec                                  qapplication.cpp               2893 0x2a6d8070     
    60 qMain                                               main.cpp                       117  0x4027c9       
    61 WinMain                                             qtmain_win.cpp                 97   0x7b7bfa       
    62 __tmainCRTStartup                                                                       0x4013c7       
    63 WinMainCRTStartup                                                                       0x4014cb       
    
    

  • Lifetime Qt Champion

    @Match0um said in Random crash during setup(ui), retranslante step:

    FicheSerrure::nouvelle_ConfigGUI

    What exactly happens in this method (code)?



  • @jsulm
    Here is the code. And as far as I understand, during the first operation, setupUi(this) get into Retranslate and then crash...

    void FicheSerrure::nouvelle_ConfigGUI()
    {
        //Configuration de l'interface utilisateur
        ui->setupUi(this);
        ConfigGUI::configView(this);
        this->setWindowTitle("Fiche Serrure");
    
        ui->stackedWidget_photo->setCurrentIndex(0);
    
        ui->tabWidget_pageCle->clear();
        ui->tabWidget_pageGoupille->clear();
    
        ui->widget->addButton(ui->toolB_editer, 0, 0);
    ...
        ui->widget->addButton(ui->toolB_sauverPage, 0, 8);
    
    
        WidgetStacked* widgetStacked = new WidgetStacked(ui->page_visible);
    
        ui->gridLayout_pageVisible->addWidget(widgetStacked);
    
        widgetStacked->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        widgetStacked->addWidget(ui->page_axe1);
        widgetStacked->addWidget(ui->page_axe2);
        widgetStacked->setCurrentIndex(0);
    
        ui->tabWidget->tabBar()->installEventFilter(this);
    }
    

  • Lifetime Qt Champion

    @Match0um There is an assert in
    QAccessibleWidget::window qaccessiblewidget.cpp 228 0x2a8f982f
    What exact Qt version do you use? Knowing the exact version we could check what happens in qaccessiblewidget.cpp at line 228, else it is hard to say.
    OK, it is this:

    QWindow *QAccessibleWidget::window() const
    {
        const QWidget *w = widget();
        Q_ASSERT(w); // This is the assert, means widget() returns nullptr
        QWindow *result = w->windowHandle();
        if (!result) {
            if (const QWidget *nativeParent = w->nativeParentWidget())
                result = nativeParent->windowHandle();
        }
        return result;
    }
    
    QWidget *QAccessibleWidget::widget() const
    {
        return qobject_cast<QWidget*>(object());
    }
    
    QObject *QAccessibleObject::object() const
    {
        return d->object;
    }
    

    Looks like either d->object is not set (unlikely as it is set in constructor) or it is not QWidget. Could be a bug in Qt, you can check Qt bug tracker.


  • Lifetime Qt Champion

    @Match0um said in Random crash during setup(ui), retranslante step:

    ui->setupUi(this);

    This is wrong - it creates new widgets every time this function is called!
    setupUi() must only be called once in the ctor.

    /edit:

    WidgetStacked* widgetStacked = new WidgetStacked(ui->page_visible);

    This is also wrong since you don't delete the old.


  • Lifetime Qt Champion

    @Christian-Ehrlicher Oh, didn't notice it wasn't constructor!



  • @Christian-Ehrlicher said in Random crash during setup(ui), retranslante step:

    setupUi() must only be called once in the ctor.

    Sorry if it was not clear.
    nouvelle_ConfigGUI() is called only once by my constructor. So not more than 1 call for setup(ui). (I double checked)

    Agreed on widget Stacked, so I temporarly took it out of the code, but issue remains.

    I work on QT 5.12.3, I tried 5.12.9 but no improvements neither :(


  • Lifetime Qt Champion

    Simplify the ui of the form until it no longer crashes. I would start by not setting the suffix for the spinbox as this is the current way how it crashes as you can see in the backtrace.


  • Lifetime Qt Champion

    Hi,

    One other thing that is not clear at all is why you are creating a WidgetStacked instance and then passing it widgets that belongs to FicheSerrure.

    I must say your GUI building logic is a bit convoluted. You seem to have put different "subwidgets" in different classes and then you shuffle them around.

    You might want to reconsider your design.



  • Hi,
    Thanks all for your support.

    I totally agree on this weird building logic. Unfortunately, it is not mine, but a former developer's.
    I was asked to fix this bug without changing evrything right now -_- . But I will try to change it a better way as soon I will be able to.

    Meantime, I took off widgetstacked, every single setSuffix or even DoubleSpinBox. But my app still crash at the same action, after a non defined times. And backtrace is not always the same neither :(

    If anyone have any idea that could help, it would be welcome !

    1  RaiseFailFastException                                                                  0x7ffb20770c0f 
    2  qt_message_fatal                                    qlogging.cpp                   1892 0x2125f454     
    3  QMessageLogger::fatal                               qlogging.cpp                   887  0x2125fe2b     
    4  qt_assert                                           qglobal.cpp                    3201 0x2125acd1     
    5  QAccessibleWidget::window                           qaccessiblewidget.cpp          228  0x2ce8982f     
    6  QWindowsUiAutomation::hwndForAccessible             qwindowsuiautils.cpp           89   0x3c243667     
    7  QWindowsUiaMainProvider::get_HostRawElementProvider qwindowsuiamainprovider.cpp    434  0x3c238689     
    8  UiaHostProviderFromHwnd                                                                 0x7ffaed52f003 
    9  UiaHostProviderFromHwnd                                                                 0x7ffaed5307d3 
    10 UiaHostProviderFromHwnd                                                                 0x7ffaed52ec5a 
    11 UiaRaiseAutomationEvent                                                                 0x7ffaed52d744 
    12 UiaRaiseAutomationEvent                                                                 0x7ffaed52d3fc 
    13 QWindowsUiaWrapper::raiseAutomationEvent            qwindowsuiawrapper.cpp         113  0x3c2ef364     
    14 QWindowsUiaMainProvider::notifyFocusChange          qwindowsuiamainprovider.cpp    109  0x3c237267     
    15 QWindowsUiaAccessibility::notifyAccessibilityUpdate qwindowsuiaaccessibility.cpp   108  0x3c236a8e     
    16 QAccessible::updateAccessibility                    qaccessible.cpp                875  0xf57569c      
    17 QWidget::setFocus                                   qwidget.cpp                    6581 0x2cca44d2     
    18 QApplication::setActiveWindow                       qapplication.cpp               2123 0x2cc6d2e0     
    19 QApplicationPrivate::notifyActiveWindowChange       qapplication.cpp               2168 0x2cc6d3a1     
    20 QGuiApplicationPrivate::processActivatedEvent       qguiapplication.cpp            2329 0xf59827f      
    21 QGuiApplicationPrivate::processWindowSystemEvent    qguiapplication.cpp            1858 0xf59c895      
    22 QWindowSystemInterface::sendWindowSystemEvents      qwindowsysteminterface.cpp     1151 0xf580503      
    23 QWindowsGuiEventDispatcher::sendPostedEvents        qwindowsguieventdispatcher.cpp 82   0x3c246f39     
    24 qt_internal_proc                                    qeventdispatcher_win.cpp       245  0x2143c219     
    25 USER32!CallWindowProcW                                                                  0x7ffb22745c1d 
    26 USER32!DispatchMessageW                                                                 0x7ffb22745612 
    27 QEventDispatcherWin32::processEvents                qeventdispatcher_win.cpp       639  0x2143b98d     
    28 QWindowsGuiEventDispatcher::processEvents           qwindowsguieventdispatcher.cpp 74   0x3c246f17     
    29 QEventLoop::processEvents                           qeventloop.cpp                 138  0x213e5e27     
    30 QEventLoop::exec                                    qeventloop.cpp                 225  0x213e6245     
    31 QCoreApplication::exec                              qcoreapplication.cpp           1363 0x213eee1a     
    32 QGuiApplication::exec                               qguiapplication.cpp            1779 0xf5923bf      
    33 QApplication::exec                                  qapplication.cpp               2893 0x2cc68070     
    34 qMain                                               main.cpp                       117  0x4027c9       
    35 WinMain                                             qtmain_win.cpp                 97   0x7b773a       
    36 __tmainCRTStartup                                                                       0x4013c7       
    37 WinMainCRTStartup                                                                       0x4014cb       
    
    

  • Lifetime Qt Champion

    I would guess that there are a lot of 'dangling' widgets around due to re-creation of them during retranslate()


Log in to reply