Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
4.5.2
-
None
-
dc2cb80ceb35edd958685189e9075ac1061870f4
Description
We have a crash using shortcuts in the QT3_SUPPORT mode. The crash occurs in the function findIdForAction called by activateCausedStack. The crash is due to a defective action instance.
If we look at the caller _q_actionTriggered, the action is correct until the line emit q->activated(id) (see below).
The comment in the first #ifdef QT3_SUPPORT part seems to indicate that it is legal to delete the action (in our case the complete menu is rebuilt). In previous versions of Qt (checked with Qt4.4.2), the part from if( !activationRecursionGuard) was missing. It seems as if the original assumption that the action may be deleted is now broken since the action pointer is used after the activated signal.
At the moment, it seems to be impossible to avoid the deletion of the menu in the event handler. On the other hand, there is no easy way to move to QAction (instead of using QT3_SUPPORT).
void QMenuPrivate::_q_actionTriggered() { Q_Q(QMenu); if (QAction *action = qobject_cast<QAction *>(q->sender())) { #ifdef QT3_SUPPORT //we store it here because the action might be deleted/changed by connected slots const int id = q->findIdForAction(action); #endif emit q->triggered(action); #ifdef QT3_SUPPORT emit q->activated(id); #endif if (!activationRecursionGuard) { //in case the action has not been activated by the mouse //we check the parent hierarchy QList< QPointer<QWidget> > list; for(QWidget *widget = q->parentWidget(); widget; ) { if (qobject_cast<QMenu*>(widget) #ifndef QT_NO_MENUBAR || qobject_cast<QMenuBar*>(widget) #endif ) { list.append(widget); widget = widget->parentWidget(); } else { break; } } activateCausedStack(list, action, QAction::Trigger, false); } } }