VirtualBox

Changeset 41159 in vbox for trunk


Ignore:
Timestamp:
May 4, 2012 1:54:46 AM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: 6141: Fixing crash which happens if settings-dialog is opened during VM poweroff/shutdown.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIMainDialog.cpp

    r35131 r41159  
    4848QDialog::DialogCode QIMainDialog::exec()
    4949{
    50     AssertMsg (!mEventLoop, ("exec is called recursively!\n"));
    51 
    52     /* Reset the result code */
    53     setResult (QDialog::Rejected);
    54     bool deleteOnClose = testAttribute (Qt::WA_DeleteOnClose);
    55     setAttribute (Qt::WA_DeleteOnClose, false);
    56     bool wasShowModal = testAttribute (Qt::WA_ShowModal);
    57     setAttribute (Qt::WA_ShowModal, true);
    58 
    59     /* Create a local event loop */
    60     mEventLoop = new QEventLoop();
    61     /* Show the window */
     50    /* Check for the recursive run: */
     51    AssertMsg(!mEventLoop, ("QIMainDialog::exec() is called recursively!\n"));
     52
     53    /* Reset the result code: */
     54    setResult(QDialog::Rejected);
     55
     56    /* Tune some attributes: */
     57    bool fDeleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
     58    AssertMsg(!fDeleteOnClose, ("QIMainDialog is NOT supposed to be run in 'delete-on-close' mode!"));
     59    setAttribute(Qt::WA_DeleteOnClose, false);
     60    bool fWasShowModal = testAttribute(Qt::WA_ShowModal);
     61    setAttribute(Qt::WA_ShowModal, true);
     62
     63    /* Create a local event-loop: */
     64    QEventLoop eventLoop;
     65    mEventLoop = &eventLoop;
     66    /* Show the window: */
    6267    show();
    63     /* A guard to ourself for the case we destroy ourself. */
     68    /* A guard to ourself for the case we destroy ourself: */
    6469    QPointer<QIMainDialog> guard = this;
    65     /* Start the event loop. This blocks. */
    66     mEventLoop->exec();
    67     /* Delete the event loop */
    68     delete mEventLoop;
    69     /* Are we valid anymore? */
     70    /* Start the event-loop: */
     71    eventLoop.exec();
     72    /* Check if dialog is still valid: */
    7073    if (guard.isNull())
    7174        return QDialog::Rejected;
     75    mEventLoop = 0;
     76    /* Prepare result: */
    7277    QDialog::DialogCode res = result();
    73     /* Set the old show modal attribute */
    74     setAttribute (Qt::WA_ShowModal, wasShowModal);
    75     /* Delete us in the case we should do so on close */
    76     if (deleteOnClose)
    77         delete this;
    78     /* Return the final result */
     78    /* Restore old show-modal attribute: */
     79    setAttribute(Qt::WA_ShowModal, fWasShowModal);
     80    /* Return the final result: */
    7981    return res;
    8082}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r41122 r41159  
    10611061        return;
    10621062
    1063     /* Create and execute current VM settings dialog: */
    1064     UISettingsDialogMachine dlg(activeMachineWindow(), session().GetMachine().GetId(), strCategory, QString());
    1065     dlg.execute();
     1063    /* Create VM settings dialog on the heap!
     1064     * Its necessary to allow QObject hierarchy cleanup to delete this dialog if necessary: */
     1065    QPointer<UISettingsDialogMachine> pDialog = new UISettingsDialogMachine(activeMachineWindow(),
     1066                                                                            session().GetMachine().GetId(),
     1067                                                                            strCategory, QString());
     1068    /* Executing VM settings dialog.
     1069     * This blocking function calls for the internal event-loop to process all further events,
     1070     * including event which can delete the dialog itself. */
     1071    pDialog->execute();
     1072    /* Delete dialog if its still valid: */
     1073    if (pDialog)
     1074        delete pDialog;
    10661075}
    10671076
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette