summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-09-21 11:05:50 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-09-21 11:08:58 (GMT)
commit0b9c7fab30bafa24ff55e7eb1bc868517d782486 (patch)
treed77806b7dcbf25dd7f541aec88cfc454d17a2e53 /src/gui/dialogs
parentda405d8e1418fd5b7b78fb7a7f8930aefc74f40d (diff)
downloadQt-0b9c7fab30bafa24ff55e7eb1bc868517d782486.zip
Qt-0b9c7fab30bafa24ff55e7eb1bc868517d782486.tar.gz
Qt-0b9c7fab30bafa24ff55e7eb1bc868517d782486.tar.bz2
Fix QPrintDialog with no parent and no active window
PrintDlgEx requires an non-null owner handle, otherwise it will fail with an "Invalid Handle" error. This caused code which popped up a print dialog as the only window in the application to fail silently and immediately return Rejected from the exec() function. To continue support for this somewhat unusual use case, we fall back to using the print dialog itself as the owner of the print dialog sheet if all else fails. Reviewed-by: Trond
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r--src/gui/dialogs/qprintdialog_win.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/dialogs/qprintdialog_win.cpp b/src/gui/dialogs/qprintdialog_win.cpp
index 1a3d2de..f66c27f 100644
--- a/src/gui/dialogs/qprintdialog_win.cpp
+++ b/src/gui/dialogs/qprintdialog_win.cpp
@@ -131,8 +131,8 @@ static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
if (d->ep->printToFile)
pd->Flags |= PD_PRINTTOFILE;
- Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
- pd->hwndOwner = parent ? parent->winId() : 0;
+ Q_ASSERT(parent != 0 && parent->testAttribute(Qt::WA_WState_Created));
+ pd->hwndOwner = parent->winId();
pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
pd->nCopies = d->ep->num_copies;
@@ -212,6 +212,10 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
else
parent = QApplication::activeWindow();
+ // If there is no window, fall back to the print dialog itself
+ if (parent == 0)
+ parent = q;
+
QWidget modal_widget;
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
modal_widget.setParent(parent, Qt::Window);