From 3ad9896361ef9382f44a5cfaa80431fe6ea3e1f9 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 1 Feb 2012 13:32:53 +0100 Subject: [PATCH] qpa: Verify that the platform returns a WId that is not WId(0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is motivated by visiting a customer that re-implemented the ::winId method and returned WId(0) that resulted in a crash. Currently there is only a comment inside the implementation of the ::winId default implementation. Add a note to the API documentation, add a Q_ASSERT to check if our assumption holds true. Change-Id: I8607a4efc4f561f7849c976cd2454f6fbcb20eaa Reviewed-by: Samuel Rødal --- src/gui/kernel/qwindow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 5b6ee0e9cb..85f12dd023 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -220,7 +220,11 @@ WId QWindow::winId() const Q_D(const QWindow); if(!d->platformWindow) const_cast(this)->create(); - return d->platformWindow->winId(); + + WId id = d->platformWindow->winId(); + // See the QPlatformWindow::winId() documentation + Q_ASSERT(id != WId(0)); + return id; } QWindow *QWindow::parent() const