Move winId!=0 assertion from QWindow to QWidget

In "very basic platform plugins", the platform window ID can be null,
which conflicts with QWidget's special treatment of 0 as a parented widget.
Such is the case with EGLFS, which can return a null native window handle
for winId on some EGL implementations.

Move the assertion winId!=0 into the widget framework, as this assert is
not relevant for non-widget applications. A large proportion of basic
platform plugin users will see relief from this unnecessary assertion.

Change-Id: I25c9d96550cd747c77c9516d773e9cdebf7440ab
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
This commit is contained in:
Andrew Knight 2013-09-06 08:32:09 +03:00 committed by The Qt Project
parent 6a41fa832e
commit ddbcf78308
2 changed files with 5 additions and 5 deletions

View File

@ -502,10 +502,7 @@ WId QWindow::winId() const
if(!d->platformWindow) if(!d->platformWindow)
const_cast<QWindow *>(this)->create(); const_cast<QWindow *>(this)->create();
WId id = d->platformWindow->winId(); return d->platformWindow->winId();
// See the QPlatformWindow::winId() documentation
Q_ASSERT(id != WId(0));
return id;
} }
/*! /*!

View File

@ -153,7 +153,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
} }
setWindowModified_helper(); setWindowModified_helper();
setWinId(win->winId()); WId id = win->winId();
// See the QPlatformWindow::winId() documentation
Q_ASSERT(id != WId(0));
setWinId(id);
// Check children and create windows for them if necessary // Check children and create windows for them if necessary
q_createNativeChildrenAndSetParent(q); q_createNativeChildrenAndSetParent(q);