From 8492b69d3302dcf9bbe25fbd7f4ae2654fbbafae Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 23 Aug 2011 10:21:38 -0300 Subject: [PATCH 001/152] Fixed build for Qt 4.6. --- PySide/QtScript/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PySide/QtScript/CMakeLists.txt b/PySide/QtScript/CMakeLists.txt index 88b0a06..024d51f 100644 --- a/PySide/QtScript/CMakeLists.txt +++ b/PySide/QtScript/CMakeLists.txt @@ -1,10 +1,10 @@ project(QtScript) -if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) - set (QtCore_46_SRC ) +if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 7) + set (QtScript_47_SRC ) else() - set(QtScript_46_SRC - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptprogram_wrapper.cpp + set(QtScript_47_SRC + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptprogram_wrapper.cpp ) endif() @@ -22,7 +22,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptextensionplugin_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptstring_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptvalue_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptvalueiterator_wrapper.cpp -${QtScript_46_SRC} +${QtScript_47_SRC} ) set(QtScript_typesystem_path "${QtCore_SOURCE_DIR}") From c31c7c60da668bc690dd0fde3659f64c7d5c5b9c Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 23 Aug 2011 14:27:15 -0300 Subject: [PATCH 002/152] Implement support to pyside debug mode on documentation generator. Reviewed by: Hugo Parente Lauro Moura --- doc/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 05584eb..61eeb09 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -8,9 +8,14 @@ add_custom_target(qdoc3 COMMENT "Running qdoc3 against Qt source code..." SOURCE "pyside.qdocconf") + +find_program(SPHINX_BUILD NAMES sphinx-build) +if (${SPHINX_BUILD} MATCHES "SPHINX_BUILD-NOTFOUND") + message(FATAL_ERROR "sphinx-build command not found.") +endif() add_custom_target(apidoc COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/rst - COMMAND sphinx-build -b html ${CMAKE_CURRENT_BINARY_DIR}/rst html + COMMAND ${SHIBOKEN_PYTHON_INTERPRETER} ${SPHINX_BUILD} -b html ${CMAKE_CURRENT_BINARY_DIR}/rst html ) # create conf.py based on conf.py.in From 544414cc0372d0f50c621f3785d43ba3a8c2cf04 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 24 Aug 2011 10:34:45 -0300 Subject: [PATCH 003/152] Created unit test for bug #959. Reviewed by: Hugo Parente Luciano Wolf --- tests/QtWebKit/CMakeLists.txt | 1 + tests/QtWebKit/bug_959.py | 87 +++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tests/QtWebKit/bug_959.py diff --git a/tests/QtWebKit/CMakeLists.txt b/tests/QtWebKit/CMakeLists.txt index f9b4663..5f0820d 100644 --- a/tests/QtWebKit/CMakeLists.txt +++ b/tests/QtWebKit/CMakeLists.txt @@ -2,6 +2,7 @@ PYSIDE_TEST(bug_448.py) PYSIDE_TEST(bug_694.py) PYSIDE_TEST(bug_803.py) PYSIDE_TEST(bug_899.py) +PYSIDE_TEST(bug_959.py) PYSIDE_TEST(qvariantlist_property_test.py) PYSIDE_TEST(qml_plugin_test.py) PYSIDE_TEST(webpage_test.py) diff --git a/tests/QtWebKit/bug_959.py b/tests/QtWebKit/bug_959.py new file mode 100644 index 0000000..26cdad8 --- /dev/null +++ b/tests/QtWebKit/bug_959.py @@ -0,0 +1,87 @@ +from PySide.QtCore import QObject, Slot, QTimer +from PySide.QtWebKit import QWebView, QWebPage + +import unittest +from helper import UsesQApplication + +class JSFuncs(QObject): + functionID = -1 + @Slot(unicode,result=unicode) + def slot_str_str(self, x): + print "slot_str_str(%r)"%x + JSFuncs.functionID = 0 + return x.upper() + + @Slot(unicode,result='QVariant') + def slot_str_list(self, x): + print "slot_str_list(%r)"%x + JSFuncs.functionID = 1 + return [x, x] + + @Slot('QStringList',result=unicode) + def slot_strlist_str(self, x): + print "slot_strlist_str(%r)"%x + JSFuncs.functionID = 2 + return x[-1] + + @Slot('QVariant',result=unicode) + def slot_variant_str(self, x): + print "slot_variant_str(%r)"%x + JSFuncs.functionID = 3 + return unicode(x) + + @Slot('QVariantList',result=unicode) + def slot_variantlist_str(self, x): + print "slot_variantlist_str(%r)"%x + JSFuncs.functionID = 4 + return unicode(x[-1]) + + @Slot('QVariantMap',result=unicode) + def slot_variantmap_str(self, x): + print "slot_variantmap_str(%r)"%x + JSFuncs.functionID = 5 + return unicode(x["foo"]) + + + +PAGE_DATA = "data:text/html," +FUNCTIONS_LIST = ['jsfuncs.slot_str_str("hello")', + 'jsfuncs.slot_str_list("hello")', + 'jsfuncs.slot_strlist_str(["hello","world"])', + 'jsfuncs.slot_variant_str("hello")', + 'jsfuncs.slot_variantlist_str(["hello","world"])', + 'jsfuncs.slot_variantmap_str({"foo": "bar"})'] + + +class TestJsCall(UsesQApplication): + + @classmethod + def setUpClass(self): + super(TestJsCall, self).setUpClass() + + def createInstance(self): + self._view = QWebView() + self._jsfuncs = JSFuncs() + JSFuncs.functionID = -1 + self._view.page().mainFrame().addToJavaScriptWindowObject("jsfuncs", self._jsfuncs) + self._view.loadFinished[bool].connect(self.onLoadFinished) + self._view.load(PAGE_DATA % FUNCTIONS_LIST[self._functionID]) + self._view.show() + + def testJsCall(self): + self._functionID = 0 + self.createInstance() + self.app.exec_() + + def onLoadFinished(self, result): + self.assertEqual(self._functionID, JSFuncs.functionID) + if self._functionID == len(FUNCTIONS_LIST) - 1: + QTimer.singleShot(300, self.app.quit) + else: + #new test + self._functionID += 1 + self.createInstance() + + +if __name__ == "__main__": + unittest.main() From 34d424f89da117188a8994a78e042e3141808ea6 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 24 Aug 2011 14:57:24 -0300 Subject: [PATCH 004/152] Register QVariantMap on TypeManager. fixes bug #959. Reviewed by: Hugo Parente Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 83f69df..6889b2e 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -155,6 +155,8 @@ + + From f5a1baac2f018bf75023c9ec98c06b885ac3c1ff Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 24 Aug 2011 17:21:32 -0300 Subject: [PATCH 005/152] Fixex return policy on QNetworkAccessManager.createRequest. Reviewed by: Hugo Parente Luciano Wolf --- PySide/QtNetwork/typesystem_network.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PySide/QtNetwork/typesystem_network.xml b/PySide/QtNetwork/typesystem_network.xml index d4aa34e..afa41ca 100644 --- a/PySide/QtNetwork/typesystem_network.xml +++ b/PySide/QtNetwork/typesystem_network.xml @@ -173,6 +173,9 @@ + + + From 138d8c42681a0fd2a73d8ac94aae375af21e6892 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 24 Aug 2011 17:22:56 -0300 Subject: [PATCH 006/152] Fixed QMenu, QMenuBar, QToolBar clear function. During the clear function all QActions need be destroyed. Reviewed by: Hugo Parente Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 626c249..c35a759 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -2370,6 +2370,10 @@ + + + + %PYARG_0 = addActionWithPyObject(%CPPSELF, QIcon(), %1, %2, %3); @@ -2379,11 +2383,25 @@ + + + + %PYARG_0 = addActionWithPyObject(%CPPSELF, %1, %2, %3, %4); + + + foreach(QAction *act, %CPPSELF.actions()) { + Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act)); + Shiboken::Object::setParent(NULL, pyAct); + Shiboken::Object::invalidate(pyAct); + } + + + @@ -2434,6 +2452,15 @@ + + + foreach(QAction *act, %CPPSELF.actions()) { + Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act)); + Shiboken::Object::setParent(NULL, pyAct); + Shiboken::Object::invalidate(pyAct); + } + + @@ -5123,6 +5150,10 @@ + + + + QAction* action = %CPPSELF.addAction(%1, %2); %PYARG_0 = %CONVERTTOPYTHON[QAction*](action); @@ -5136,6 +5167,9 @@ + + + QAction* action = %CPPSELF.addAction(%1); %PYARG_0 = %CONVERTTOPYTHON[QAction*](action); @@ -5189,6 +5223,14 @@ lst << pyChild; } } + + //Remove actions + foreach(QAction *act, %CPPSELF.actions()) { + Shiboken::AutoDecRef pyAct(%CONVERTTOPYTHON[QAction*](act)); + Shiboken::Object::setParent(NULL, pyAct); + Shiboken::Object::invalidate(pyAct); + } + %CPPSELF.clear(); foreach(PyObject* obj, lst) { Shiboken::Object::invalidate(reinterpret_cast<SbkObject* >(obj)); From 6e9b7ffd5971d56101a304e3bd9e0a4205637aaf Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 24 Aug 2011 17:24:21 -0300 Subject: [PATCH 007/152] Created unit test for QMenu, QMenuBar, QToolBar clear function. Reviewed by: Hugo Parente Luciano Wolf --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/action_clear.py | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/QtGui/action_clear.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 96920b4..9c9339d 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -1,5 +1,6 @@ #Keep this in alphabetical sort +PYSIDE_TEST(action_clear.py) PYSIDE_TEST(api2_test.py) PYSIDE_TEST(add_action_test.py) PYSIDE_TEST(bug_172.py) diff --git a/tests/QtGui/action_clear.py b/tests/QtGui/action_clear.py new file mode 100644 index 0000000..54d5e93 --- /dev/null +++ b/tests/QtGui/action_clear.py @@ -0,0 +1,46 @@ +from PySide.QtGui import QMenu, QWidget, QMenuBar, QToolBar +import weakref + +import unittest +from helper import UsesQApplication + + +class TestQActionLifeCycle(UsesQApplication): + def actionDestroyed(self, act): + self._actionDestroyed = True + + def testMenu(self): + self._actionDestroyed = False + w = QWidget() + menu = QMenu(w) + act = menu.addAction("MENU") + _ref = weakref.ref(act, self.actionDestroyed) + act = None + self.assertFalse(self._actionDestroyed) + menu.clear() + self.assertTrue(self._actionDestroyed) + + def testMenuBar(self): + self._actionDestroyed = False + w = QWidget() + menuBar = QMenuBar(w) + act = menuBar.addAction("MENU") + _ref = weakref.ref(act, self.actionDestroyed) + act = None + self.assertFalse(self._actionDestroyed) + menuBar.clear() + self.assertTrue(self._actionDestroyed) + + def testToolBar(self): + self._actionDestroyed = False + w = QWidget() + toolBar = QToolBar(w) + act = toolBar.addAction("MENU") + _ref = weakref.ref(act, self.actionDestroyed) + act = None + self.assertFalse(self._actionDestroyed) + toolBar.clear() + self.assertTrue(self._actionDestroyed) + +if __name__ == "__main__": + unittest.main() From 65d4cf2be4bf6071b03c9ae34368d9cffda597e5 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 25 Aug 2011 17:29:01 -0300 Subject: [PATCH 008/152] Fix complation warning relative to PyDateTime_IMPORT. --- PySide/QtCore/qdatetime_conversions.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PySide/QtCore/qdatetime_conversions.h b/PySide/QtCore/qdatetime_conversions.h index 38c0336..44cf92c 100644 --- a/PySide/QtCore/qdatetime_conversions.h +++ b/PySide/QtCore/qdatetime_conversions.h @@ -1,3 +1,6 @@ +#define PySideDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", \ + (char*)"datetime_CAPI") namespace Shiboken { inline bool Converter::checkType(PyObject* pyObj) @@ -16,7 +19,7 @@ inline bool Converter::isConvertible(PyObject* pyObj) return true; if (!PyDateTimeAPI) - PyDateTime_IMPORT; + PySideDateTime_IMPORT; SbkObjectType* shiboType = reinterpret_cast(SbkType< ::QDateTime >()); return PyDateTime_Check(pyObj) || ObjectType::isExternalConvertible(shiboType, pyObj); @@ -26,7 +29,7 @@ inline bool Converter::isConvertible(PyObject* pyObj) inline QDateTime Converter::toCpp(PyObject* pyObj) { if (!PyDateTimeAPI) - PyDateTime_IMPORT; + PySideDateTime_IMPORT; if (pyObj == Py_None) { return QDateTime(); From d5b645d3ab8faa5aa5887e7fecf370f7ef322bba Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 15:38:23 -0300 Subject: [PATCH 009/152] Created utility function to call a python method usign args received in qt_metacall. Reviewed by: Hugo Parente Luciano Wolf --- libpyside/globalreceiverv2.cpp | 36 ++--- libpyside/signalmanager.cpp | 232 ++++++++++++++++++--------------- libpyside/signalmanager.h | 2 + 3 files changed, 140 insertions(+), 130 deletions(-) diff --git a/libpyside/globalreceiverv2.cpp b/libpyside/globalreceiverv2.cpp index c31a9d2..748332f 100644 --- a/libpyside/globalreceiverv2.cpp +++ b/libpyside/globalreceiverv2.cpp @@ -52,7 +52,7 @@ class DynamicSlotDataV2 int addSlot(const char* signature); int id(const char* signature) const; - PyObject* call(PyObject* args); + PyObject* callback(); QByteArray hash() const; void notify(); @@ -115,20 +115,17 @@ QByteArray DynamicSlotDataV2::hash(PyObject* callback) return QByteArray::number((qlonglong)PyObject_Hash(callback)); } -PyObject* DynamicSlotDataV2::call(PyObject* args) +PyObject* DynamicSlotDataV2::callback() { PyObject* callback = m_callback; //create a callback based on method data if (m_isMethod) callback = PyMethod_New(m_callback, m_pythonSelf, m_pyClass); + else + Py_INCREF(callback); - PyObject* result = PyObject_CallObject(callback, args); - - if (m_isMethod) - Py_DECREF(callback); - - return result; + return callback; } int DynamicSlotDataV2::id(const char* signature) const @@ -282,26 +279,9 @@ int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void** args) m_refs.removeAll(obj); // remove all refs to this object decRef(); //remove the safe ref } else { - Shiboken::GilState gil; - PyObject* retval = 0; - - bool isShortCurt = (strstr(slot.signature(), "(") == 0); - if (isShortCurt) { - retval = m_data->call(reinterpret_cast(args[1])); - } else { - QList paramTypes = slot.parameterTypes(); - Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count())); - for (int i = 0, max = paramTypes.count(); i < max; ++i) { - PyObject* arg = Shiboken::TypeResolver::get(paramTypes[i].constData())->toPython(args[i+1]); // Do not increment the reference - PyTuple_SET_ITEM(preparedArgs.object(), i, arg); - } - retval = m_data->call(preparedArgs); - } - - if (!retval) - PyErr_Print(); - else - Py_DECREF(retval); + bool isShortCuit = (strstr(slot.signature(), "(") == 0); + Shiboken::AutoDecRef callback(m_data->callback()); + SignalManager::callPythonMetaMethod(slot, args, callback, isShortCuit); } return -1; diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index c0dffd4..bd455c9 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -50,6 +50,12 @@ namespace { static PyObject *metaObjectAttr = 0; + + static int callMethod(QObject* object, int id, void** args); + static PyObject* parseArguments(QList paramTypese, void** args); + static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args); + static bool emitNormalSignal(QObject* source, int signalIndex, const char* signal, PyObject* args, const QStringList& argTypes); + static void destroyMetaObject(void* obj) { delete reinterpret_cast(obj); @@ -58,7 +64,6 @@ namespace { namespace PySide { -static int callMethod(QObject* object, int id, void** args); PyObjectWrapper::PyObjectWrapper() :m_me(Py_None) @@ -309,58 +314,6 @@ int SignalManager::globalReceiverSlotIndex(QObject* receiver, const char* signat return reinterpret_cast(receiver)->addSlot(signature); } -static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args) -{ - void* signalArgs[2] = {0, args}; - source->qt_metacall(QMetaObject::InvokeMetaMethod, signalIndex, signalArgs); - return true; -} - -static bool emitNormalSignal(QObject* source, int signalIndex, const char* signal, PyObject* args, const QStringList& argTypes) -{ - Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0)); - int argsGiven = PySequence_Fast_GET_SIZE(sequence.object()); - - if (argsGiven != argTypes.count()) { - PyErr_Format(PyExc_TypeError, "%s only accepts %d arguments, %d given!", signal, argTypes.count(), argsGiven); - return false; - } - - QVariant* signalValues = new QVariant[argsGiven]; - void** signalArgs = new void*[argsGiven + 1]; - signalArgs[0] = 0; - - int i; - for (i = 0; i < argsGiven; ++i) { - QByteArray typeName = argTypes[i].toAscii(); - Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get(typeName); - if (typeResolver) { - if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ValueType) { - int typeId = QMetaType::type(typeName); - if (!typeId) { - PyErr_Format(PyExc_TypeError, "Value type used on signal needs to be registered on meta type: %s", typeName.data()); - break; - } - signalValues[i] = QVariant(typeId, (void*) 0); - } - signalArgs[i+1] = signalValues[i].data(); - typeResolver->toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i), &signalArgs[i+1]); - } else { - PyErr_Format(PyExc_TypeError, "Unknown type used to emit a signal: %s", qPrintable(argTypes[i])); - break; - } - } - - bool ok = i == argsGiven; - if (ok) - source->qt_metacall(QMetaObject::InvokeMetaMethod, signalIndex, signalArgs); - - delete[] signalArgs; - delete[] signalValues; - - return ok; -} - bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* args) { if (!Signal::checkQtSignal(signal)) @@ -444,60 +397,36 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, return id; } -static int PySide::callMethod(QObject* object, int id, void** args) +int SignalManager::callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* pyMethod, bool isShortCuit) { - const QMetaObject* metaObject = object->metaObject(); - QMetaMethod method = metaObject->method(id); + Q_ASSERT(pyMethod); - if (method.methodType() == QMetaMethod::Signal) { - // emit python signal - QMetaObject::activate(object, id, args); + Shiboken::GilState gil; + PyObject* pyArguments = NULL; + + if (isShortCuit) + pyArguments = reinterpret_cast(args[1]); + else + pyArguments = parseArguments(method.parameterTypes(), args); + + //keep the returnType this call be destroyed after method call + QByteArray returnType = method.typeName(); + + Shiboken::AutoDecRef retval(PyObject_CallObject(pyMethod, pyArguments)); + + if (!isShortCuit) + Py_XDECREF(pyArguments); + + if (retval.isNull()) { + PyErr_Print(); } else { - // call python slot - Shiboken::GilState gil; - QList paramTypes = method.parameterTypes(); - PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object); - PyObject* preparedArgs = NULL; - Py_ssize_t argsSize = paramTypes.count(); - - if (argsSize) - preparedArgs = PyTuple_New(argsSize); - - for (int i = 0, max = paramTypes.count(); i < max; ++i) { - void* data = args[i+1]; - const char* dataType = paramTypes[i].constData(); - - Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(dataType); - if (tr) { - PyObject* arg = tr->toPython(data); - PyTuple_SET_ITEM(preparedArgs, i, arg); - } else { - PyErr_Format(PyExc_TypeError, "Can't call meta function because I have no idea how to handle %s", dataType); - return -1; - } - } - - QString methodName = method.signature(); - methodName = methodName.left(methodName.indexOf('(')); - - Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(self, qPrintable(methodName))); - if (!pyMethod.isNull()) { - Shiboken::AutoDecRef retval(PyObject_CallObject(pyMethod, preparedArgs)); - if (retval.isNull()) { - qWarning() << "Error calling slot" << methodName; - PyErr_Print(); - } else { - const char* returnType = method.typeName(); - if (returnType && (strlen(returnType) > 0)) - Shiboken::TypeResolver::get(returnType)->toCpp(retval, &args[0]); - } - } else { - qWarning() << "Dynamic slot" << methodName << "not found!"; - } - Py_XDECREF(preparedArgs); + if (returnType.size() > 0) + Shiboken::TypeResolver::get(returnType)->toCpp(retval, &args[0]); } + return -1; } + bool SignalManager::registerMetaMethod(QObject* source, const char* signature, QMetaMethod::MethodType type) { int ret = registerMetaMethodGetIndex(source, signature, type); @@ -544,7 +473,6 @@ bool SignalManager::hasConnectionWith(const QObject *object) return m_d->m_globalReceiver.hasConnectionWith(object); } - const QMetaObject* SignalManager::retriveMetaObject(PyObject *self) { Shiboken::GilState gil; @@ -563,4 +491,104 @@ const QMetaObject* SignalManager::retriveMetaObject(PyObject *self) return mo; } +namespace { +static int callMethod(QObject* object, int id, void** args) +{ + const QMetaObject* metaObject = object->metaObject(); + QMetaMethod method = metaObject->method(id); + + if (method.methodType() == QMetaMethod::Signal) { + // emit python signal + QMetaObject::activate(object, id, args); + } else { + Shiboken::GilState gil; + PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(object); + QByteArray methodName = method.signature(); + methodName = methodName.left(methodName.indexOf('(')); + Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(self, methodName)); + SignalManager::callPythonMetaMethod(method, args, pyMethod, false); + } + return -1; +} + + +static PyObject* parseArguments(QList paramTypes, void** args) +{ + PyObject* preparedArgs = NULL; + Py_ssize_t argsSize = paramTypes.count(); + + if (argsSize) + preparedArgs = PyTuple_New(argsSize); + + for (int i = 0, max = paramTypes.count(); i < max; ++i) { + void* data = args[i+1]; + const char* dataType = paramTypes[i].constData(); + + Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(dataType); + if (tr) { + PyObject* arg = tr->toPython(data); + PyTuple_SET_ITEM(preparedArgs, i, arg); + } else { + PyErr_Format(PyExc_TypeError, "Can't call meta function because I have no idea how to handle %s", dataType); + Py_DECREF(preparedArgs); + return NULL; + } + } + + return preparedArgs; +} + +static bool emitShortCircuitSignal(QObject* source, int signalIndex, PyObject* args) +{ + void* signalArgs[2] = {0, args}; + source->qt_metacall(QMetaObject::InvokeMetaMethod, signalIndex, signalArgs); + return true; +} + +static bool emitNormalSignal(QObject* source, int signalIndex, const char* signal, PyObject* args, const QStringList& argTypes) +{ + Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0)); + int argsGiven = PySequence_Fast_GET_SIZE(sequence.object()); + + if (argsGiven != argTypes.count()) { + PyErr_Format(PyExc_TypeError, "%s only accepts %d arguments, %d given!", signal, argTypes.count(), argsGiven); + return false; + } + + QVariant* signalValues = new QVariant[argsGiven]; + void** signalArgs = new void*[argsGiven + 1]; + signalArgs[0] = 0; + + int i; + for (i = 0; i < argsGiven; ++i) { + QByteArray typeName = argTypes[i].toAscii(); + Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get(typeName); + if (typeResolver) { + if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ValueType) { + int typeId = QMetaType::type(typeName); + if (!typeId) { + PyErr_Format(PyExc_TypeError, "Value type used on signal needs to be registered on meta type: %s", typeName.data()); + break; + } + signalValues[i] = QVariant(typeId, (void*) 0); + } + signalArgs[i+1] = signalValues[i].data(); + typeResolver->toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i), &signalArgs[i+1]); + } else { + PyErr_Format(PyExc_TypeError, "Unknown type used to emit a signal: %s", qPrintable(argTypes[i])); + break; + } + } + + bool ok = i == argsGiven; + if (ok) + source->qt_metacall(QMetaObject::InvokeMetaMethod, signalIndex, signalArgs); + + delete[] signalArgs; + delete[] signalValues; + + return ok; +} + +} //namespace diff --git a/libpyside/signalmanager.h b/libpyside/signalmanager.h index 1c8ecfc..744cf9e 100644 --- a/libpyside/signalmanager.h +++ b/libpyside/signalmanager.h @@ -79,6 +79,8 @@ public: // Disconnect all signals managed by Globalreceiver void clear(); + // Utility function to call a python method usign args received in qt_metacall + static int callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* obj, bool isShortCuit); PYSIDE_DEPRECATED(QObject* globalReceiver()); PYSIDE_DEPRECATED(void addGlobalSlot(const char* slot, PyObject* callback)); From e9b959ed8ef5bab7840220675c327f6b0ffc3204 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 15:39:29 -0300 Subject: [PATCH 010/152] Implemented inject code for function QWebPage.qt_metacall. This inject code is necessary due a workaround on C++ class QWebPage. Check de C++ doc for more information: http://doc.qt.nokia.com/4.7-snapshot/qwebpage.html#shouldInterruptJavaScript Fixes bug #973. Reviewed by: Hugo Parente Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 1 - PySide/QtWebKit/typesystem_webkit.xml | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 6889b2e..124b4cd 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -62,7 +62,6 @@ - diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml index bd32ccc..5dbd449 100644 --- a/PySide/QtWebKit/typesystem_webkit.xml +++ b/PySide/QtWebKit/typesystem_webkit.xml @@ -163,6 +163,27 @@ + + + + static int _signalIndex = -1; + static QMetaMethod _m; + + if (_signalIndex == -1) { + _signalIndex = QWebPage::staticMetaObject.indexOfSlot("shouldInterruptJavaScript()"); + _m = QWebPage::staticMetaObject.method(_signalIndex); + } + + if (_signalIndex == id) { + Shiboken::GilState gil; + PyObject* self = (PyObject*)Shiboken::BindingManager::instance().retrieveWrapper(this); + if (self) { + Shiboken::AutoDecRef _pyMethod(PyObject_GetAttrString(self, "shouldInterruptJavaScript")); + return PySide::SignalManager::callPythonMetaMethod(_m, args, _pyMethod, false); + } + } + + From b3e839c1f8cc0f2181ccafb4aebd9dd1a153eb8a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 15:49:38 -0300 Subject: [PATCH 011/152] Removed debug messages from the test. Reviewed by: Hugo Parente Luciano Wolf --- tests/QtWebKit/bug_959.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/QtWebKit/bug_959.py b/tests/QtWebKit/bug_959.py index 26cdad8..c4e53c7 100644 --- a/tests/QtWebKit/bug_959.py +++ b/tests/QtWebKit/bug_959.py @@ -8,37 +8,31 @@ class JSFuncs(QObject): functionID = -1 @Slot(unicode,result=unicode) def slot_str_str(self, x): - print "slot_str_str(%r)"%x JSFuncs.functionID = 0 return x.upper() @Slot(unicode,result='QVariant') def slot_str_list(self, x): - print "slot_str_list(%r)"%x JSFuncs.functionID = 1 return [x, x] @Slot('QStringList',result=unicode) def slot_strlist_str(self, x): - print "slot_strlist_str(%r)"%x JSFuncs.functionID = 2 return x[-1] @Slot('QVariant',result=unicode) def slot_variant_str(self, x): - print "slot_variant_str(%r)"%x JSFuncs.functionID = 3 return unicode(x) @Slot('QVariantList',result=unicode) def slot_variantlist_str(self, x): - print "slot_variantlist_str(%r)"%x JSFuncs.functionID = 4 return unicode(x[-1]) @Slot('QVariantMap',result=unicode) def slot_variantmap_str(self, x): - print "slot_variantmap_str(%r)"%x JSFuncs.functionID = 5 return unicode(x["foo"]) From 01bd258e107ca3ef58e1b1dd9d9bc62f2b602c59 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 16:03:08 -0300 Subject: [PATCH 012/152] Created unit test for bug #973. Reviewed by: Hugo Parente Luciano Wolf --- tests/QtWebKit/CMakeLists.txt | 1 + .../shouldInterruptjavascript_test.py | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/QtWebKit/shouldInterruptjavascript_test.py diff --git a/tests/QtWebKit/CMakeLists.txt b/tests/QtWebKit/CMakeLists.txt index 5f0820d..7fab647 100644 --- a/tests/QtWebKit/CMakeLists.txt +++ b/tests/QtWebKit/CMakeLists.txt @@ -5,6 +5,7 @@ PYSIDE_TEST(bug_899.py) PYSIDE_TEST(bug_959.py) PYSIDE_TEST(qvariantlist_property_test.py) PYSIDE_TEST(qml_plugin_test.py) +PYSIDE_TEST(shouldInterruptjavascript_test.py) PYSIDE_TEST(webpage_test.py) PYSIDE_TEST(webview_test.py) PYSIDE_TEST(webframe_test.py) diff --git a/tests/QtWebKit/shouldInterruptjavascript_test.py b/tests/QtWebKit/shouldInterruptjavascript_test.py new file mode 100644 index 0000000..b624220 --- /dev/null +++ b/tests/QtWebKit/shouldInterruptjavascript_test.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import unittest +from PySide import QtCore, QtWebKit + +from helper import UsesQApplication + +class QWebPageHeadless(QtWebKit.QWebPage): + # FIXME: This is not working, the slot is not overriden! + # http://doc.qt.nokia.com/4.7-snapshot/qwebpage.html#shouldInterruptJavaScript + @QtCore.Slot() + def shouldInterruptJavaScript(self): + self._interrupted = True + QtCore.QTimer.singleShot(300, self._app.quit) + return True + +class TestSlotOverride(UsesQApplication): + def testFunctionCall(self): + page = QWebPageHeadless() + page._interrupted = False + page._app = self.app + page.mainFrame().setHtml('') + self.app.exec_() + self.assertTrue(page._interrupted) + +if __name__ == '__main__': + unittest.main() From 5eda2f136589c9e28fa9c16c55370627f54af73e Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 25 Aug 2011 19:27:48 -0300 Subject: [PATCH 013/152] Fix white space. --- PySide/QtCore/typesystem_core.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 124b4cd..ba25881 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1510,7 +1510,7 @@ - + From e59a9f833f4cb1a891bd84bf87f11c1538496bef Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 25 Aug 2011 19:41:19 -0300 Subject: [PATCH 014/152] Added missing primitive types on QtCore type system. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index ba25881..71c9572 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -104,7 +104,9 @@ + + @@ -116,7 +118,9 @@ + + From b6068afc3eb822fea7846b294e56412a16d8da56 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 18:42:26 -0300 Subject: [PATCH 015/152] Fixed SignalManager bug during anonymous signal connection. Reviewed by: Hugo Parente Luciano Wolf --- libpyside/signalmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index bd455c9..002d8f9 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -275,10 +275,12 @@ QObject* SignalManager::globalReceiver(QObject *sender, PyObject *callback) SharedMap globalReceivers = m_d->m_globalReceivers; QByteArray hash = GlobalReceiverV2::hash(callback); GlobalReceiverV2* gr = 0; - if (!globalReceivers->contains(hash) && sender) { + if (!globalReceivers->contains(hash)) { gr = (*globalReceivers)[hash] = new GlobalReceiverV2(callback, globalReceivers); - gr->incRef(sender); // create a link reference - gr->decRef(); // remove extra reference + if (sender) { + gr->incRef(sender); // create a link reference + gr->decRef(); // remove extra reference + } } else { gr = (*globalReceivers)[hash]; if (sender) From d0decf40df7ec0f9474a2237fb0fd4809c43589f Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 19:11:54 -0300 Subject: [PATCH 016/152] Fail during the signal connection or disconnection raises exception. Fixes bug #987. Reviewed by: Hugo Parente Luciano Wolf --- libpyside/pysidesignal.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/libpyside/pysidesignal.cpp b/libpyside/pysidesignal.cpp index 7fdb01f..b4940d5 100644 --- a/libpyside/pysidesignal.cpp +++ b/libpyside/pysidesignal.cpp @@ -374,9 +374,14 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds) if (match) { Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "connect")); - return PyObject_CallObject(pyMethod, tupleArgs); + PyObject* result = PyObject_CallObject(pyMethod, tupleArgs); + if (result == Py_True) + return result; + else + Py_DECREF(result); } + PyErr_Format(PyExc_RuntimeError, "Fail to connect signal %s.", source->d->signature); return 0; } @@ -416,7 +421,6 @@ PyObject* signalInstanceGetItem(PyObject* self, PyObject* key) } PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s", sig, sigName); free(sig); - return 0; } @@ -460,9 +464,14 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args) if (match) { Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "disconnect")); - return PyObject_CallObject(pyMethod, tupleArgs); + PyObject* result = PyObject_CallObject(pyMethod, tupleArgs); + if (result == Py_True) + return result; + else + Py_DECREF(result); } + PyErr_Format(PyExc_RuntimeError, "Fail to disconnect signal %s.", source->d->signature); return 0; } @@ -674,7 +683,13 @@ bool connect(PyObject* source, const char* signal, PyObject* callback) Shiboken::AutoDecRef pySignature(PyString_FromString(signal)); Shiboken::AutoDecRef pyArgs(PyTuple_Pack(3, source, pySignature.object(), callback)); - return PyObject_CallObject(pyMethod, pyArgs); + PyObject* result = PyObject_CallObject(pyMethod, pyArgs); + if (result == Py_False) { + PyErr_Format(PyExc_RuntimeError, "Fail to connect signal %s, to python callable object.", signal); + Py_DECREF(result); + result = 0; + } + return result; } PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList& methodList) From 24838672f0b8256a4fddcb04cf30d7a4d53b7d52 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 26 Aug 2011 19:12:52 -0300 Subject: [PATCH 017/152] Created unit test for bug #987. Reviewed by: Hugo Parente Luciano Wolf --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_987.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/QtCore/bug_987.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index aa646d7..2438b09 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -21,6 +21,7 @@ PYSIDE_TEST(bug_927.py) PYSIDE_TEST(bug_931.py) PYSIDE_TEST(bug_938.py) PYSIDE_TEST(bug_953.py) +PYSIDE_TEST(bug_987.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(classinfo_test.py) PYSIDE_TEST(child_event_test.py) diff --git a/tests/QtCore/bug_987.py b/tests/QtCore/bug_987.py new file mode 100644 index 0000000..9609a45 --- /dev/null +++ b/tests/QtCore/bug_987.py @@ -0,0 +1,15 @@ +from PySide.QtCore import QObject + +import unittest + + +class TestBug987(unittest.TestCase): + def callback(self): + pass + + def testInvalidDisconnection(self): + o = QObject() + self.assertRaises(RuntimeError, o.destroyed.disconnect, self.callback) + +if __name__ == '__main__': + unittest.main() From 1c4ebcbe8a79c7b5c9a9db8164493926009831db Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 29 Aug 2011 15:02:27 -0300 Subject: [PATCH 018/152] Fixed gcc warning during QDate conversion compilation. --- PySide/QtCore/qdate_conversions.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PySide/QtCore/qdate_conversions.h b/PySide/QtCore/qdate_conversions.h index 7c45eec..586fc3c 100644 --- a/PySide/QtCore/qdate_conversions.h +++ b/PySide/QtCore/qdate_conversions.h @@ -1,3 +1,7 @@ +#define PySideDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI*) PyCObject_Import((char*)"datetime", \ + (char*)"datetime_CAPI") + namespace Shiboken { inline bool Converter::checkType(PyObject* pyObj) @@ -16,7 +20,7 @@ inline bool Converter::isConvertible(PyObject* pyObj) return true; if (!PyDateTimeAPI) - PyDateTime_IMPORT; + PySideDateTime_IMPORT; SbkObjectType* shiboType = reinterpret_cast(SbkType< ::QDate >()); return PyDate_Check(pyObj) || ObjectType::isExternalConvertible(shiboType, pyObj); @@ -25,7 +29,7 @@ inline bool Converter::isConvertible(PyObject* pyObj) inline QDate Converter::toCpp(PyObject* pyObj) { if (!PyDateTimeAPI) - PyDateTime_IMPORT; + PySideDateTime_IMPORT; if (pyObj == Py_None) { return QDate(); From 49ad2f9c1de0c8877f72a92ffab47d2895a48839 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 30 Aug 2011 11:19:20 -0300 Subject: [PATCH 019/152] Created unit test for repr function. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_991.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/QtGui/bug_991.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 9c9339d..044366d 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -72,6 +72,7 @@ PYSIDE_TEST(bug_921.py) PYSIDE_TEST(bug_941.py) PYSIDE_TEST(bug_964.py) PYSIDE_TEST(bug_972.py) +PYSIDE_TEST(bug_991.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(event_filter_test.py) diff --git a/tests/QtGui/bug_991.py b/tests/QtGui/bug_991.py new file mode 100644 index 0000000..55ff81d --- /dev/null +++ b/tests/QtGui/bug_991.py @@ -0,0 +1,15 @@ +import unittest +from PySide.QtCore import QObject +from PySide.QtGui import QPen, QBrush + +class TestBug991 (unittest.TestCase): + def testReprFunction(self): + reprPen = repr(QPen()) + self.assertTrue(reprPen.startswith(" Date: Tue, 30 Aug 2011 15:53:36 -0300 Subject: [PATCH 020/152] Optimize my dumb code that do stuff with a QByteArray without knowing if will use it. --- libpyside/pysidesignal.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libpyside/pysidesignal.cpp b/libpyside/pysidesignal.cpp index b4940d5..9b8cbc0 100644 --- a/libpyside/pysidesignal.cpp +++ b/libpyside/pysidesignal.cpp @@ -783,11 +783,12 @@ void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject) SignalSigMap signalsFound; for(int i = metaObject->methodOffset(), max = metaObject->methodCount(); i < max; ++i) { QMetaMethod method = metaObject->method(i); - QByteArray methodName(method.signature()); - methodName.chop(methodName.size() - methodName.indexOf('(')); - if (method.methodType() == QMetaMethod::Signal) + if (method.methodType() == QMetaMethod::Signal) { + QByteArray methodName(method.signature()); + methodName.chop(methodName.size() - methodName.indexOf('(')); signalsFound[methodName] << join(method.parameterTypes(), ","); + } } SignalSigMap::Iterator it = signalsFound.begin(); From a7e4ddb8cae99fc17ab5e15a0a32c019c3f3a494 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 30 Aug 2011 16:02:43 -0300 Subject: [PATCH 021/152] Fix bug 988 - "The type supplied with currentChanged signal in QTabWidget has changed in 1.0.6" Reviewer: Luciano Wolf Marcelo Lira --- libpyside/pysidesignal.cpp | 9 ++++++++- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_988.py | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/QtGui/bug_988.py diff --git a/libpyside/pysidesignal.cpp b/libpyside/pysidesignal.cpp index 9b8cbc0..3308035 100644 --- a/libpyside/pysidesignal.cpp +++ b/libpyside/pysidesignal.cpp @@ -777,6 +777,12 @@ static void _addSignalToWrapper(SbkObjectType* wrapperType, const char* signalNa PyDict_SetItemString(typeDict, signalName, reinterpret_cast(signal)); } +// This function is used by qStableSort to promote empty signatures +static bool compareSignals(const QByteArray& sig1, const QByteArray& sig2) +{ + return sig1.isEmpty(); +} + void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject) { typedef QHash > SignalSigMap; @@ -801,7 +807,8 @@ void registerSignals(SbkObjectType* pyObj, const QMetaObject* metaObject) self->initialized = 0; self->homonymousMethod = 0; - qSort(it.value().begin(), it.value().end()); + // Empty signatures comes first! So they will be the default signal signature + qStableSort(it.value().begin(), it.value().end(), &compareSignals); SignalSigMap::mapped_type::const_iterator j = it.value().begin(); SignalSigMap::mapped_type::const_iterator endJ = it.value().end(); for (; j != endJ; ++j) diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 044366d..85e5988 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -72,6 +72,7 @@ PYSIDE_TEST(bug_921.py) PYSIDE_TEST(bug_941.py) PYSIDE_TEST(bug_964.py) PYSIDE_TEST(bug_972.py) +PYSIDE_TEST(bug_988.py) PYSIDE_TEST(bug_991.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtGui/bug_988.py b/tests/QtGui/bug_988.py new file mode 100644 index 0000000..12e2155 --- /dev/null +++ b/tests/QtGui/bug_988.py @@ -0,0 +1,18 @@ +import unittest +from PySide.QtGui import * + +class TestBug988 (unittest.TestCase): + + def callback(self, arg): + self.arg = arg + + def testIt(self): + self.arg = None + app = QApplication([]) + obj = QTabWidget() + obj.currentChanged.connect(self.callback) + obj.currentChanged.emit(5) + self.assertEqual(self.arg, 5) + +if __name__ == "__main__": + unittest.main() From 6e6e7f528d59b27349ba1fd33f27d743592f8959 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 30 Aug 2011 18:14:42 -0300 Subject: [PATCH 022/152] Created test for bug #979. --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_979.py | 9 +++++++++ tests/QtGui/import_test.py | 2 ++ 3 files changed, 12 insertions(+) create mode 100644 tests/QtGui/bug_979.py create mode 100644 tests/QtGui/import_test.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 85e5988..9fb62b4 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -72,6 +72,7 @@ PYSIDE_TEST(bug_921.py) PYSIDE_TEST(bug_941.py) PYSIDE_TEST(bug_964.py) PYSIDE_TEST(bug_972.py) +PYSIDE_TEST(bug_979.py) PYSIDE_TEST(bug_988.py) PYSIDE_TEST(bug_991.py) PYSIDE_TEST(customproxywidget_test.py) diff --git a/tests/QtGui/bug_979.py b/tests/QtGui/bug_979.py new file mode 100644 index 0000000..b780d35 --- /dev/null +++ b/tests/QtGui/bug_979.py @@ -0,0 +1,9 @@ +from PySide.QtGui import QDialog +from import_test import PysideImportTest2 + +class PysideImportTest1(QDialog, PysideImportTest2): + pass + +if __name__ == '__main__': + quit() + diff --git a/tests/QtGui/import_test.py b/tests/QtGui/import_test.py new file mode 100644 index 0000000..0b60241 --- /dev/null +++ b/tests/QtGui/import_test.py @@ -0,0 +1,2 @@ +class PysideImportTest2(object): + pass From 57b291fe66dde855ad2d6782eef6034ec914d6c1 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 31 Aug 2011 11:31:03 -0300 Subject: [PATCH 023/152] Unit test for bug 967, a side effect of bug 988. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Marcelo Lira Renato Araújo --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_967.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/QtGui/bug_967.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 9fb62b4..ab5bd39 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -71,6 +71,7 @@ PYSIDE_TEST(bug_919.py) PYSIDE_TEST(bug_921.py) PYSIDE_TEST(bug_941.py) PYSIDE_TEST(bug_964.py) +PYSIDE_TEST(bug_967.py) PYSIDE_TEST(bug_972.py) PYSIDE_TEST(bug_979.py) PYSIDE_TEST(bug_988.py) diff --git a/tests/QtGui/bug_967.py b/tests/QtGui/bug_967.py new file mode 100644 index 0000000..41faf2f --- /dev/null +++ b/tests/QtGui/bug_967.py @@ -0,0 +1,18 @@ +import unittest +from PySide.QtGui import * + +class TestBug967 (unittest.TestCase): + + def callback(self, arg): + self.arg = arg + + def testIt(self): + self.arg = None + app = QApplication([]) + obj = QComboBox() + obj.currentIndexChanged.connect(self.callback) + obj.currentIndexChanged.emit(5) + self.assertEqual(self.arg, 5) + +if __name__ == "__main__": + unittest.main() From 2487a080624a74a0db9dc068174d23453d18c114 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 31 Aug 2011 16:57:28 -0300 Subject: [PATCH 024/152] Fixed QColor reduce function. Fixes bug #989. Reviewer: Luciano Wolf Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index c35a759..e772cd9 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1165,42 +1165,43 @@ + + + Shiboken::AutoDecRef func(PyObject_GetAttr(%PYSELF, PyTuple_GET_ITEM(%1, 0))); + PyObject* args = PyTuple_GET_ITEM(%1, 1); + %PYARG_0 = PyObject_Call(func, args, NULL); + + - PyObject *createFunction = 0; - switch(%CPPSELF.spec()) { case QColor::Rgb: { qreal r, g, b, a; - createFunction = PyObject_GetAttrString(%PYSELF, "fromRgbF"); %CPPSELF.getRgbF(&r, &g, &b, &a); - %PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, r, g, b, a); + %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setRgbF", (float)r, (float)g, (float)b, (float)a); break; } case QColor::Hsv: { qreal h, s, v, a; - createFunction = PyObject_GetAttrString(%PYSELF, "fromHsvF"); %CPPSELF.getHsvF(&h, &s, &v, &a); - %PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, h, s, v, a); + %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHsvF", (float)h, (float)s, (float)v, (float)a); break; } case QColor::Cmyk: { qreal c, m, y, k, a; - createFunction = PyObject_GetAttrString(%PYSELF, "fromCmykF"); %CPPSELF.getCmykF(&c, &m, &y, &k, &a); - %PYARG_0 = Py_BuildValue("(N(fffff))", createFunction, c, m, y, k, a); + %PYARG_0 = Py_BuildValue("(ON(s(fffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setCmykF", (float)c, (float)m, (float)y, (float)k, (float)a); break; } #if QT_VERSION >= 0x040600 case QColor::Hsl: { qreal h, s, l, a; - createFunction = PyObject_GetAttrString(%PYSELF, "fromHslF"); %CPPSELF.getHslF(&h, &s, &l, &a); - %PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, h, s, l, a); + %PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHslF", (float)h, (float)s, (float)l, (float)a); break; } #endif From 700a4cf95ca3723062dc6affc89a2bd6a5b66dee Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 31 Aug 2011 16:58:39 -0300 Subject: [PATCH 025/152] Created unit test for QColor reduce function. Reviewer: Luciano Wolf Marcelo Lira --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/qcolor_reduce_test.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/QtGui/qcolor_reduce_test.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index ab5bd39..d4ea190 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -94,6 +94,7 @@ PYSIDE_TEST(qapplication_singleton_test.py) PYSIDE_TEST(qapp_test.py) PYSIDE_TEST(qbrush_test.py) PYSIDE_TEST(qcolor_test.py) +PYSIDE_TEST(qcolor_reduce_test.py) PYSIDE_TEST(qcursor_test.py) PYSIDE_TEST(qaction_test.py) PYSIDE_TEST(qdatastream_gui_operators_test.py) diff --git a/tests/QtGui/qcolor_reduce_test.py b/tests/QtGui/qcolor_reduce_test.py new file mode 100644 index 0000000..c846ae3 --- /dev/null +++ b/tests/QtGui/qcolor_reduce_test.py @@ -0,0 +1,31 @@ +import unittest +import pickle +from PySide.QtGui import QColor + +class TestQColor (unittest.TestCase): + def reduceColor(self, c): + p = pickle.dumps(c) + c2 = pickle.loads(p) + self.assertEqual(c.spec(), c2.spec()) + self.assertEqual(c, c2) + + def testReduceEmpty(self): + self.reduceColor(QColor()) + + def testReduceString(self): + self.reduceColor(QColor('gray')) + + def testReduceRGB(self): + self.reduceColor(QColor.fromRgbF(0.1, 0.2, 0.3, 0.4)) + + def testReduceCMYK(self): + self.reduceColor(QColor.fromCmykF(0.1, 0.2, 0.3, 0.4, 0.5)) + + def testReduceHsl(self): + self.reduceColor(QColor.fromHslF(0.1, 0.2, 0.3, 0.4)) + + def testReduceHsv(self): + self.reduceColor(QColor.fromHsvF(0.1, 0.2, 0.3, 0.4)) + +if __name__ == "__main__": + unittest.main() From 08d202e824ffc6221bd426084ac169324808e9da Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 31 Aug 2011 15:24:40 -0300 Subject: [PATCH 026/152] Fix bug 966 - "QX11Info.display() missing" --- PySide/QtGui/typesystem_gui_x11.xml | 19 +++++++++++++++---- tests/QtGui/CMakeLists.txt | 2 +- tests/QtGui/x11_symbols_test.py | 17 ++++++++++++----- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_x11.xml b/PySide/QtGui/typesystem_gui_x11.xml index 96bfb24..54d8882 100644 --- a/PySide/QtGui/typesystem_gui_x11.xml +++ b/PySide/QtGui/typesystem_gui_x11.xml @@ -23,10 +23,21 @@ - - - - + + + %PYARG_0 = PyLong_FromVoidPtr(%TYPE::%FUNCTION_NAME()); + + + + + %PYARG_0 = PyLong_FromVoidPtr(%CPPSELF.%FUNCTION_NAME()); + + + + + %PYARG_0 = PyLong_FromVoidPtr(%CPPSELF.%FUNCTION_NAME()); + + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index d4ea190..75f576f 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -160,6 +160,6 @@ PYSIDE_TEST(virtual_pure_override_test.py) PYSIDE_TEST(wrong_return_test.py) -if(X11) +if(Q_WS_X11) PYSIDE_TEST(x11_symbols_test.py) endif() diff --git a/tests/QtGui/x11_symbols_test.py b/tests/QtGui/x11_symbols_test.py index 29cce15..6a38eed 100644 --- a/tests/QtGui/x11_symbols_test.py +++ b/tests/QtGui/x11_symbols_test.py @@ -3,15 +3,22 @@ import unittest -from PySide.QtGui import QPixmap +from PySide.QtGui import * class X11Test(unittest.TestCase): def test(self): - self.assert_('handle' in dir(QPixmap)) - self.assert_('x11Info' in dir(QPixmap)) - self.assert_('x11PictureHandle' in dir(QPixmap)) - self.assert_('x11SetDefaultScreen' in dir(QPixmap)) + qpixmapFuncs = dir(QPixmap) + self.assert_('handle' in qpixmapFuncs) + self.assert_('x11Info' in qpixmapFuncs) + self.assert_('x11PictureHandle' in qpixmapFuncs) + self.assert_('x11SetDefaultScreen' in qpixmapFuncs) + + def testX11Functions(self): + qx11infoFuncs = dir(QX11Info) + self.assert_('display' in qx11infoFuncs) + self.assert_('appVisual' in qx11infoFuncs) + self.assert_('visual' in qx11infoFuncs) if __name__ == '__main__': unittest.main() From 9afe76796d365978ee4be04e195cc5ec43758868 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 31 Aug 2011 17:43:45 -0300 Subject: [PATCH 027/152] Fix bug 944 - "QIODevice.readData must use qmemcpy instead of qstrncpy" Reviewer: Luciano Wolf Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 2 +- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_994.py | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/QtCore/bug_994.py diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 71c9572..8271a1b 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2043,7 +2043,7 @@ %out = -1; } else { %out = PyString_GET_SIZE((PyObject*)%PYARG_0); - qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1); + memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out); } diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 2438b09..398746d 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -22,6 +22,7 @@ PYSIDE_TEST(bug_931.py) PYSIDE_TEST(bug_938.py) PYSIDE_TEST(bug_953.py) PYSIDE_TEST(bug_987.py) +PYSIDE_TEST(bug_994.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(classinfo_test.py) PYSIDE_TEST(child_event_test.py) diff --git a/tests/QtCore/bug_994.py b/tests/QtCore/bug_994.py new file mode 100644 index 0000000..74e352c --- /dev/null +++ b/tests/QtCore/bug_994.py @@ -0,0 +1,20 @@ +import unittest +from PySide.QtCore import * + +class MyIODevice (QIODevice): + def readData(self, amount): + return "\0a" * (amount/2) + + def atEnd(self): + return False + +class TestBug944 (unittest.TestCase): + + def testIt(self): + device = MyIODevice() + device.open(QIODevice.ReadOnly) + s = QTextStream(device) + self.assertEqual(s.read(4), "\0a\0a") + +if __name__ == "__main__": + unittest.main() From 7ee30db078e15913c0a50016deb33113f06aa5dd Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Thu, 1 Sep 2011 14:09:54 -0300 Subject: [PATCH 028/152] Add extra test on QByteArray explicit conversion Reviewer: Luciano Wolf Reviewer: Marcelo Lira --- tests/QtCore/qbytearray_test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/QtCore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py index 38ed2ab..b12f7f9 100644 --- a/tests/QtCore/qbytearray_test.py +++ b/tests/QtCore/qbytearray_test.py @@ -154,6 +154,13 @@ class QByteArrayBug720(unittest.TestCase): self.assertEqual(str(ba), "32\"1\x00123") self.assertEqual(repr(ba), "PySide.QtCore.QByteArray('32\"1\\x00123')") +class QByteArrayImplicitConvert(unittest.TestCase): + def testString(self): + # No implicit conversions from QByteArray to python string + ba = QByteArray("object name") + obj = QObject() + self.assertRaises(TypeError, obj.setObjectName, ba) + if __name__ == '__main__': unittest.main() From 8e43e10f4e901851069be5557ec0f3dad72dc954 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 1 Sep 2011 11:38:14 -0300 Subject: [PATCH 029/152] Fix other QIODevice read functions stopping at null bytes. --- PySide/QtCore/typesystem_core.xml | 2 +- tests/QtCore/bug_994.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 8271a1b..f450a29 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2066,7 +2066,7 @@ %out = -1; } else { %out = PyString_GET_SIZE((PyObject*)%PYARG_0); - qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1); + memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out); } diff --git a/tests/QtCore/bug_994.py b/tests/QtCore/bug_994.py index 74e352c..5f12a96 100644 --- a/tests/QtCore/bug_994.py +++ b/tests/QtCore/bug_994.py @@ -5,6 +5,9 @@ class MyIODevice (QIODevice): def readData(self, amount): return "\0a" * (amount/2) + def readLineData(self, maxSize): + return "\0b" * 4 + def atEnd(self): return False @@ -15,6 +18,7 @@ class TestBug944 (unittest.TestCase): device.open(QIODevice.ReadOnly) s = QTextStream(device) self.assertEqual(s.read(4), "\0a\0a") + self.assertEqual(device.readLine(), "\0b\0b\0b\0b") if __name__ == "__main__": unittest.main() From e9de49255b6b4a1749b729a02e9fe643c66a042f Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 1 Sep 2011 14:26:33 -0300 Subject: [PATCH 030/152] Fix QAbstractFileEngine read and readLine methods to accept data with null bytes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Marcelo Lira Renato Araújo --- PySide/QtCore/typesystem_core.xml | 4 ++-- tests/QtCore/bug_723.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index f450a29..6b8205e 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2363,7 +2363,7 @@ %out = -1; } else { %out = PyString_GET_SIZE((PyObject*)%PYARG_0); - qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1); + memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out); } @@ -2386,7 +2386,7 @@ %out = -1; } else { %out = PyString_GET_SIZE((PyObject*)%PYARG_0); - qstrncpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out + 1); + memcpy(%1, PyString_AS_STRING((PyObject*)%PYARG_0), %out); } diff --git a/tests/QtCore/bug_723.py b/tests/QtCore/bug_723.py index 68ebeab..319c04b 100644 --- a/tests/QtCore/bug_723.py +++ b/tests/QtCore/bug_723.py @@ -5,7 +5,7 @@ class MyFileEngine (QAbstractFileEngine): def __init__(self): QAbstractFileEngine.__init__(self) - self.contents = "Foo bar for the win!" + self.contents = "Foo \0bar for the win!" self.pos = 0 def open(self, mode): @@ -27,7 +27,6 @@ class MyFileEngine (QAbstractFileEngine): class MyFileEngineHandler (QAbstractFileEngineHandler): def create(self, fileName): - print "hey ho: ", fileName if fileName.startswith("foo:/"): return MyFileEngine() return None @@ -42,7 +41,7 @@ class TestBug723 (unittest.TestCase): assert(f.open(QFile.ReadOnly | QFile.Text)) contents = f.readAll() - self.assertEqual(contents, "Foo bar for the win!") + self.assertEqual(contents, "Foo \0bar for the win!") f.close() From b55ea7fd5ebf58cb6d141c0091f7d47ef761a2ad Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 1 Sep 2011 17:33:20 -0300 Subject: [PATCH 031/152] Fix bug 981 - "QSettings docs should empathize the behavior changes of value() on different platforms" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Marcelo Lira Luciano Wolf Renato Araújo --- PySide/QtCore/typesystem_core.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 6b8205e..bb67540 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2544,6 +2544,11 @@ + + + .. warning:: QSettings.value can return different types (QVariant types) depending on the platform it's running on, so the safest way to use it is always casting the result to the desired type, e.g.: int(settings.value("myKey")) + + From d29d9ad5ac54d19aa456d5d8b189766162733445 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 31 Aug 2011 15:00:55 -0300 Subject: [PATCH 032/152] Changed QStringList from container to primitive type. QStringList inherits from QList, and it isn't a reusable container itself, such as QList. Reviewed by Hugo Parente Reviewed by Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index bb67540..67969cd 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -139,10 +139,10 @@ - + - + From bfcc30ab86727b65c0ab89118e35a45a1e683470 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 6 Sep 2011 11:04:18 -0300 Subject: [PATCH 033/152] Fixed problems in function that return None, and was not verified. Some functions with inject code didnot verify the result value before convert to Shiboken types. Fixes bug #998. Reviewed by: Hugo Parente Lauro Neto --- PySide/typesystem_templates.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index c2c0474..a35602f 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -246,10 +246,12 @@ %END_ALLOW_THREADS %PYARG_0 = Shiboken::makeTuple(retval_, %5); - From 2a634aea05487732fe06c2935dc2893f75af79ed Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 12 Dec 2011 17:46:37 -0300 Subject: [PATCH 138/152] Updated the custom widget plugin to use the new converters. --- plugins/CMakeLists.txt | 2 +- plugins/customwidget.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index b17dbc2..a65a421 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -5,7 +5,7 @@ set(ui_plugin_src customwidget.cpp ) -set (ui_plugin_moc +set(ui_plugin_moc customwidget.h customwidgets.h ) diff --git a/plugins/customwidget.cpp b/plugins/customwidget.cpp index fb849f2..d573ef4 100644 --- a/plugins/customwidget.cpp +++ b/plugins/customwidget.cpp @@ -95,11 +95,12 @@ QWidget* PyCustomWidget::createWidget(QWidget* parent) bool unkowParent = false; if (parent) { pyParent = reinterpret_cast(Shiboken::BindingManager::instance().retrieveWrapper(parent)); - if (!pyParent) { - pyParent = Shiboken::Converter::toPython(parent); - unkowParent = true; - } else { + if (pyParent) { Py_INCREF(pyParent); + } else { + static Shiboken::Conversions::SpecificConverter converter("QWidget*"); + pyParent = converter.toPython(&parent); + unkowParent = true; } } else { Py_INCREF(Py_None); @@ -129,4 +130,3 @@ void PyCustomWidget::initialize(QDesignerFormEditorInterface* core) { m_data->initialized = true; } - From e76b2b76f51ab643d6e97842ac3d3adc50b6a851 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 12 Dec 2011 20:02:38 -0300 Subject: [PATCH 139/152] Added type system entries to the primitive types used by QtOpenGL. --- PySide/QtOpenGL/typesystem_opengl.xml | 39 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/PySide/QtOpenGL/typesystem_opengl.xml b/PySide/QtOpenGL/typesystem_opengl.xml index 4c2604a..60a2d18 100644 --- a/PySide/QtOpenGL/typesystem_opengl.xml +++ b/PySide/QtOpenGL/typesystem_opengl.xml @@ -21,6 +21,21 @@ + + + + + + + + + + + + + + + @@ -191,7 +206,7 @@ - + @@ -207,7 +222,7 @@ - + @@ -415,7 +430,7 @@ - + @@ -431,7 +446,7 @@ - + @@ -640,19 +655,19 @@ - - - - + + + + - - - - + + + + From c78b4686a1f98273cf4e730efae32fa7f93ebebd Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 12 Dec 2011 19:10:07 -0200 Subject: [PATCH 140/152] Add GC support to PySide Property type. This fixes GC errors when running PySide on a Python debug env. Reviewer: Marcelo Lira --- libpyside/pysideproperty.cpp | 68 ++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/libpyside/pysideproperty.cpp b/libpyside/pysideproperty.cpp index e5ae5d5..1e1cf29 100644 --- a/libpyside/pysideproperty.cpp +++ b/libpyside/pysideproperty.cpp @@ -38,12 +38,14 @@ extern "C" static PyObject* qpropertyTpNew(PyTypeObject* subtype, PyObject* args, PyObject* kwds); static int qpropertyTpInit(PyObject*, PyObject*, PyObject*); -static void qpropertyFree(void*); +static void qpropertyDeAlloc(PyObject* self); //methods static PyObject* qPropertyCall(PyObject*, PyObject*, PyObject*); static PyObject* qPropertySetter(PyObject*, PyObject*); static PyObject* qPropertyGetter(PyObject*, PyObject*); +static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg); +static int qpropertyClear(PyObject* self); static PyMethodDef PySidePropertyMethods[] = { {"setter", (PyCFunction)qPropertySetter, METH_O}, @@ -58,7 +60,7 @@ PyTypeObject PySidePropertyType = { QPROPERTY_CLASS_NAME, /*tp_name*/ sizeof(PySideProperty), /*tp_basicsize*/ 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ + qpropertyDeAlloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -73,10 +75,10 @@ PyTypeObject PySidePropertyType = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc */ - 0, /*tp_traverse */ - 0, /*tp_clear */ + qpropertyTraverse, /*tp_traverse */ + qpropertyClear, /*tp_clear */ 0, /*tp_richcompare */ 0, /*tp_weaklistoffset */ 0, /*tp_iter */ @@ -92,7 +94,7 @@ PyTypeObject PySidePropertyType = { qpropertyTpInit, /*tp_init */ 0, /*tp_alloc */ qpropertyTpNew, /*tp_new */ - qpropertyFree, /*tp_free */ + 0, /*tp_free */ 0, /*tp_is_gc */ 0, /*tp_bases */ 0, /*tp_mro */ @@ -208,23 +210,10 @@ int qpropertyTpInit(PyObject* self, PyObject* args, PyObject* kwds) } } -void qpropertyFree(void *self) +void qpropertyDeAlloc(PyObject* self) { - PyObject *pySelf = reinterpret_cast(self); - PySideProperty *data = reinterpret_cast(self); - PySidePropertyPrivate* pData = data->d; - - Py_XDECREF(pData->fget); - Py_XDECREF(pData->fset); - Py_XDECREF(pData->freset); - Py_XDECREF(pData->fdel); - Py_XDECREF(pData->notify); - - free(pData->typeName); - free(pData->doc); - free(pData->notifySignature); - delete data->d; - pySelf->ob_type->tp_base->tp_free(self); + qpropertyClear(self); + Py_TYPE(self)->tp_free(self); } PyObject* qPropertyCall(PyObject* self, PyObject* args, PyObject* kw) @@ -279,6 +268,41 @@ PyObject* qPropertyGetter(PyObject* self, PyObject* callback) } } +static int qpropertyTraverse(PyObject* self, visitproc visit, void* arg) +{ + PySidePropertyPrivate* data = reinterpret_cast(self)->d; + if (!data) + return 0; + + Py_VISIT(data->fget); + Py_VISIT(data->fset); + Py_VISIT(data->freset); + Py_VISIT(data->fdel); + Py_VISIT(data->notify); + return 0; +} + +static int qpropertyClear(PyObject* self) +{ + PySidePropertyPrivate* data = reinterpret_cast(self)->d; + if (!data) + return 0; + + Py_CLEAR(data->fget); + Py_CLEAR(data->fset); + Py_CLEAR(data->freset); + Py_CLEAR(data->fdel); + Py_CLEAR(data->notify); + + + free(data->typeName); + free(data->doc); + free(data->notifySignature); + delete data; + reinterpret_cast(self)->d = 0; + return 0; +} + } // extern "C" namespace { From 7b8d2925dd61e2cb1edc78bd10cdda2e8ef19bf2 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 13 Dec 2011 16:58:30 -0200 Subject: [PATCH 141/152] Small code style changes. --- libpyside/pysideqflags.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libpyside/pysideqflags.cpp b/libpyside/pysideqflags.cpp index 4fe24b8..39f8b04 100644 --- a/libpyside/pysideqflags.cpp +++ b/libpyside/pysideqflags.cpp @@ -39,7 +39,7 @@ extern "C" { #define PYSIDE_QFLAGS(X) reinterpret_cast(X) - PyObject* PySideQFlagsNew(PyTypeObject *type, PyObject *args, PyObject *kwds) + PyObject* PySideQFlagsNew(PyTypeObject* type, PyObject* args, PyObject* kwds) { long val = 0; if (PyTuple_GET_SIZE(args)) { @@ -61,13 +61,11 @@ extern "C" { static long getNumberValue(PyObject* v) { - PyObject* number = PyNumber_Long(v); - long result = PyLong_AsLong(number); - Py_XDECREF(number); - return result; + Shiboken::AutoDecRef number(PyNumber_Long(v)); + return PyLong_AsLong(number); } - PyObject* PySideQFlagsRichCompare(PyObject *self, PyObject *other, int op) + PyObject* PySideQFlagsRichCompare(PyObject* self, PyObject* other, int op) { int result = 0; if (!PyNumber_Check(other)) { From 65d8f9fcef98f8a80015cc5e0b7526224332e7ec Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 14 Dec 2011 14:14:18 -0300 Subject: [PATCH 142/152] Fixes the QSettings related QVariant's save/load bug. --- libpyside/signalmanager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 4bcfae5..81ce14d 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -250,6 +250,8 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate) // Register PyObject type to use in queued signal and slot connections qRegisterMetaType(PYTHON_TYPE); qRegisterMetaTypeStreamOperators(PYTHON_TYPE); + qRegisterMetaTypeStreamOperators("PyObjectWrapper"); + qRegisterMetaTypeStreamOperators("PySide::PyObjectWrapper"); SbkConverter* converter = Shiboken::Conversions::createConverter(&PyBaseObject_Type, 0); Shiboken::Conversions::setCppPointerToPythonFunction(converter, PyObject_PTR_CppToPython_PyObject); From 8ddbd3167bba33820b19de36c2dbac83e9e8f55d Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 15 Dec 2011 14:47:39 -0300 Subject: [PATCH 143/152] The temporary file used in the test for bug #829 must not be deleted by the test. This fixes the test in win32 platforms. --- tests/QtCore/bug_829.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/QtCore/bug_829.py b/tests/QtCore/bug_829.py index da527ad..945d8df 100644 --- a/tests/QtCore/bug_829.py +++ b/tests/QtCore/bug_829.py @@ -3,12 +3,11 @@ import unittest from PySide.QtCore import QSettings -from helper import adjust_filename import tempfile class QVariantConversions(unittest.TestCase): def testDictionary(self): - confFile = tempfile.NamedTemporaryFile() + confFile = tempfile.NamedTemporaryFile(delete=False) s = QSettings(confFile.name, QSettings.IniFormat) # Save value s.setValue('x', {1: 'a'}) From 481ba5aa3ef94b417211fd25f07f30575b5afa68 Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Fri, 16 Dec 2011 18:10:45 -0300 Subject: [PATCH 144/152] Fix BUG #1084 - "Crash (segfault) when writing unicode string on socket" See http://bugs.pyside.org/show_bug.cgi?id=1084. Signed-off-by: Paulo Alcantara Reviewed-by: Trust me --- PySide/QtCore/typesystem_core_common.xml | 21 ++++++++------------- tests/QtNetwork/CMakeLists.txt | 1 + tests/QtNetwork/bug_1084.py | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 tests/QtNetwork/bug_1084.py diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml index aa39e95..a2e1deb 100644 --- a/PySide/QtCore/typesystem_core_common.xml +++ b/PySide/QtCore/typesystem_core_common.xml @@ -2666,20 +2666,15 @@ - + - + - + - - - - %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%1, Shiboken::String::len(%PYARG_1)); - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); - - - + + + @@ -2688,7 +2683,7 @@ - + QByteArray ba; ba.resize(%2); @@ -2712,7 +2707,7 @@ - + QByteArray ba; ba.resize(%2); diff --git a/tests/QtNetwork/CMakeLists.txt b/tests/QtNetwork/CMakeLists.txt index 3077155..7476f91 100644 --- a/tests/QtNetwork/CMakeLists.txt +++ b/tests/QtNetwork/CMakeLists.txt @@ -1,4 +1,5 @@ PYSIDE_TEST(bug_446.py) +PYSIDE_TEST(bug_1084.py) PYSIDE_TEST(basic_auth_test.py) PYSIDE_TEST(accessManager_test.py) PYSIDE_TEST(http_test.py) diff --git a/tests/QtNetwork/bug_1084.py b/tests/QtNetwork/bug_1084.py new file mode 100644 index 0000000..9d8471c --- /dev/null +++ b/tests/QtNetwork/bug_1084.py @@ -0,0 +1,16 @@ +''' unit test for BUG #1084 ''' + +import unittest +from PySide import QtNetwork +import py3kcompat as py3k + +class QTcpSocketTestCase(unittest.TestCase): + def setUp(self): + self.sock = QtNetwork.QTcpSocket() + self.sock.connectToHost('127.0.0.1', 25) + + def testIt(self): + self.sock.write(py3k.unicode_('quit')) + +if __name__ == "__main__": + unittest.main() From b2b14fe9b70cb233b003425328ef1f4d8749c744 Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Wed, 21 Dec 2011 14:57:32 -0300 Subject: [PATCH 145/152] Fix BUG #1091 - "PixmapFragment and drawPixmapFragments are not bound" See http://bugs.pyside.org/show_bug.cgi?id=1091. Also minor coding style fixes in QtGui's typesystem. Signed-off-by: Paulo Alcantara Reviewed-by: Marcelo Lira --- PySide/QtGui/CMakeLists.txt | 10 +- PySide/QtGui/typesystem_gui_common.xml | 149 +++++++++++++------------ tests/QtGui/CMakeLists.txt | 3 + tests/QtGui/bug_1091.py | 12 ++ 4 files changed, 100 insertions(+), 74 deletions(-) create mode 100644 tests/QtGui/bug_1091.py diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index 6023a32..7625634 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -15,7 +15,6 @@ if(ENABLE_X11) endif() endif() - if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) set(QtGui_46_SRC "") else() @@ -60,6 +59,14 @@ else() ) endif () +if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 7) + set(QtGui_47_SRC "") +else() + set(QtGui_47_SRC + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpainter_pixmapfragment_wrapper.cpp + ) +endif() + set(QtGui_OPTIONAL_SRC ) set(QtGui_DROPPED_ENTRIES ) check_qt_class(QtGui QAbstractPageSetupDialog QtGui_OPTIONAL_SRC QtGui_DROPPED_ENTRIES) @@ -398,6 +405,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qworkspace_wrapper.cpp ${SPECIFIC_OS_FILES} ${QPYTEXTOBJECT_MOC} ${QtGui_46_SRC} +${QtGui_47_SRC} ${QtGui_OPTIONAL_SRC} ) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index e9058b5..552636a 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3470,7 +3470,7 @@ - + @@ -3479,7 +3479,7 @@ - + @@ -3488,7 +3488,7 @@ - + @@ -3497,7 +3497,7 @@ - + @@ -3506,7 +3506,7 @@ - + @@ -3604,24 +3604,24 @@ - + - + - + - + @@ -3632,38 +3632,38 @@ - + - + - + - + - + - + - + @@ -3759,7 +3759,7 @@ - + @@ -3821,17 +3821,17 @@ - + - + - + @@ -3868,17 +3868,17 @@ - + - + - + @@ -3893,17 +3893,17 @@ - + - + - + @@ -3913,12 +3913,12 @@ - + - + @@ -3994,12 +3994,12 @@ - + - + @@ -4247,7 +4247,7 @@ - + @@ -4529,7 +4529,7 @@ - + @@ -4540,7 +4540,7 @@ - + @@ -4555,7 +4555,7 @@ - + @@ -4731,29 +4731,29 @@ - + - + - + - + - + // Clear parent from the old child QStandardItem* _i = %CPPSELF->item(%1, %2); @@ -4766,7 +4766,7 @@ - + // Clear parent from the old child QStandardItem* _i = %CPPSELF->item(%1); @@ -4779,13 +4779,13 @@ - + - + // Clear parent from the old child QStandardItem* _i = %CPPSELF->verticalHeaderItem(%1); @@ -4817,19 +4817,19 @@ - + - + - + @@ -5086,18 +5086,18 @@ - + - + - + @@ -5200,13 +5200,13 @@ - + - + @@ -5258,12 +5258,12 @@ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYARG_0, "connect", "OsO", %PYARG_0, SIGNAL(triggered()), %PYARG_2)); - + - + @@ -5425,9 +5425,12 @@ + + + - + - + - + - - - - - - + + + + + + - + - + - + %BEGIN_ALLOW_THREADS @@ -5475,7 +5478,7 @@ %END_ALLOW_THREADS - + %BEGIN_ALLOW_THREADS @@ -5483,13 +5486,13 @@ %END_ALLOW_THREADS - + - + @@ -5503,32 +5506,32 @@ - + - + - + - + - + - + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 1d95576..9bac913 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -164,6 +164,9 @@ PYSIDE_TEST(virtual_protected_inheritance_test.py) PYSIDE_TEST(virtual_pure_override_test.py) PYSIDE_TEST(wrong_return_test.py) +if (${QTVERSION} VERSION_GREATER 4.6.9) + PYSIDE_TEST(bug_1091.py) +endif() if(Q_WS_X11) PYSIDE_TEST(x11_symbols_test.py) diff --git a/tests/QtGui/bug_1091.py b/tests/QtGui/bug_1091.py new file mode 100644 index 0000000..b58d26f --- /dev/null +++ b/tests/QtGui/bug_1091.py @@ -0,0 +1,12 @@ +''' unit test for BUG #1091 ''' + +import unittest +from PySide import QtGui + +class QPainterTestCase(unittest.TestCase): + def testIt(self): + self.assertTrue("PixmapFragment" in dir(QtGui.QPainter)) + self.assertTrue("drawPixmapFragments" in dir(QtGui.QPainter)) + +if __name__ == "__main__": + unittest.main() From 98be0df6a55b45538d107421fd557fb77f8ab92b Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Wed, 21 Dec 2011 18:51:34 -0300 Subject: [PATCH 146/152] Fix BUG #1060 - "Subclassing of QUiLoader leads to "Internal C++ object already deleted" exception" See http://bugs.pyside.org/show_bug.cgi?id=1060. Signed-off-by: Paulo Alcantara Reviewed-by: Marcelo Lira --- PySide/QtUiTools/typesystem_uitools.xml | 11 ++++++----- tests/QtUiTools/CMakeLists.txt | 1 + tests/QtUiTools/bug_1060.py | 18 ++++++++++++++++++ tests/QtUiTools/bug_1060.ui | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 tests/QtUiTools/bug_1060.py create mode 100644 tests/QtUiTools/bug_1060.ui diff --git a/PySide/QtUiTools/typesystem_uitools.xml b/PySide/QtUiTools/typesystem_uitools.xml index c86ae44..08e98bd 100644 --- a/PySide/QtUiTools/typesystem_uitools.xml +++ b/PySide/QtUiTools/typesystem_uitools.xml @@ -70,27 +70,28 @@ %CPPSELF.addPluginPath(""); // force reload widgets - + - + - + - + - + + diff --git a/tests/QtUiTools/CMakeLists.txt b/tests/QtUiTools/CMakeLists.txt index eecf3df..68ed7f1 100644 --- a/tests/QtUiTools/CMakeLists.txt +++ b/tests/QtUiTools/CMakeLists.txt @@ -8,5 +8,6 @@ PYSIDE_TEST(bug_909.py) PYSIDE_TEST(bug_913.py) PYSIDE_TEST(bug_958.py) PYSIDE_TEST(bug_965.py) +PYSIDE_TEST(bug_1060.py) PYSIDE_TEST(uiloader_test.py) PYSIDE_TEST(ui_test.py) diff --git a/tests/QtUiTools/bug_1060.py b/tests/QtUiTools/bug_1060.py new file mode 100644 index 0000000..8b51501 --- /dev/null +++ b/tests/QtUiTools/bug_1060.py @@ -0,0 +1,18 @@ +''' unit test for BUG #1060 ''' + +from PySide.QtGui import QApplication +from PySide.QtUiTools import QUiLoader +from helper import adjust_filename + +class MyQUiLoader(QUiLoader): + def __init__(self): + super(MyQUiLoader, self).__init__() + + def createWidget(self, *args): + return super(MyQUiLoader, self).createWidget(*args) + +if __name__ == "__main__": + app = QApplication([]) + + ui = MyQUiLoader().load(adjust_filename("bug_1060.ui", __file__)) + ui.show() diff --git a/tests/QtUiTools/bug_1060.ui b/tests/QtUiTools/bug_1060.ui new file mode 100644 index 0000000..f4044a8 --- /dev/null +++ b/tests/QtUiTools/bug_1060.ui @@ -0,0 +1,19 @@ + + + Dialog + + + + 0 + 0 + 100 + 100 + + + + Dialog + + + + + From a8a07b77f8a781764eef62eb05bfeac864368cad Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 22 Dec 2011 21:49:08 -0300 Subject: [PATCH 147/152] Declares Python types using the new "" tag. Reviewed by Hugo Parente Reviewed by Paulo Alcantara --- PySide/QtCore/typesystem_core_common.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml index a2e1deb..8955612 100644 --- a/PySide/QtCore/typesystem_core_common.xml +++ b/PySide/QtCore/typesystem_core_common.xml @@ -21,6 +21,16 @@ + + + + + + + + + + From afc9a7e10b8fd1816b99628de5be3e84032fca03 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Fri, 30 Dec 2011 15:30:29 -0300 Subject: [PATCH 148/152] Version bump to 1.1.0. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f9db8..0151eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ project(pysidebindings) cmake_minimum_required(VERSION 2.6) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Macros/ ${CMAKE_MODULE_PATH}) -find_package(GeneratorRunner 0.6.15 REQUIRED) -find_package(Shiboken 1.0.10 REQUIRED) +find_package(GeneratorRunner 0.6.16 REQUIRED) +find_package(Shiboken 1.1.0 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) find_file(GL_H "gl.h" PATH_SUFFIXES "GL") include(FindQt4Extra) @@ -62,8 +62,8 @@ endif() set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "1") -set(BINDING_API_MINOR_VERSION "0") -set(BINDING_API_MICRO_VERSION "9") +set(BINDING_API_MINOR_VERSION "1") +set(BINDING_API_MICRO_VERSION "0") set(BINDING_API_RELEASE_LEVEL "final") # alpha, beta, rc, or final set(BINDING_API_SERIAL 1) # leave as 0 when release level is final set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide version" FORCE) From d30a8672c3db038886273d194f5bcdcb19cc29bd Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Fri, 30 Dec 2011 15:31:11 -0300 Subject: [PATCH 149/152] Version bump to 1.1.1. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0151eea..696b4e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ endif() set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "1") set(BINDING_API_MINOR_VERSION "1") -set(BINDING_API_MICRO_VERSION "0") +set(BINDING_API_MICRO_VERSION "1") set(BINDING_API_RELEASE_LEVEL "final") # alpha, beta, rc, or final set(BINDING_API_SERIAL 1) # leave as 0 when release level is final set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" CACHE STRING "PySide version" FORCE) From db6f1e3306e626b871d6ed1a971638d106648b51 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 13 Mar 2012 14:26:42 -0300 Subject: [PATCH 150/152] Fix PySide compilation. Change-Id: Ie7a30961232526af59cbc21dbf1b58ab9a4e3e7b Reviewed-by: Hugo Parente Lima --- CMakeLists.txt | 3 +-- cmake/Macros/PySideModules.cmake | 2 +- doc/CMakeLists.txt | 2 +- tests/pysidetest/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 696b4e3..a7ffbd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,7 @@ project(pysidebindings) cmake_minimum_required(VERSION 2.6) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Macros/ ${CMAKE_MODULE_PATH}) -find_package(GeneratorRunner 0.6.16 REQUIRED) -find_package(Shiboken 1.1.0 REQUIRED) +find_package(Shiboken 1.1.1 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) find_file(GL_H "gl.h" PATH_SUFFIXES "GL") include(FindQt4Extra) diff --git a/cmake/Macros/PySideModules.cmake b/cmake/Macros/PySideModules.cmake index 9eabd56..4877b12 100644 --- a/cmake/Macros/PySideModules.cmake +++ b/cmake/Macros/PySideModules.cmake @@ -20,7 +20,7 @@ macro(create_pyside_module module_name module_include_dir module_libraries modul endif() add_custom_command(OUTPUT ${${module_sources}} - COMMAND ${GENERATORRUNNER_BINARY} ${GENERATOR_EXTRA_FLAGS} + COMMAND ${SHIBOKEN_BINARY} ${GENERATOR_EXTRA_FLAGS} ${pyside_BINARY_DIR}/pyside_global.h --include-paths=${pyside_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR} --typesystem-paths=${pyside_SOURCE_DIR}${PATH_SEP}${${module_typesystem_path}} diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 61eeb09..967c289 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -23,7 +23,7 @@ configure_file("conf.py.in" "rst/conf.py" @ONLY) configure_file(typesystem_doc.xml.in typesystem_doc.xml @ONLY) add_custom_target("docrsts" - COMMAND ${GENERATORRUNNER_BINARY} --generator-set=qtdoc + COMMAND ${SHIBOKEN_BINARY} --generator-set=qtdoc ${pyside_BINARY_DIR}/pyside_global.h --include-paths="${QT_INCLUDE_DIR}${PATH_SEP}${pyside_SOURCE_DIR}" --api-version=${SUPPORTED_QT_VERSION} diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 01d61f7..78c6f95 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -34,7 +34,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp ) add_custom_command(OUTPUT ${testbinding_SRC} -COMMAND ${GENERATORRUNNER_BINARY} ${GENERATOR_EXTRA_FLAGS} +COMMAND ${SHIBOKEN_BINARY} ${GENERATOR_EXTRA_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/pysidetest_global.h --include-paths=${pyside_BINARY_DIR}${PATH_SEP}${CMAKE_CURRENT_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR}${PATH_SEP}${QT_QTCORE_INCLUDE_DIR}${PATH_SEP}${QT_QTGUI_INCLUDE_DIR} --typesystem-paths=${CMAKE_CURRENT_SOURCE_DIR}${PATH_SEP}${pyside_SOURCE_DIR}${PATH_SEP}${QtCore_SOURCE_DIR}${PATH_SEP}${QtCore_BINARY_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR} From fe8dc36f90fe64590f7f13843a076f8d2d61f378 Mon Sep 17 00:00:00 2001 From: Juhapekka Piiroinen Date: Tue, 6 Mar 2012 13:57:16 +0200 Subject: [PATCH 151/152] Fix bug PYSIDE-6 This should resolve the issue in PYSIDE-6 "Fix phonon VideoCaptureDevice detection to properly use phonon_ namespace". Changed if check in PySideModules.cmake. Change-Id: Ie30d6858a0fc6073560ec4cd09508504cbeb667d Reviewed-by: Hugo Parente Lima --- cmake/Macros/PySideModules.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Macros/PySideModules.cmake b/cmake/Macros/PySideModules.cmake index 4877b12..2fe6cd1 100644 --- a/cmake/Macros/PySideModules.cmake +++ b/cmake/Macros/PySideModules.cmake @@ -71,7 +71,7 @@ macro(check_qt_class module class optional_source_files dropped_entries) endif () string(TOLOWER ${class} _class) string(TOUPPER ${module} _module) - if (${namespace}) + if (_namespace) set(_cppfile ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module}/${_namespace}_${_class}_wrapper.cpp) else () set(_cppfile ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module}/${_class}_wrapper.cpp) From f011ce2cb9e2b93a748874de007232ec88cc8ac1 Mon Sep 17 00:00:00 2001 From: Juhapekka Piiroinen Date: Mon, 5 Mar 2012 07:59:41 +0200 Subject: [PATCH 152/152] Bug fix for PYSIDE-7 This should resolve the issue in PYSIDE-7 "QDateTime does not support the 6-argument format". Added function signature for 6-argument version and a testcase. Change-Id: I617eefab6a41939c37e2f1bf800857bc2d74b6ee Reviewed-by: Hugo Parente Lima --- PySide/QtCore/typesystem_core_common.xml | 7 +++++++ tests/QtCore/python_conversion.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml index 8955612..2e83131 100644 --- a/PySide/QtCore/typesystem_core_common.xml +++ b/PySide/QtCore/typesystem_core_common.xml @@ -1257,6 +1257,13 @@ %0 = new %TYPE(date, time, Qt::TimeSpec(%8)); + + + QDate date(%1, %2, %3); + QTime time(%4, %5, %6); + %0 = new %TYPE(date, time); + + diff --git a/tests/QtCore/python_conversion.py b/tests/QtCore/python_conversion.py index 2472dee..84845c0 100644 --- a/tests/QtCore/python_conversion.py +++ b/tests/QtCore/python_conversion.py @@ -43,5 +43,22 @@ class TestDateTimeConversions (unittest.TestCase): self.assertEqual(dateTime, other.toPython()) + def testQDateTime6arg(self): + dateTime = datetime.datetime(2010, 4, 23, 11, 14, 7) + other = QDateTime(dateTime) + + otherDate = other.date() + self.assertEqual(dateTime.year, otherDate.year()) + self.assertEqual(dateTime.month, otherDate.month()) + self.assertEqual(dateTime.day, otherDate.day()) + + otherTime = other.time() + self.assertEqual(dateTime.hour, otherTime.hour()) + self.assertEqual(dateTime.minute, otherTime.minute()) + self.assertEqual(dateTime.second, otherTime.second()) + self.assertEqual(dateTime.microsecond/1000, otherTime.msec()) + + self.assertEqual(dateTime, other.toPython()) + if __name__ == '__main__': unittest.main()