aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2012-06-18 17:52:22 -0400
committerHugo Parente Lima <hugo.lima@openbossa.org>2012-07-31 22:01:11 +0200
commit1cea6192fa32fee29ae64cdc2bda1414e6a443bd (patch)
tree9982c3aab06fba086a888c6c9302c7fd8085b3ab
parentc00a1f7ffd313d7e0363a1d386d2bd6e7db3feb6 (diff)
Invalidate invisibleRootItem in clear() method
Fixes PYSIDE-56 Change-Id: If0529a289e6d9613fdd85bd9d37ccf438d4e92ca Reviewed-by: Hugo Parente Lima <hugo.lima@openbossa.org>
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml6
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/QtGui/qstandarditemmodel_test.py8
3 files changed, 16 insertions, 2 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index ab97ee15f..fe5221134 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -4844,6 +4844,12 @@
<modify-function signature="clear()">
<inject-code class="target" position="beginning">
+ Shiboken::BindingManager&amp; bm = Shiboken::BindingManager::instance();
+ SbkObject* pyRoot = bm.retrieveWrapper(%CPPSELF.invisibleRootItem());
+ if (pyRoot) {
+ Shiboken::Object::destroy(pyRoot, %CPPSELF.invisibleRootItem());
+ }
+
for(int r=0, r_max = %CPPSELF.rowCount(); r &lt; r_max; r++) {
QList&lt;QStandardItem *&gt; ri = %CPPSELF.takeRow(0);
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 34e3844bb..3e828a9c9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -6,7 +6,7 @@ else()
endif()
if(WIN32)
- set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${testbinding_BINARY_DIR}")
+ set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${testbinding_BINARY_DIR};$ENV{PYTHONPATH}")
set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR};${pysidetest_BINARY_DIR};${SHIBOKEN_INCLUDE_DIR}/../../bin;$ENV{PATH}")
set(LIBRARY_PATH_VAR "PATH")
string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
@@ -15,7 +15,7 @@ else()
string(REPLACE ";" "\\;" TEST_PYTHONPATH "${TEST_PYTHONPATH}")
string(REPLACE ";" "\\;" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}")
else()
- set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util:${testbinding_BINARY_DIR}")
+ set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util:${testbinding_BINARY_DIR}:$ENV{PYTHONPATH}")
set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR}:${pysidetest_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}")
set(LIBRARY_PATH_VAR "LD_LIBRARY_PATH")
endif()
diff --git a/tests/QtGui/qstandarditemmodel_test.py b/tests/QtGui/qstandarditemmodel_test.py
index 6ab86dd04..514a9247e 100644
--- a/tests/QtGui/qstandarditemmodel_test.py
+++ b/tests/QtGui/qstandarditemmodel_test.py
@@ -2,6 +2,7 @@ import unittest
import sys
from PySide.QtGui import QStandardItemModel, QWidget, QStandardItem
+import shiboken
from helper import UsesQApplication
@@ -21,6 +22,13 @@ class QStandardItemModelTest(UsesQApplication):
# bug #227
self.model.insertRow(0)
+ def testClear(self):
+
+ model = QStandardItemModel()
+ root = model.invisibleRootItem()
+ model.clear()
+ self.assertFalse(shiboken.isValid(root))
+
class QStandardItemModelRef(UsesQApplication):
def testRefCount(self):