summaryrefslogtreecommitdiffstats
path: root/tests/QtUiTools/bug_1135.py
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@zytor.com>2012-02-27 23:16:16 -0300
committerPaulo Alcantara <pcacjr@zytor.com>2012-02-27 23:26:14 -0300
commit3f779b8307ebf4b6bdfbe777f41d76ce4ca25151 (patch)
tree184629fd744505fd54bddab51f80c7a17dc4a2b9 /tests/QtUiTools/bug_1135.py
parentcbd3075fffa95bb9c195f90698533c8d906edaab (diff)
downloadpyside-bug1135.tar.gz
pyside-bug1135.tar.xz
pyside-bug1135.zip
Fix BUG #1135 - "SIGSEGV when loading custom widget using QUiLoader..."bug1135
As PyCustomWidget::createWidget()'s caller is a thread which calls the PyObject_CallObject() function it needs _exclusive_ access to the Python interpreter so that a Shiboken::Gilstate is needed in order to make it thread-safe and avoiding that other threads call the interpreter at the same time. See http://bugs.pyside.org/show_bug.cgi?id=1135. Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
Diffstat (limited to 'tests/QtUiTools/bug_1135.py')
-rw-r--r--tests/QtUiTools/bug_1135.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/QtUiTools/bug_1135.py b/tests/QtUiTools/bug_1135.py
new file mode 100644
index 0000000..4a82413
--- /dev/null
+++ b/tests/QtUiTools/bug_1135.py
@@ -0,0 +1,29 @@
+''' unit test for BUG #1135 '''
+''' see http://bugs.pyside.org/show_bug.cgi?id=1135 '''
+
+from PySide.QtCore import *
+from PySide.QtGui import *
+from PySide.QtUiTools import QUiLoader
+from helper import adjust_filename
+
+class CustomWidget(QFrame):
+ def __init__(self, parent=None):
+ super(CustomWidget, self).__init__(parent)
+ self.layout = QVBoxLayout()
+ self.label = QLabel("Custom widget")
+ self.layout.addWidget(self.label)
+ self.setLayout(self.layout)
+
+class CustomLoader(QUiLoader):
+ def __init__(self):
+ super(CustomLoader,self).__init__()
+
+ def createWidget(self, className, parent=None, name=""):
+ return super(CustomLoader, self).createWidget(className, parent, name)
+
+if __name__ == "__main__":
+ app = QApplication([])
+ loader = CustomLoader()
+ loader.registerCustomWidget(CustomWidget)
+ form = loader.load(adjust_filename("bug_1135.ui", __file__))
+ form.show()