src/gui/widgets/qmenu.cpp
branchRCL_3
changeset 13 c0432d11811c
parent 7 3f74d0d4af4c
equal deleted inserted replaced
12:cc75c76972ee 13:c0432d11811c
  1404     Destroys the menu.
  1404     Destroys the menu.
  1405 */
  1405 */
  1406 QMenu::~QMenu()
  1406 QMenu::~QMenu()
  1407 {
  1407 {
  1408     Q_D(QMenu);
  1408     Q_D(QMenu);
  1409     QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();
  1409     if (!d->widgetItems.isEmpty()) {  // avoid detach on shared null hash
  1410     for (; it != d->widgetItems.end(); ++it) {
  1410         QHash<QAction *, QWidget *>::iterator it = d->widgetItems.begin();
  1411         if (QWidget *widget = it.value()) {
  1411         for (; it != d->widgetItems.end(); ++it) {
  1412             QWidgetAction *action = static_cast<QWidgetAction *>(it.key());
  1412             if (QWidget *widget = it.value()) {
  1413             action->releaseWidget(widget);
  1413                 QWidgetAction *action = static_cast<QWidgetAction *>(it.key());
  1414             *it = 0;
  1414                 action->releaseWidget(widget);
       
  1415                 *it = 0;
       
  1416             }
  1415         }
  1417         }
  1416     }
  1418     }
  1417 
  1419 
  1418     if (d->eventLoop)
  1420     if (d->eventLoop)
  1419         d->eventLoop->exit();
  1421         d->eventLoop->exit();
  2809         return;
  2811         return;
  2810     d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos());
  2812     d->hasHadMouse = d->hasHadMouse || rect().contains(e->pos());
  2811 
  2813 
  2812     QAction *action = d->actionAt(e->pos());
  2814     QAction *action = d->actionAt(e->pos());
  2813     if (!action) {
  2815     if (!action) {
  2814         if (d->hasHadMouse)
  2816         if (d->hasHadMouse
       
  2817             && (!d->currentAction
       
  2818                 || !(d->currentAction->menu() && d->currentAction->menu()->isVisible())))
  2815             d->setCurrentAction(0);
  2819             d->setCurrentAction(0);
  2816         return;
  2820         return;
  2817     } else if(e->buttons()) {
  2821     } else if(e->buttons()) {
  2818         d->mouseDown = this;
  2822         d->mouseDown = this;
  2819     }
  2823     }