- Timestamp:
- May 4, 2012 1:54:46 AM (13 years ago)
- 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 48 48 QDialog::DialogCode QIMainDialog::exec() 49 49 { 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: */ 62 67 show(); 63 /* A guard to ourself for the case we destroy ourself .*/68 /* A guard to ourself for the case we destroy ourself: */ 64 69 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: */ 70 73 if (guard.isNull()) 71 74 return QDialog::Rejected; 75 mEventLoop = 0; 76 /* Prepare result: */ 72 77 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: */ 79 81 return res; 80 82 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r41122 r41159 1061 1061 return; 1062 1062 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; 1066 1075 } 1067 1076
Note:
See TracChangeset
for help on using the changeset viewer.