Add a non-implicit copy constructor to QEvent
authorThiago Macieira <thiago.macieira@intel.com>
Wed, 4 Apr 2012 17:25:12 +0000 (14:25 -0300)
committerQt by Nokia <qt-info@nokia.com>
Wed, 16 May 2012 05:00:31 +0000 (07:00 +0200)
commit2ec089bbc85fa37cd7e0d1e8447bd43858e50873
tree34e516b19947676ca8c0dfefe0ab139cb0d899d1
parentb25b3a9f8bee10d490d3160d1fb28bf0013c8e0b
Add a non-implicit copy constructor to QEvent

Copying events is a bad idea but it is permitted, used at least in the
state machine framework and QApplication, which somehow found it
amusing to clone events. We can't forbid it because it would be
source-incompatible with Qt 4, and other ill-advised developer may be
doing this.

In the new copy functions and in the destructor, ensure that the d
pointer is null. We can't copy it if it isn't. The exception is for
DeferredDelete events, which use the d pointer to store the loop level
count. Such value must not be deleted.

In the future, if QEvent::d is used at the QEvent level, make sure to
adapt QCoreApplication::postEvent to store the counter somewhere else.

Task-number: QTBUG-25070
Change-Id: I1f2d3f3cfc891ec216df2e8b7dbe531524d21b26
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/corelib/kernel/qcoreevent.cpp
src/corelib/kernel/qcoreevent.h