summaryrefslogtreecommitdiffstats
path: root/plugins/customwidget.cpp
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 /plugins/customwidget.cpp
parentcbd3075fffa95bb9c195f90698533c8d906edaab (diff)
downloadpyside-3f779b8307ebf4b6bdfbe777f41d76ce4ca25151.tar.gz
pyside-3f779b8307ebf4b6bdfbe777f41d76ce4ca25151.tar.xz
pyside-3f779b8307ebf4b6bdfbe777f41d76ce4ca25151.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 'plugins/customwidget.cpp')
-rw-r--r--plugins/customwidget.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/customwidget.cpp b/plugins/customwidget.cpp
index d573ef4..1098ebf 100644
--- a/plugins/customwidget.cpp
+++ b/plugins/customwidget.cpp
@@ -1,7 +1,7 @@
/*
* This file is part of the PySide project.
*
- * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (C) 2009-2012 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: PySide team <contact@pyside.org>
*
@@ -17,10 +17,9 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include "customwidget.h"
#include <shiboken.h>
@@ -90,7 +89,7 @@ QString PyCustomWidget::whatsThis() const
QWidget* PyCustomWidget::createWidget(QWidget* parent)
{
- //Create a python instance and return cpp object
+ // Create a python instance and return cpp object
PyObject* pyParent;
bool unkowParent = false;
if (parent) {
@@ -108,9 +107,11 @@ QWidget* PyCustomWidget::createWidget(QWidget* parent)
}
Shiboken::AutoDecRef pyArgs(PyTuple_New(1));
- PyTuple_SET_ITEM(pyArgs, 0, pyParent); //tuple will keep pyParent reference
+ PyTuple_SET_ITEM(pyArgs, 0, pyParent); // this tuple will keep pyParent reference
+
+ Shiboken::GilState gil;
- //Call python constructor
+ // Call python constructor
SbkObject* result = reinterpret_cast<SbkObject*>(PyObject_CallObject(m_data->pyObject, pyArgs));
QWidget* widget = 0;