From ef8e5af1d219dd749ea306230cfd097cc2595cb4 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 27 May 2011 16:06:53 +0200 Subject: [PATCH] The proper fix for subwindow parenting issues. The previous patch tried to work around the fact that Qt::SubWindow accidentally pulled in Qt::Window. This patch corrects the root cause of the problem. --- src/corelib/global/qnamespace.h | 2 +- src/widgets/kernel/qwidget_qpa.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 70f13cf79f..4a663fc8a5 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -278,7 +278,7 @@ public: ToolTip = Popup | Sheet, SplashScreen = ToolTip | Dialog, Desktop = 0x00000010 | Window, - SubWindow = Desktop | Dialog, + SubWindow = 0x00000012, WindowType_Mask = 0x000000ff, MSWindowsFixedSizeDialogHint = 0x00000100, diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index c2b60d0387..2120e40c57 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -96,6 +96,12 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO QWindowSurface *surface = q->windowSurface(); QWindow *win = topData()->window; + // topData() ensures the extra is created but does not ensure 'window' is non-null + // in case the extra was already valid. + if (!win) { + createTLSysExtra(); + win = topData()->window; + } win->setWindowFlags(data.window_flags); win->setGeometry(q->geometry()); @@ -250,8 +256,8 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) QPoint QWidget::mapToGlobal(const QPoint &pos) const { - int x=pos.x(), y=pos.y(); - const QWidget* w = this; + int x = pos.x(), y = pos.y(); + const QWidget *w = this; while (w) { x += w->data->crect.x(); y += w->data->crect.y(); @@ -262,8 +268,8 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const QPoint QWidget::mapFromGlobal(const QPoint &pos) const { - int x=pos.x(), y=pos.y(); - const QWidget* w = this; + int x = pos.x(), y = pos.y(); + const QWidget *w = this; while (w) { x -= w->data->crect.x(); y -= w->data->crect.y();