Events after Object destruction
-
@anli From your logs, I suspect that it's just as you say: The deleted button doesn't get properly removed from the event queue.
I'm not sure what's the best way forward though. The first thing I'd recommend is to upgrade to Qt 4.8.7 and see if the issue exists there.
-
Hello JKSH,
in the meantime we already tried this. We also changed the hardware platform to a faster one to get an idea, if this is maybe the reason, but also with QT 4.8.7 we get there the effect.
It seems to me as if the QWS window list does not get updated in time...
-
@anli
You're still trying to sort out object deletion and signal/slot delivery etc., right?At this point if it were me, I would set up a new, standalone, minimal project, without worrying about "slow" or "embedded" etc., and just test what's going on in the simplest case, so that you understand. Having your full, complex, existing application code is just going to obscure whatever issue there is.
-
Might be a stupid workaround, but what happens when you, in your slot, set the PushButton to disabled, this should happe as the very first thing of course ?
-
For further information, I now attach a backtrace for the moment, when toolbutton is destroyed:
0 layout_n::manager_c::slotButtonDeleted layoutmanager.cpp 526 0x27eb70 1 layout_n::manager_c::qt_static_metacall moc_layoutmanager.cpp 243 0x28a4b4 2 QMetaObject::activate qobject.cpp 3540 0xd6c2f0 3 QObject::destroyed moc_qobject.cpp 149 0xd6dce8 4 QObject::~QObject qobject.cpp 843 0xd66c3c 5 QWidget::~QWidget qwidget.cpp 1705 0x38be4c 6 QAbstractButton::~QAbstractButton qabstractbutton.cpp 608 0x77284c 7 QToolButton::~QToolButton qtoolbutton.cpp 409 0x803c48 8 layout_n::toolButton_c::~toolButton_c layoutmanager.h 185 0x28b934 9 layout_n::toolButton_c::~toolButton_c layoutmanager.h 185 0x28b994 10 QObjectPrivate::deleteChildren qobject.cpp 1908 0xd68368 11 QWidget::~QWidget qwidget.cpp 1681 0x38bd90 12 QWidget::~QWidget qwidget.cpp 1705 0x38bec8 13 qDeleteInEventHandler qobject.cpp 4270 0xd6d858 14 QObject::event qobject.cpp 1175 0xd67384 15 QWidget::event qwidget.cpp 8846 0x39e564 16 QApplicationPrivate::notify_helper qapplication.cpp 4566 0x348428 17 QApplication::notify qapplication.cpp 4530 0x348260 18 QCoreApplication::notifyInternal qcoreapplication.cpp 947 0xd4e6b4 19 QCoreApplication::sendEvent qcoreapplication.h 231 0x34aee4 20 QCoreApplicationPrivate::sendPostedEvents qcoreapplication.cpp 1572 0xd4f950 21 QCoreApplication::sendPostedEvents qcoreapplication.cpp 1468 0xd4f548 22 QCoreApplication::sendPostedEvents qcoreapplication.h 236 0x3d2e68 23 QEventDispatcherQWS::flush qeventdispatcher_qws.cpp 164 0x3d2dbc 24 QCoreApplication::flush qcoreapplication.cpp 683 0xd4e0d0 25 QAbstractButton::mousePressEvent qabstractbutton.cpp 1101 0x773910 26 QToolButton::mousePressEvent qtoolbutton.cpp 710 0x804a90 27 QWidget::event qwidget.cpp 8371 0x39d230 28 QAbstractButton::event qabstractbutton.cpp 1085 0x77384c 29 QToolButton::event qtoolbutton.cpp 1162 0x8060cc 30 QApplicationPrivate::notify_helper qapplication.cpp 4566 0x348428 31 QApplication::notify qapplication.cpp 4108 0x3466e4 32 QCoreApplication::notifyInternal qcoreapplication.cpp 947 0xd4e6b4 33 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 234 0x34af58 34 QETWidget::translateMouseEvent qapplication_qws.cpp 3539 0x3cbe08 35 QApplication::qwsProcessEvent qapplication_qws.cpp 2984 0x3c9d48 36 QEventDispatcherQWS::processEvents qeventdispatcher_qws.cpp 121 0x3d2b5c 37 QEventLoop::processEvents qeventloop.cpp 149 0xd4bc7c 38 QEventLoop::exec qeventloop.cpp 200 0xd4be10 39 QCoreApplication::exec qcoreapplication.cpp 1221 0xd4eec8 40 QApplication::exec qapplication.cpp 3823 0x34551c 41 main main.cpp 650 0x2192b4
There you can see, that the mouse button press is captured by the QWS system around line 34, beeing then forwarded to the respective button, which should paint the button as pressed (line 25) and performs a flush of the event queue to get the paint event processed, which in this case also finds the 'delete later' (line 13), that has been posted to the event queue by the previous mouse button press event and performs this deletion. After leaving the flush function, it will continue to operate on illegal pointer variables, because its own object has already been destroyed
-
@anli said in Events after Object destruction:
@JonB :
We tried it and currently do not get the problems there. We are currently trying to understand why.Alternatively, make a copy of your project and gradually simplify your code until the issue disappears.
-
@anli said in Events after Object destruction:
We also tried this, but the second event got fired, before the button is disabled...
mmh, I'll like to throw in a new idea.
You should check, if your connection between button and slot is unique. If you called connect somewhere twice, than this could lead to the race condition. -