qt5base-lts/tests/auto
Jian Liang 8fcab70408 Avoid crash due to accessing deleted QWidgetWindow object
Change childWidget->windowHandle() to childWidget->internalWinId() in
q_createNativeChildrenAndSetParent() to determine whether should we call
childWidget->winId().
This is because in some circumstances Qt will crash due to accessing
deleted QWidgetWindow object if we use windowHandle(). Think about the
following scenario:

1) create a widget A without parent and add two child widgets B and C to A

2) create a native widget D as the child of B, note that when we set
Qt::WA_NativeWindow attribute to it, its QWidgetWindow will be created
which means its windowHandle() is not null.

3) create a top level widget E as the child of C and show it. This will
make Qt call createWinId() to A and then
q_createNativeChildrenAndSetParent() will be called to create A's native
children recursively and finally make D's QWidgetWindow object become a
child of A's QWidgetWindow object. Please note here that B will not become
a native widget just because at that moment windowHandle() of D is not
null and Qt will not call winId() to its parent B

4) Set A's parent to another widget which has been shown, setParent_sys()
will be called to A and then Qt will call destroy() to A. in destroy() Qt
will try to call destroy() to its children recursively with a condition that
the child has Qt::WA_NativeWindow been set. But D's parent B is not a native
widget right now so B and D is not destroyed. Qt will then deleted the
QWidgetWindow object of A, since E's QWidgetWindow object is a child of
A's QWidgetWindow object, it will also be deleted. Now E hold a deleted
pointer of QWidgetWindow object. This is the source of crash later.

Task-number: QTBUG-35600

Change-Id: I97a20a68e626ee62b15bb4eae580e26f8948923b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
2013-12-24 02:56:41 +01:00
..
android Adding CI utilities to Android test script 2013-10-30 11:29:04 +01:00
bic/data test: Add 5.1.0 bic data for linux-gcc-ia32 2013-07-08 21:47:36 +02:00
cmake Teach CMake about Qt 5 plugins. 2013-09-10 14:38:18 +02:00
compilerwarnings/data Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
concurrent QtConcurrent: Workaround GCC bug 58800 in median calculation 2013-12-03 11:45:18 +01:00
corelib Use the short time format of the current locale on Windows 2013-12-16 22:26:37 +01:00
dbus don't erroneously claim that gui support is needed 2013-10-16 17:10:15 +02:00
gui Check if device is opened before trying to create image handler. 2013-12-12 12:02:29 +01:00
guiapplauncher
installed_cmake Add a unit test for testing Qt in its install location. 2013-07-02 23:08:54 +02:00
network QUdpSocket auto test: disable Socks5 over UDP for new test server 2013-12-10 15:14:22 +01:00
opengl Mark tst_qgl as insignificant in angle build 2013-11-12 07:11:07 +01:00
other Fix a race that occurred as we unlock the mutex to destroy the functor in ~QObject 2013-11-26 08:24:25 +01:00
printsupport QPrinter - Fix OutputFormat when no printers 2013-11-29 15:59:00 +01:00
shared Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
sql fix parsing of bound SQL statements for PostgreSQL 2013-12-16 15:35:30 +01:00
testlib Testlib.selftest: Improve process execution, run on openSUSE. 2013-11-19 22:47:43 +01:00
tools Test that Qt tools can handle ' as a digit separator. 2013-10-30 09:44:07 +01:00
widgets Avoid crash due to accessing deleted QWidgetWindow object 2013-12-24 02:56:41 +01:00
xml Fully expand entities to ensure deep or widely nested ones fail parsing 2013-11-14 17:43:58 +01:00
auto.pro exclude gui-needing tests from -no-gui build 2013-10-18 20:05:27 +02:00
network-settings.h network test settings: support newer FTP server versions 2013-08-28 12:45:34 +02:00
qtest-config.h Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
test.pl Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00