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

Weird crash with QGesture



  • Hi every one !

    First of all, i am using Qt 4.8.6 64 bit under debian 8.

    I have a weird crash while deleting some of my widgets, in the Qt Code. This is a gdb print of the generated core :

    	qDeleteAll<QSet<QGesture*>::const_iterator>		322	0x7f34a91da4cd	
    	qDeleteAll<QSet<QGesture*> >		330	0x7f34a91da4cd	
    	QGestureManager::filterEventThroughContexts		389	0x7f34a91da4cd	
    	QGestureManager::filterEvent		496	0x7f34a91dd205	
    	QApplication::notify		3916	0x7f34a917f4ea	
    	QCoreApplication::notifyInternal		955	0x7f34a8c4871d	
    	sendEvent		231	0x7f34a91cb1ee	
    	QWidget::~QWidget		1699	0x7f34a91cb1ee	
    	QWidget::~QWidget		1703	0x7f34a91cb489	
    	QObjectPrivate::deleteChildren		1935	0x7f34a8c60248	
    	QWidget::~QWidget		1679	0x7f34a91cb173
    

    I am not using QGesture at all in the project by the way.

    The code called is in QGestureManager.cpp line 389 :

        //Clean up the Gestures
        qDeleteAll(m_gesturesToDelete);
    

    Does anyone understand this ?


  • Lifetime Qt Champion

    Hi,

    How are you deleting your widget ?



  • Hi,

    function close() is called in a slot. Then an event (deferredDelete) actually call delete on the widget.
    This widget is embedded in a MDIArea.

    It's not happening at every close of the widget.



  • I switched from the Qt 4.8.6 from debian package to a 4.8.6 builded from source with the define QT_NO_GESTURES.
    The crash seems to be avoided.

    Is there a way to disable all the treatment that Qt do for Gesture management, as we do not use them in our project, without compiling from source ?


  • Lifetime Qt Champion

    Something's not clear, you are calling close and then deleteLater on your widget ?



  • No, i think that the close() call implicate a DeferedDelete event (Qt mechanism).


  • Lifetime Qt Champion

    No it doesn't unless you have set the theQt::WA_DeleteOnClose attribute. Otherwise it hides the widget.



  • Yes, the attribute is actually set .

    By the way, i have found another way to reproduce the problem and this time i initiate the delete of the widget manually, without close().

    The idea is :
    i have a QSplitter, the QSplitter is used as a container for 2 widgets. The two widgets are called "upper" and "bottom" area. The upper part in this case contains a list of items. When user click an item, we display a "bottom" part with details on the item selected in the "upper" part.
    The crash happens (sometimes) when we switch the "bottom" part.

    In this code, m_pBottomArea is the current bottom, pNewBottomArea is the one we want to set.

        if (m_pBottomArea != NULL)
        {
            //Already a bottom: delete it, this will remove it from splitter
            delete m_pBottomArea;
            //m_pBottomArea->deleteLater;
        }
    
        m_pBottomArea = pNewBottomArea;
    
        if (m_pBottomArea != NULL)
        {
            //Add the bottom
            m_pSplitter->insertWidget(1, m_pBottomArea);
        }
    
    

    Either if i use a delete, or a deleteLater, there is sometimes a crash. Always with the same call stack.

    Did i do something wrong ?
    Do you know if there is a way to disable the GestureManager without compiling Qt from source ?


  • Lifetime Qt Champion

    AFAIK, no.

    One thing you can try is to set m_pBottomArea's parent to nullptr before deleting it.



  • Already tried that :(


  • Lifetime Qt Champion

    Can you share the complete implementation of the function where you manipulate m_pBottomArea ? The handling pNewBottomArea is absent and the look of the code looks like it might be more complicated that necessary.


Log in to reply