1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| int QDialog::exec()
{
Q_D(QDialog);
if (d->eventLoop) {
qWarning("QDialog::exec: Recursive call detected");
return -1;
}
bool deleteOnClose = testAttribute(Qt::WA_DeleteOnClose);
setAttribute(Qt::WA_DeleteOnClose, false);
bool wasShowModal = testAttribute(Qt::WA_ShowModal);
setAttribute(Qt::WA_ShowModal, true);
setResult(0);
//On Windows Mobile we create an empty menu to hide the current menu
#ifdef Q_OS_WINCE_WM
#ifndef QT_NO_MENUBAR
QMenuBar *menuBar = 0;
if (!findChild<QMenuBar *>())
menuBar = new QMenuBar(this);
if (qt_wince_is_smartphone()) {
QAction *doneAction = new QAction(tr("Done"), this);
menuBar->setDefaultAction(doneAction);
connect(doneAction, SIGNAL(triggered()), this, SLOT(_q_doneAction()));
}
#endif //QT_NO_MENUBAR
#endif //Q_OS_WINCE_WM
show();
QEventLoop eventLoop;
d->eventLoop = &eventLoop;
QPointer<QDialog> guard = this;
(void) eventLoop.exec();
if (guard.isNull())
return QDialog::Rejected;
d->eventLoop = 0;
setAttribute(Qt::WA_ShowModal, wasShowModal);
int res = result();
if (deleteOnClose)
delete this;
#ifdef Q_OS_WINCE_WM
#ifndef QT_NO_MENUBAR
else if (menuBar)
delete menuBar;
#endif //QT_NO_MENUBAR
#endif //Q_OS_WINCE_WM
return res;
} |
Partager