aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml6
-rw-r--r--PySide/typesystem_templates.xml5
-rw-r--r--tests/QtGui/qmainwindow_test.py15
3 files changed, 21 insertions, 5 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index d3473d450..c8ad97e14 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -2134,6 +2134,7 @@
<replace from="$FUNCTION_GET_OLD" to="centralWidget" />
<replace from="$CHILD_TYPE" to="QWidget" />
<replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
</insert-template>
</inject-code>
</modify-function>
@@ -2144,16 +2145,18 @@
<replace from="$FUNCTION_GET_OLD" to="menuBar" />
<replace from="$CHILD_TYPE" to="QMenuBar" />
<replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
</insert-template>
</inject-code>
</modify-function>
- <modify-function signature="setMenuWidget(QWidget*)">
+ <modify-function signature="setMenuWidget(QWidget*)">
<inject-code class="target" position="beginning">
<insert-template name="replace_child">
<replace from="$FUNCTION_GET_OLD" to="menuWidget" />
<replace from="$CHILD_TYPE" to="QWidget" />
<replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
</insert-template>
</inject-code>
</modify-function>
@@ -2164,6 +2167,7 @@
<replace from="$FUNCTION_GET_OLD" to="statusBar" />
<replace from="$CHILD_TYPE" to="QStatusBar" />
<replace from="$PYARG" to="%PYARG_1" />
+ <replace from="$CPPARG" to="%1" />
</insert-template>
</inject-code>
</modify-function>
diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml
index 3a46c620f..9c2be1e7f 100644
--- a/PySide/typesystem_templates.xml
+++ b/PySide/typesystem_templates.xml
@@ -21,9 +21,10 @@
<typesystem>
<template name="replace_child">
$CHILD_TYPE* oldChild = %CPPSELF.$FUNCTION_GET_OLD();
- if (oldChild) {
+ if (oldChild &amp;&amp; (oldChild != $CPPARG)) {
Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[$CHILD_TYPE*](oldChild));
- Shiboken::Object::setParent(NULL, pyChild);
+ Shiboken::Object::setParent(0, pyChild);
+ Shiboken::Object::releaseOwnership(pyChild);
}
Shiboken::Object::setParent(%PYSELF, $PYARG);
</template>
diff --git a/tests/QtGui/qmainwindow_test.py b/tests/QtGui/qmainwindow_test.py
index 372018cb3..6ea84abc7 100644
--- a/tests/QtGui/qmainwindow_test.py
+++ b/tests/QtGui/qmainwindow_test.py
@@ -1,5 +1,6 @@
import unittest
import sys
+import weakref
from PySide import QtGui
from PySide import QtCore
@@ -34,14 +35,19 @@ class TestMainWindow(UsesQApplication):
QtCore.QTimer.singleShot(1000, self.app.quit)
self.app.exec_()
+ def objDel(self, obj):
+ self.app.quit()
+
def testRefCountToNull(self):
w = QtGui.QMainWindow()
c = QtGui.QWidget()
self.assertEqual(sys.getrefcount(c), 2)
w.setCentralWidget(c)
self.assertEqual(sys.getrefcount(c), 3)
+ wr = weakref.ref(c, self.objDel)
w.setCentralWidget(None)
- self.assertEqual(sys.getrefcount(c), 2)
+ c = None
+ self.app.exec_()
def testRefCountToAnother(self):
w = QtGui.QMainWindow()
@@ -52,9 +58,14 @@ class TestMainWindow(UsesQApplication):
c2 = QtGui.QWidget()
w.setCentralWidget(c2)
- self.assertEqual(sys.getrefcount(c), 2)
self.assertEqual(sys.getrefcount(c2), 3)
+ wr = weakref.ref(c, self.objDel)
+ w.setCentralWidget(None)
+ c = None
+
+ self.app.exec_()
+
def testSignalDisconect(self):
w = QtGui.QMainWindow()
b = MyButton("button")