From 9a5b72eb64d698aff507d5c2b2ea6d19bda0b65e Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 9 Nov 2010 14:39:27 +0000 Subject: Send WinIdChange event when winId is set to zero This allows an observer to get a notification just before the window handle owned by a native widget is destroyed. Note that, at the point when the event is sent, the widget's internalWinId() will return the new value, but the old native window handle will not be destroyed until after the event handler is run. Task-number: QTMOBILITY-645 Reviewed-by: sroedal --- dist/changes-4.7.2 | 8 ++++++-- src/gui/kernel/qwidget.cpp | 9 ++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dist/changes-4.7.2 b/dist/changes-4.7.2 index 49bdd8e..a18a237 100644 --- a/dist/changes-4.7.2 +++ b/dist/changes-4.7.2 @@ -45,8 +45,12 @@ QtCore QtGui ----- - - foo - * bar + - QWidget + * [QTMOBILITY-645] Send WinIdChange event when winId is set to zero. + The window handle of a native widget may be set to zero in two + situations: (i) temporarily, during reparenting and (ii) during + widget destruction. Previously, no WinIdChange event was sent in + either of these cases; now, it is sent in both cases. QtDBus ------ diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e22ec55..cbf4886 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1673,13 +1673,8 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier } if(oldWinId != id) { - // Do not emit an event when the old winId is destroyed. This only - // happens (a) during widget destruction, and (b) immediately prior - // to creation of a new winId, for example as a result of re-parenting. - if(id != 0) { - QEvent e(QEvent::WinIdChange); - QCoreApplication::sendEvent(q, &e); - } + QEvent e(QEvent::WinIdChange); + QCoreApplication::sendEvent(q, &e); } } -- cgit v0.12