From ca1533509e52479e222710469d4eb2fd898f18b2 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 7 Jun 2010 10:08:47 -0300 Subject: [PATCH 0001/1129] Bump to version 0.3.3. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e7c708..4b26d1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ find_package(Qt4 4.5.0 REQUIRED) set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "0") set(BINDING_API_MINOR_VERSION "3") -set(BINDING_API_MICRO_VERSION "2") +set(BINDING_API_MICRO_VERSION "3") set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}") set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) From 471486732b03cbb42b884158604a59d5a18e8a35 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 7 Jun 2010 16:23:37 -0300 Subject: [PATCH 0002/1129] Removed an copy'n'paste error from the documentation of new style signals/slots. Reviewed by Hugo Parente Reviewed by Luciano Wolf --- doc/newsigslot.rst | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/doc/newsigslot.rst b/doc/newsigslot.rst index b73a6b9..15e9fca 100644 --- a/doc/newsigslot.rst +++ b/doc/newsigslot.rst @@ -30,16 +30,12 @@ New way: Signal() and Slot() The new-style uses a different syntax to create and to connect signals/slots. The previous example could be rewritten as: :: - + ... def someFunc(): print "someFunc has been called!" - ... - - clicked = QtCore.Signal() - button = QtGui.QPushButton("Call someFunc") button.clicked.connect(someFunc) From ab918abc1e103e0ca86939f7d057e8a44ac8a4ef Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 7 Jun 2010 14:43:45 -0300 Subject: [PATCH 0003/1129] Created new unittest model. Separete unittest for module. Only run unittest for compiled modules. Reviewer: Marcelo Lira , Luciano Wolf --- tests/CMakeLists.txt | 60 ++++++++++----- tests/QtCore/CMakeLists.txt | 71 ++++++++++++++++++ .../blocking_signals_test.py | 0 tests/{qtcore => QtCore}/buffer_test.py | 0 tests/{qtcore => QtCore}/child_event_test.py | 0 tests/{qtcore => QtCore}/deletelater_test.py | 0 .../{qtcore => QtCore}/duck_punching_test.py | 0 .../missing_symbols_test.py | 0 tests/{qtcore => QtCore}/qabs_test.py | 0 .../qabstracttransition_test.py | 0 .../qanimationgroup_test.py | 0 tests/{qtcore => QtCore}/qbitarray_test.py | 0 .../qbytearray_buffer_protocol_test.py | 0 .../qbytearray_concatenation_operator_test.py | 0 .../qbytearray_operator_iadd_test.py | 0 .../qbytearray_operator_test.py | 0 tests/{qtcore => QtCore}/qbytearray_test.py | 0 tests/{qtcore => QtCore}/qchar_test.py | 0 .../qcoreapplication_instance_test.py | 0 tests/{qtcore => QtCore}/qdatastream_test.py | 0 tests/{qtcore => QtCore}/qdate_test.py | 0 tests/{qtcore => QtCore}/qenum_test.py | 0 tests/{qtcore => QtCore}/qevent_test.py | 0 tests/{qtcore => QtCore}/qfile_test.py | 0 tests/{qtcore => QtCore}/qfileinfo_test.py | 0 tests/{qtcore => QtCore}/qflags_test.py | 0 tests/{qtcore => QtCore}/qhandle_test.py | 0 .../{qtcore => QtCore}/qlatin1string_test.py | 0 tests/{qtcore => QtCore}/qlinef_test.py | 0 tests/{qtcore => QtCore}/qlocale_test.py | 0 tests/{qtcore => QtCore}/qmetaobject_test.py | 0 .../qmodelindex_internalpointer_test.py | 0 .../qobject_children_segfault_test.py | 0 .../qobject_connect_notify_test.py | 0 .../qobject_event_filter_test.py | 0 .../qobject_inherits_test.py | 0 .../{qtcore => QtCore}/qobject_parent_test.py | 0 .../qobject_property_test.py | 0 .../qobject_protected_methods_test.py | 0 tests/{qtcore => QtCore}/qobject_test.py | 0 .../qobject_timer_event_test.py | 0 .../qobject_tr_as_instance_test.py | 0 tests/{qtcore => QtCore}/qpoint_test.py | 0 tests/{qtcore => QtCore}/qprocess_test.py | 0 tests/{qtcore => QtCore}/qrect_test.py | 0 tests/{qtcore => QtCore}/qresource_test.py | 0 tests/{qtcore => QtCore}/qsize_test.py | 0 tests/{qtcore => QtCore}/qslot_object_test.py | 0 tests/{qtcore => QtCore}/qsrand_test.py | 0 tests/{qtcore => QtCore}/qstate_test.py | 0 .../{qtcore => QtCore}/qstatemachine_test.py | 0 .../qstring_buffer_protocol_test.py | 0 .../qstring_operator_test.py | 0 tests/{qtcore => QtCore}/qstring_test.py | 0 tests/{qtcore => QtCore}/qstringlist_test.py | 0 tests/{qtcore => QtCore}/qtext_codec_test.py | 0 tests/{qtcore => QtCore}/qtextstream_test.py | 0 .../qthread_prod_cons_test.py | 0 .../{qtcore => QtCore}/qthread_signal_test.py | 0 tests/{qtcore => QtCore}/qthread_test.py | 0 .../qtimer_singleshot_test.py | 0 .../{qtcore => QtCore}/qtimer_timeout_test.py | 0 tests/{qtcore => QtCore}/qtnamespace_test.py | 0 tests/{qtcore => QtCore}/quoteEnUS.txt | 0 tests/{qtcore => QtCore}/qurl_test.py | 0 .../qvariant_pyobject_test.py | 0 tests/{qtcore => QtCore}/qvariant_test.py | 0 tests/{qtcore => QtCore}/resources.qrc | 0 tests/{qtcore => QtCore}/resources_mc.py | 0 .../{qtcore => QtCore}/static_method_test.py | 0 .../static_protected_methods_test.py | 0 tests/{qtcore => QtCore}/thread_signals.py | 14 +--- tests/{qtcore => QtCore}/translation_test.py | 0 .../translations/trans_latin.ts | 0 .../translations/trans_russian.ts | 0 .../{qtcore => QtCore}/unaryoperator_test.py | 0 tests/{qtcore => QtCore}/unicode_test.py | 0 tests/QtDeclarative/CMakeLists.txt | 2 + .../network.qml | 0 .../qdeclarativenetwork_test.py | 0 .../qdeclarativeview_test.py | 0 .../{qtdeclarative => QtDeclarative}/view.qml | 0 tests/QtGui/CMakeLists.txt | 58 ++++++++++++++ tests/{qtgui => QtGui}/add_action_test.py | 0 .../customproxywidget_test.py | 0 .../float_to_int_implicit_conversion_test.py | 0 .../grandparent_method_test.py | 0 tests/{qtgui => QtGui}/hashabletype_test.py | 0 tests/{qtgui => QtGui}/keep_reference_test.py | 0 .../{qtgui => QtGui}/missing_symbols_test.py | 0 tests/{qtgui => QtGui}/paint_event_test.py | 0 tests/{qtgui => QtGui}/parent_method_test.py | 0 .../python_properties_test.py | 0 tests/{qtgui => QtGui}/qapp_test.py | 0 .../qapplication_exit_segfault_test.py | 0 .../qapplication_singleton_test.py | 0 tests/{qtgui => QtGui}/qbrush_test.py | 0 tests/{qtgui => QtGui}/qcolor_test.py | 0 .../qdatastream_gui_operators_test.py | 0 tests/{qtgui => QtGui}/qfontdialog_test.py | 0 tests/{qtgui => QtGui}/qfontmetrics_test.py | 0 .../qgraphicsitem_isblocked_test.py | 0 tests/{qtgui => QtGui}/qgraphicsitem_test.py | 0 .../qgraphicsproxywidget_test.py | 0 tests/{qtgui => QtGui}/qgraphicsscene_test.py | 0 .../{qtgui => QtGui}/qinputdialog_get_test.py | 0 tests/{qtgui => QtGui}/qitemselection_test.py | 0 tests/{qtgui => QtGui}/qlayout_ref_test.py | 0 tests/{qtgui => QtGui}/qlayout_test.py | 0 tests/{qtgui => QtGui}/qlcdnumber_test.py | 0 .../{qtgui => QtGui}/qlistwidgetitem_test.py | 0 tests/{qtgui => QtGui}/qmainwindow_test.py | 0 tests/{qtgui => QtGui}/qmatrix_test.py | 0 tests/{qtgui => QtGui}/qmenu_test.py | 0 tests/{qtgui => QtGui}/qmenuadd_test.py | 0 tests/{qtgui => QtGui}/qobject_mi_test.py | 0 tests/{qtgui => QtGui}/qpainter_test.py | 0 tests/{qtgui => QtGui}/qpen_test.py | 0 tests/{qtgui => QtGui}/qpixmap_test.py | 0 tests/{qtgui => QtGui}/qpushbutton_test.py | 0 .../{qtgui => QtGui}/qradialgradient_test.py | 0 tests/{qtgui => QtGui}/qregion_test.py | 0 tests/{qtgui => QtGui}/qshortcut_test.py | 0 .../qstandarditemmodel_test.py | 0 .../qstring_qkeysequence_test.py | 0 tests/{qtgui => QtGui}/qstyle_test.py | 0 tests/{qtgui => QtGui}/qtableview_test.py | 0 tests/{qtgui => QtGui}/qtabwidget_test.py | 0 tests/{qtgui => QtGui}/qtextedit_test.py | 0 tests/{qtgui => QtGui}/qtoolbar_test.py | 0 tests/{qtgui => QtGui}/qtoolbox_test.py | 0 tests/{qtgui => QtGui}/qvariant_test.py | 0 .../qwidget_setlayout_test.py | 0 tests/{qtgui => QtGui}/qwidget_test.py | 0 .../{qtgui => QtGui}/reference_count_test.py | 0 tests/{qtgui => QtGui}/sample.png | Bin tests/{qtgui => QtGui}/standardpixmap_test.py | 0 tests/{qtgui => QtGui}/timed_app_test.py | 0 .../virtual_protected_inheritance_test.py | 0 .../{qtgui => QtGui}/virtual_pure_override.py | 0 tests/{qtgui => QtGui}/wrong_return_test.py | 0 tests/{qtgui => QtGui}/x11_symbols.py | 0 tests/QtHelp/CMakeLists.txt | 1 + tests/{qthelp => QtHelp}/help_test.py | 0 tests/QtMaemo5/CMakeLists.txt | 2 + .../pickselector_test.py | 0 .../qmaemo5import_test.py | 0 tests/QtMultimedia/CMakeLists.txt | 1 + .../audio_test.py | 0 tests/QtNetwork/CMakeLists.txt | 4 + .../accessManager_test.py | 0 tests/{qtnetwork => QtNetwork}/http_test.py | 0 .../tcpserver_test.py | 0 .../udpsocket_test.py | 0 tests/QtOpenGL/CMakeLists.txt | 3 + .../{qtopengl => QtOpenGL}/qglbuffer_test.py | 0 tests/QtScript/CMakeLists.txt | 3 + tests/{qtscript => QtScript}/base_test.py | 0 tests/{qtscript => QtScript}/engine_test.py | 0 tests/{qtscript => QtScript}/test_base.py | 0 tests/QtScriptTools/CMakeLists.txt | 1 + .../debugger_test.py | 0 tests/QtSql/CMakeLists.txt | 1 + .../qsqldatabaseandqueries_test.py | 0 tests/QtSvg/CMakeLists.txt | 1 + tests/{qtsvg => QtSvg}/qsvggenerator_test.py | 0 tests/QtTest/CMakeLists.txt | 2 + tests/{qttest => QtTest}/click_test.py | 0 tests/{qttest => QtTest}/eventfilter_test.py | 0 tests/QtUiTools/CMakeLists.txt | 2 + tests/{qtuitools => QtUiTools}/test.ui | 0 tests/{qtuitools => QtUiTools}/ui_test.py | 0 .../{qtuitools => QtUiTools}/uiloader_test.py | 0 tests/QtWebKit/CMakeLists.txt | 2 + tests/{qtwebkit => QtWebKit}/fox.html | 0 tests/{qtwebkit => QtWebKit}/webpage_test.py | 0 tests/{qtwebkit => QtWebKit}/webview_test.py | 0 tests/QtXml/CMakeLists.txt | 2 + tests/{qtxml => QtXml}/qdomdocument_test.py | 0 .../{qtxml => QtXml}/qxmlsimplereader_test.py | 0 tests/QtXmlPatterns/CMakeLists.txt | 1 + .../import_test.py | 0 tests/phonon/CMakeLists.txt | 2 + tests/qtgui/qlabel_pixmap_refcount.py | 46 ------------ tests/run_test.sh | 8 +- tests/signals/CMakeLists.txt | 32 ++++++++ tests/signals/args_dont_match_test.py | 1 + tests/signals/decorators_test.py | 0 tests/signals/invalid_callback_test.py | 0 tests/signals/lambda_gui_test.py | 0 tests/signals/lambda_test.py | 0 .../signals/multiple_connections_gui_test.py | 0 tests/signals/multiple_connections_test.py | 0 tests/signals/pysignal_test.py | 0 tests/signals/qobject_destroyed_test.py | 0 tests/signals/qobject_receivers_test.py | 0 tests/signals/segfault_proxyparent_test.py | 0 tests/signals/self_connect_test.py | 0 tests/signals/short_circuit_test.py | 0 tests/signals/signal2signal_connect_test.py | 0 tests/signals/signal_autoconnect_test.py | 0 .../signals/signal_connectiontype_support.py | 0 tests/signals/signal_emission_gui_test.py | 0 tests/signals/signal_emission_test.py | 0 tests/signals/signal_func_test.py | 0 tests/signals/signal_manager_refcount_test.py | 0 tests/signals/signal_object_test.py | 0 .../signal_with_primitive_type_test.py | 0 tests/signals/slot_reference_count_test.py | 0 tests/signals/static_metaobject_test.py | 0 tests/signals/upstream_segfault_test.py | 0 211 files changed, 241 insertions(+), 79 deletions(-) create mode 100644 tests/QtCore/CMakeLists.txt rename tests/{qtcore => QtCore}/blocking_signals_test.py (100%) rename tests/{qtcore => QtCore}/buffer_test.py (100%) rename tests/{qtcore => QtCore}/child_event_test.py (100%) rename tests/{qtcore => QtCore}/deletelater_test.py (100%) rename tests/{qtcore => QtCore}/duck_punching_test.py (100%) rename tests/{qtcore => QtCore}/missing_symbols_test.py (100%) rename tests/{qtcore => QtCore}/qabs_test.py (100%) rename tests/{qtcore => QtCore}/qabstracttransition_test.py (100%) rename tests/{qtcore => QtCore}/qanimationgroup_test.py (100%) rename tests/{qtcore => QtCore}/qbitarray_test.py (100%) rename tests/{qtcore => QtCore}/qbytearray_buffer_protocol_test.py (100%) rename tests/{qtcore => QtCore}/qbytearray_concatenation_operator_test.py (100%) rename tests/{qtcore => QtCore}/qbytearray_operator_iadd_test.py (100%) rename tests/{qtcore => QtCore}/qbytearray_operator_test.py (100%) rename tests/{qtcore => QtCore}/qbytearray_test.py (100%) rename tests/{qtcore => QtCore}/qchar_test.py (100%) rename tests/{qtcore => QtCore}/qcoreapplication_instance_test.py (100%) rename tests/{qtcore => QtCore}/qdatastream_test.py (100%) rename tests/{qtcore => QtCore}/qdate_test.py (100%) rename tests/{qtcore => QtCore}/qenum_test.py (100%) rename tests/{qtcore => QtCore}/qevent_test.py (100%) rename tests/{qtcore => QtCore}/qfile_test.py (100%) rename tests/{qtcore => QtCore}/qfileinfo_test.py (100%) rename tests/{qtcore => QtCore}/qflags_test.py (100%) rename tests/{qtcore => QtCore}/qhandle_test.py (100%) rename tests/{qtcore => QtCore}/qlatin1string_test.py (100%) rename tests/{qtcore => QtCore}/qlinef_test.py (100%) rename tests/{qtcore => QtCore}/qlocale_test.py (100%) rename tests/{qtcore => QtCore}/qmetaobject_test.py (100%) rename tests/{qtcore => QtCore}/qmodelindex_internalpointer_test.py (100%) rename tests/{qtcore => QtCore}/qobject_children_segfault_test.py (100%) rename tests/{qtcore => QtCore}/qobject_connect_notify_test.py (100%) rename tests/{qtcore => QtCore}/qobject_event_filter_test.py (100%) rename tests/{qtcore => QtCore}/qobject_inherits_test.py (100%) rename tests/{qtcore => QtCore}/qobject_parent_test.py (100%) rename tests/{qtcore => QtCore}/qobject_property_test.py (100%) rename tests/{qtcore => QtCore}/qobject_protected_methods_test.py (100%) rename tests/{qtcore => QtCore}/qobject_test.py (100%) rename tests/{qtcore => QtCore}/qobject_timer_event_test.py (100%) rename tests/{qtcore => QtCore}/qobject_tr_as_instance_test.py (100%) rename tests/{qtcore => QtCore}/qpoint_test.py (100%) rename tests/{qtcore => QtCore}/qprocess_test.py (100%) rename tests/{qtcore => QtCore}/qrect_test.py (100%) rename tests/{qtcore => QtCore}/qresource_test.py (100%) rename tests/{qtcore => QtCore}/qsize_test.py (100%) rename tests/{qtcore => QtCore}/qslot_object_test.py (100%) rename tests/{qtcore => QtCore}/qsrand_test.py (100%) rename tests/{qtcore => QtCore}/qstate_test.py (100%) rename tests/{qtcore => QtCore}/qstatemachine_test.py (100%) rename tests/{qtcore => QtCore}/qstring_buffer_protocol_test.py (100%) rename tests/{qtcore => QtCore}/qstring_operator_test.py (100%) rename tests/{qtcore => QtCore}/qstring_test.py (100%) rename tests/{qtcore => QtCore}/qstringlist_test.py (100%) rename tests/{qtcore => QtCore}/qtext_codec_test.py (100%) rename tests/{qtcore => QtCore}/qtextstream_test.py (100%) rename tests/{qtcore => QtCore}/qthread_prod_cons_test.py (100%) rename tests/{qtcore => QtCore}/qthread_signal_test.py (100%) rename tests/{qtcore => QtCore}/qthread_test.py (100%) rename tests/{qtcore => QtCore}/qtimer_singleshot_test.py (100%) rename tests/{qtcore => QtCore}/qtimer_timeout_test.py (100%) rename tests/{qtcore => QtCore}/qtnamespace_test.py (100%) rename tests/{qtcore => QtCore}/quoteEnUS.txt (100%) rename tests/{qtcore => QtCore}/qurl_test.py (100%) rename tests/{qtcore => QtCore}/qvariant_pyobject_test.py (100%) rename tests/{qtcore => QtCore}/qvariant_test.py (100%) rename tests/{qtcore => QtCore}/resources.qrc (100%) rename tests/{qtcore => QtCore}/resources_mc.py (100%) rename tests/{qtcore => QtCore}/static_method_test.py (100%) rename tests/{qtcore => QtCore}/static_protected_methods_test.py (100%) rename tests/{qtcore => QtCore}/thread_signals.py (70%) rename tests/{qtcore => QtCore}/translation_test.py (100%) rename tests/{qtcore => QtCore}/translations/trans_latin.ts (100%) rename tests/{qtcore => QtCore}/translations/trans_russian.ts (100%) rename tests/{qtcore => QtCore}/unaryoperator_test.py (100%) rename tests/{qtcore => QtCore}/unicode_test.py (100%) create mode 100644 tests/QtDeclarative/CMakeLists.txt rename tests/{qtdeclarative => QtDeclarative}/network.qml (100%) rename tests/{qtdeclarative => QtDeclarative}/qdeclarativenetwork_test.py (100%) rename tests/{qtdeclarative => QtDeclarative}/qdeclarativeview_test.py (100%) rename tests/{qtdeclarative => QtDeclarative}/view.qml (100%) create mode 100644 tests/QtGui/CMakeLists.txt rename tests/{qtgui => QtGui}/add_action_test.py (100%) rename tests/{qtgui => QtGui}/customproxywidget_test.py (100%) rename tests/{qtgui => QtGui}/float_to_int_implicit_conversion_test.py (100%) rename tests/{qtgui => QtGui}/grandparent_method_test.py (100%) rename tests/{qtgui => QtGui}/hashabletype_test.py (100%) rename tests/{qtgui => QtGui}/keep_reference_test.py (100%) rename tests/{qtgui => QtGui}/missing_symbols_test.py (100%) rename tests/{qtgui => QtGui}/paint_event_test.py (100%) rename tests/{qtgui => QtGui}/parent_method_test.py (100%) rename tests/{qtgui => QtGui}/python_properties_test.py (100%) rename tests/{qtgui => QtGui}/qapp_test.py (100%) rename tests/{qtgui => QtGui}/qapplication_exit_segfault_test.py (100%) rename tests/{qtgui => QtGui}/qapplication_singleton_test.py (100%) rename tests/{qtgui => QtGui}/qbrush_test.py (100%) rename tests/{qtgui => QtGui}/qcolor_test.py (100%) rename tests/{qtgui => QtGui}/qdatastream_gui_operators_test.py (100%) rename tests/{qtgui => QtGui}/qfontdialog_test.py (100%) rename tests/{qtgui => QtGui}/qfontmetrics_test.py (100%) rename tests/{qtgui => QtGui}/qgraphicsitem_isblocked_test.py (100%) rename tests/{qtgui => QtGui}/qgraphicsitem_test.py (100%) rename tests/{qtgui => QtGui}/qgraphicsproxywidget_test.py (100%) rename tests/{qtgui => QtGui}/qgraphicsscene_test.py (100%) rename tests/{qtgui => QtGui}/qinputdialog_get_test.py (100%) rename tests/{qtgui => QtGui}/qitemselection_test.py (100%) rename tests/{qtgui => QtGui}/qlayout_ref_test.py (100%) rename tests/{qtgui => QtGui}/qlayout_test.py (100%) rename tests/{qtgui => QtGui}/qlcdnumber_test.py (100%) rename tests/{qtgui => QtGui}/qlistwidgetitem_test.py (100%) rename tests/{qtgui => QtGui}/qmainwindow_test.py (100%) rename tests/{qtgui => QtGui}/qmatrix_test.py (100%) rename tests/{qtgui => QtGui}/qmenu_test.py (100%) rename tests/{qtgui => QtGui}/qmenuadd_test.py (100%) rename tests/{qtgui => QtGui}/qobject_mi_test.py (100%) rename tests/{qtgui => QtGui}/qpainter_test.py (100%) rename tests/{qtgui => QtGui}/qpen_test.py (100%) rename tests/{qtgui => QtGui}/qpixmap_test.py (100%) rename tests/{qtgui => QtGui}/qpushbutton_test.py (100%) rename tests/{qtgui => QtGui}/qradialgradient_test.py (100%) rename tests/{qtgui => QtGui}/qregion_test.py (100%) rename tests/{qtgui => QtGui}/qshortcut_test.py (100%) rename tests/{qtgui => QtGui}/qstandarditemmodel_test.py (100%) rename tests/{qtgui => QtGui}/qstring_qkeysequence_test.py (100%) rename tests/{qtgui => QtGui}/qstyle_test.py (100%) rename tests/{qtgui => QtGui}/qtableview_test.py (100%) rename tests/{qtgui => QtGui}/qtabwidget_test.py (100%) rename tests/{qtgui => QtGui}/qtextedit_test.py (100%) rename tests/{qtgui => QtGui}/qtoolbar_test.py (100%) rename tests/{qtgui => QtGui}/qtoolbox_test.py (100%) rename tests/{qtgui => QtGui}/qvariant_test.py (100%) rename tests/{qtgui => QtGui}/qwidget_setlayout_test.py (100%) rename tests/{qtgui => QtGui}/qwidget_test.py (100%) rename tests/{qtgui => QtGui}/reference_count_test.py (100%) rename tests/{qtgui => QtGui}/sample.png (100%) rename tests/{qtgui => QtGui}/standardpixmap_test.py (100%) rename tests/{qtgui => QtGui}/timed_app_test.py (100%) rename tests/{qtgui => QtGui}/virtual_protected_inheritance_test.py (100%) rename tests/{qtgui => QtGui}/virtual_pure_override.py (100%) rename tests/{qtgui => QtGui}/wrong_return_test.py (100%) rename tests/{qtgui => QtGui}/x11_symbols.py (100%) create mode 100644 tests/QtHelp/CMakeLists.txt rename tests/{qthelp => QtHelp}/help_test.py (100%) create mode 100644 tests/QtMaemo5/CMakeLists.txt rename tests/{qtmaemo5 => QtMaemo5}/pickselector_test.py (100%) rename tests/{qtmaemo5 => QtMaemo5}/qmaemo5import_test.py (100%) create mode 100644 tests/QtMultimedia/CMakeLists.txt rename tests/{qtmultimedia => QtMultimedia}/audio_test.py (100%) create mode 100644 tests/QtNetwork/CMakeLists.txt rename tests/{qtnetwork => QtNetwork}/accessManager_test.py (100%) rename tests/{qtnetwork => QtNetwork}/http_test.py (100%) rename tests/{qtnetwork => QtNetwork}/tcpserver_test.py (100%) rename tests/{qtnetwork => QtNetwork}/udpsocket_test.py (100%) create mode 100644 tests/QtOpenGL/CMakeLists.txt rename tests/{qtopengl => QtOpenGL}/qglbuffer_test.py (100%) create mode 100644 tests/QtScript/CMakeLists.txt rename tests/{qtscript => QtScript}/base_test.py (100%) rename tests/{qtscript => QtScript}/engine_test.py (100%) rename tests/{qtscript => QtScript}/test_base.py (100%) create mode 100644 tests/QtScriptTools/CMakeLists.txt rename tests/{qtscripttools => QtScriptTools}/debugger_test.py (100%) create mode 100644 tests/QtSql/CMakeLists.txt rename tests/{qtsql => QtSql}/qsqldatabaseandqueries_test.py (100%) create mode 100644 tests/QtSvg/CMakeLists.txt rename tests/{qtsvg => QtSvg}/qsvggenerator_test.py (100%) create mode 100644 tests/QtTest/CMakeLists.txt rename tests/{qttest => QtTest}/click_test.py (100%) rename tests/{qttest => QtTest}/eventfilter_test.py (100%) create mode 100644 tests/QtUiTools/CMakeLists.txt rename tests/{qtuitools => QtUiTools}/test.ui (100%) rename tests/{qtuitools => QtUiTools}/ui_test.py (100%) rename tests/{qtuitools => QtUiTools}/uiloader_test.py (100%) create mode 100644 tests/QtWebKit/CMakeLists.txt rename tests/{qtwebkit => QtWebKit}/fox.html (100%) rename tests/{qtwebkit => QtWebKit}/webpage_test.py (100%) rename tests/{qtwebkit => QtWebKit}/webview_test.py (100%) create mode 100644 tests/QtXml/CMakeLists.txt rename tests/{qtxml => QtXml}/qdomdocument_test.py (100%) rename tests/{qtxml => QtXml}/qxmlsimplereader_test.py (100%) create mode 100644 tests/QtXmlPatterns/CMakeLists.txt rename tests/{qtxmlpatterns => QtXmlPatterns}/import_test.py (100%) create mode 100644 tests/phonon/CMakeLists.txt delete mode 100644 tests/qtgui/qlabel_pixmap_refcount.py create mode 100644 tests/signals/CMakeLists.txt mode change 100644 => 100755 tests/signals/args_dont_match_test.py mode change 100644 => 100755 tests/signals/decorators_test.py mode change 100644 => 100755 tests/signals/invalid_callback_test.py mode change 100644 => 100755 tests/signals/lambda_gui_test.py mode change 100644 => 100755 tests/signals/lambda_test.py mode change 100644 => 100755 tests/signals/multiple_connections_gui_test.py mode change 100644 => 100755 tests/signals/multiple_connections_test.py mode change 100644 => 100755 tests/signals/pysignal_test.py mode change 100644 => 100755 tests/signals/qobject_destroyed_test.py mode change 100644 => 100755 tests/signals/qobject_receivers_test.py mode change 100644 => 100755 tests/signals/segfault_proxyparent_test.py mode change 100644 => 100755 tests/signals/self_connect_test.py mode change 100644 => 100755 tests/signals/short_circuit_test.py mode change 100644 => 100755 tests/signals/signal2signal_connect_test.py mode change 100644 => 100755 tests/signals/signal_autoconnect_test.py mode change 100644 => 100755 tests/signals/signal_connectiontype_support.py mode change 100644 => 100755 tests/signals/signal_emission_gui_test.py mode change 100644 => 100755 tests/signals/signal_emission_test.py mode change 100644 => 100755 tests/signals/signal_func_test.py mode change 100644 => 100755 tests/signals/signal_manager_refcount_test.py mode change 100644 => 100755 tests/signals/signal_object_test.py mode change 100644 => 100755 tests/signals/signal_with_primitive_type_test.py mode change 100644 => 100755 tests/signals/slot_reference_count_test.py mode change 100644 => 100755 tests/signals/static_metaobject_test.py mode change 100644 => 100755 tests/signals/upstream_segfault_test.py diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ada5b7a..d87414f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,22 +1,44 @@ +set(PYSIDE_TIMEOUT 5) -file(GLOB TEST_FILES */*_test.py) +macro(TEST_QT_MODULE var name) + if(NOT DISABLE_${name} AND ${var}) + add_subdirectory(${name}) + endif() +endmacro(TEST_QT_MODULE) -set(test_blacklist ) +macro(PYSIDE_TEST) + set(TEST_NAME ${ARGV0}) + if (${ARGC} EQUAL 1) + set(EXPECT_TO_FAIL 0) + elseif(${ARGC} EQUAL 2) + set(EXPECT_TO_FAIL ${ARGV1}) + else() + message(WARNING "Ivalid call of macro PYSIDE_TEST") + endif() + set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}") + add_test(${TEST_NAME} ${TEST_CMD}) + set_tests_properties(${TEST_NAME} PROPERTIES + TIMEOUT ${PYSIDE_TIMEOUT} + WILL_FAIL ${EXPECT_TO_FAIL}) +endmacro(PYSIDE_TEST) -foreach(test_file ${TEST_FILES}) - string(REGEX MATCH "/([^/]+)//?([^/]+)_test.py" test_name ${test_file} ) - list(FIND test_blacklist ${CMAKE_MATCH_1}_${CMAKE_MATCH_2} expect_fail) - add_test(${CMAKE_MATCH_1}_${CMAKE_MATCH_2} sh - ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh - "${pysidebase_BINARY_DIR}:${libpyside_BINARY_DIR}" - "${CMAKE_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}/util" - ${PYTHON_EXECUTABLE} - ${test_file}) - set_tests_properties(${CMAKE_MATCH_1}_${CMAKE_MATCH_2} PROPERTIES TIMEOUT 5) - if (${expect_fail} GREATER -1) - set_tests_properties(${CMAKE_MATCH_1}_${CMAKE_MATCH_2} PROPERTIES WILL_FAIL TRUE) - endif(${expect_fail} GREATER -1) -# Should set python path here -# Looks like it's fixed in 2.8: -# http://www.vtk.org/Bug/print_bug_page.php?bug_id=7885 -endforeach(test_file ${TEST_FILES}) + +add_subdirectory(signals) +TEST_QT_MODULE(QT_QTCORE_FOUND QtCore) +TEST_QT_MODULE(QT_QTGUI_FOUND QtGui) +TEST_QT_MODULE(QT_QTNETWORK_FOUND QtNetwork) +TEST_QT_MODULE(QT_QTWEBKIT_FOUND QtWebKit) +TEST_QT_MODULE(QT_QTSVG_FOUND QtSvg) +TEST_QT_MODULE(QT_QTXML_FOUND QtXml) +TEST_QT_MODULE(QT_QTTEST_FOUND QtTest) +TEST_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL) +TEST_QT_MODULE(QT_QTSQL_FOUND QtSql) +TEST_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) +TEST_QT_MODULE(QT_QTHELP_FOUND QtHelp) +TEST_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns) +TEST_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5) +TEST_QT_MODULE(QT_QTSCRIPT_FOUND QtScript) +TEST_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools) +TEST_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia) +TEST_QT_MODULE(QT_PHONON_FOUND phonon) +TEST_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative) diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt new file mode 100644 index 0000000..536d408 --- /dev/null +++ b/tests/QtCore/CMakeLists.txt @@ -0,0 +1,71 @@ +PYSIDE_TEST(blocking_signals_test.py) +PYSIDE_TEST(buffer_test.py) +PYSIDE_TEST(child_event_test.py) +PYSIDE_TEST(deletelater_test.py) +PYSIDE_TEST(duck_punching_test.py) +PYSIDE_TEST(missing_symbols_test.py) +PYSIDE_TEST(qabs_test.py) +PYSIDE_TEST(qabstracttransition_test.py) +PYSIDE_TEST(qanimationgroup_test.py) +PYSIDE_TEST(qbitarray_test.py) +PYSIDE_TEST(qbytearray_buffer_protocol_test.py) +PYSIDE_TEST(qbytearray_concatenation_operator_test.py) +PYSIDE_TEST(qbytearray_operator_iadd_test.py) +PYSIDE_TEST(qbytearray_operator_test.py) +PYSIDE_TEST(qbytearray_test.py) +PYSIDE_TEST(qchar_test.py) +PYSIDE_TEST(qcoreapplication_instance_test.py) +PYSIDE_TEST(qdatastream_test.py) +PYSIDE_TEST(qdate_test.py) +PYSIDE_TEST(qenum_test.py) +PYSIDE_TEST(qevent_test.py) +PYSIDE_TEST(qfileinfo_test.py) +PYSIDE_TEST(qfile_test.py) +PYSIDE_TEST(qflags_test.py) +PYSIDE_TEST(qhandle_test.py) +PYSIDE_TEST(qlatin1string_test.py) +PYSIDE_TEST(qlinef_test.py) +PYSIDE_TEST(qlocale_test.py) +PYSIDE_TEST(qmetaobject_test.py) +PYSIDE_TEST(qmodelindex_internalpointer_test.py) +PYSIDE_TEST(qobject_children_segfault_test.py) +PYSIDE_TEST(qobject_connect_notify_test.py) +PYSIDE_TEST(qobject_event_filter_test.py) +PYSIDE_TEST(qobject_inherits_test.py) +PYSIDE_TEST(qobject_parent_test.py) +PYSIDE_TEST(qobject_property_test.py) +PYSIDE_TEST(qobject_protected_methods_test.py) +PYSIDE_TEST(qobject_test.py) +PYSIDE_TEST(qobject_timer_event_test.py) +PYSIDE_TEST(qobject_tr_as_instance_test.py) +PYSIDE_TEST(qpoint_test.py) +PYSIDE_TEST(qprocess_test.py) +PYSIDE_TEST(qrect_test.py) +PYSIDE_TEST(qresource_test.py) +PYSIDE_TEST(qsize_test.py) +PYSIDE_TEST(qslot_object_test.py) +PYSIDE_TEST(qsrand_test.py) +PYSIDE_TEST(qstatemachine_test.py) +PYSIDE_TEST(qstate_test.py) +PYSIDE_TEST(qstring_buffer_protocol_test.py) +PYSIDE_TEST(qstringlist_test.py) +PYSIDE_TEST(qstring_operator_test.py) +PYSIDE_TEST(qstring_test.py) +PYSIDE_TEST(qtext_codec_test.py) +PYSIDE_TEST(qtextstream_test.py) +PYSIDE_TEST(qthread_prod_cons_test.py) +PYSIDE_TEST(qthread_signal_test.py) +PYSIDE_TEST(qthread_test.py) +PYSIDE_TEST(qtimer_singleshot_test.py) +PYSIDE_TEST(qtimer_timeout_test.py) +PYSIDE_TEST(qtnamespace_test.py) +PYSIDE_TEST(qurl_test.py) +PYSIDE_TEST(qvariant_pyobject_test.py) +PYSIDE_TEST(qvariant_test.py) +PYSIDE_TEST(resources_mc.py) +PYSIDE_TEST(static_method_test.py) +PYSIDE_TEST(static_protected_methods_test.py) +PYSIDE_TEST(thread_signals.py) +PYSIDE_TEST(translation_test.py) +PYSIDE_TEST(unaryoperator_test.py) +PYSIDE_TEST(unicode_test.py) diff --git a/tests/qtcore/blocking_signals_test.py b/tests/QtCore/blocking_signals_test.py similarity index 100% rename from tests/qtcore/blocking_signals_test.py rename to tests/QtCore/blocking_signals_test.py diff --git a/tests/qtcore/buffer_test.py b/tests/QtCore/buffer_test.py similarity index 100% rename from tests/qtcore/buffer_test.py rename to tests/QtCore/buffer_test.py diff --git a/tests/qtcore/child_event_test.py b/tests/QtCore/child_event_test.py similarity index 100% rename from tests/qtcore/child_event_test.py rename to tests/QtCore/child_event_test.py diff --git a/tests/qtcore/deletelater_test.py b/tests/QtCore/deletelater_test.py similarity index 100% rename from tests/qtcore/deletelater_test.py rename to tests/QtCore/deletelater_test.py diff --git a/tests/qtcore/duck_punching_test.py b/tests/QtCore/duck_punching_test.py similarity index 100% rename from tests/qtcore/duck_punching_test.py rename to tests/QtCore/duck_punching_test.py diff --git a/tests/qtcore/missing_symbols_test.py b/tests/QtCore/missing_symbols_test.py similarity index 100% rename from tests/qtcore/missing_symbols_test.py rename to tests/QtCore/missing_symbols_test.py diff --git a/tests/qtcore/qabs_test.py b/tests/QtCore/qabs_test.py similarity index 100% rename from tests/qtcore/qabs_test.py rename to tests/QtCore/qabs_test.py diff --git a/tests/qtcore/qabstracttransition_test.py b/tests/QtCore/qabstracttransition_test.py similarity index 100% rename from tests/qtcore/qabstracttransition_test.py rename to tests/QtCore/qabstracttransition_test.py diff --git a/tests/qtcore/qanimationgroup_test.py b/tests/QtCore/qanimationgroup_test.py similarity index 100% rename from tests/qtcore/qanimationgroup_test.py rename to tests/QtCore/qanimationgroup_test.py diff --git a/tests/qtcore/qbitarray_test.py b/tests/QtCore/qbitarray_test.py similarity index 100% rename from tests/qtcore/qbitarray_test.py rename to tests/QtCore/qbitarray_test.py diff --git a/tests/qtcore/qbytearray_buffer_protocol_test.py b/tests/QtCore/qbytearray_buffer_protocol_test.py similarity index 100% rename from tests/qtcore/qbytearray_buffer_protocol_test.py rename to tests/QtCore/qbytearray_buffer_protocol_test.py diff --git a/tests/qtcore/qbytearray_concatenation_operator_test.py b/tests/QtCore/qbytearray_concatenation_operator_test.py similarity index 100% rename from tests/qtcore/qbytearray_concatenation_operator_test.py rename to tests/QtCore/qbytearray_concatenation_operator_test.py diff --git a/tests/qtcore/qbytearray_operator_iadd_test.py b/tests/QtCore/qbytearray_operator_iadd_test.py similarity index 100% rename from tests/qtcore/qbytearray_operator_iadd_test.py rename to tests/QtCore/qbytearray_operator_iadd_test.py diff --git a/tests/qtcore/qbytearray_operator_test.py b/tests/QtCore/qbytearray_operator_test.py similarity index 100% rename from tests/qtcore/qbytearray_operator_test.py rename to tests/QtCore/qbytearray_operator_test.py diff --git a/tests/qtcore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py similarity index 100% rename from tests/qtcore/qbytearray_test.py rename to tests/QtCore/qbytearray_test.py diff --git a/tests/qtcore/qchar_test.py b/tests/QtCore/qchar_test.py similarity index 100% rename from tests/qtcore/qchar_test.py rename to tests/QtCore/qchar_test.py diff --git a/tests/qtcore/qcoreapplication_instance_test.py b/tests/QtCore/qcoreapplication_instance_test.py similarity index 100% rename from tests/qtcore/qcoreapplication_instance_test.py rename to tests/QtCore/qcoreapplication_instance_test.py diff --git a/tests/qtcore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py similarity index 100% rename from tests/qtcore/qdatastream_test.py rename to tests/QtCore/qdatastream_test.py diff --git a/tests/qtcore/qdate_test.py b/tests/QtCore/qdate_test.py similarity index 100% rename from tests/qtcore/qdate_test.py rename to tests/QtCore/qdate_test.py diff --git a/tests/qtcore/qenum_test.py b/tests/QtCore/qenum_test.py similarity index 100% rename from tests/qtcore/qenum_test.py rename to tests/QtCore/qenum_test.py diff --git a/tests/qtcore/qevent_test.py b/tests/QtCore/qevent_test.py similarity index 100% rename from tests/qtcore/qevent_test.py rename to tests/QtCore/qevent_test.py diff --git a/tests/qtcore/qfile_test.py b/tests/QtCore/qfile_test.py similarity index 100% rename from tests/qtcore/qfile_test.py rename to tests/QtCore/qfile_test.py diff --git a/tests/qtcore/qfileinfo_test.py b/tests/QtCore/qfileinfo_test.py similarity index 100% rename from tests/qtcore/qfileinfo_test.py rename to tests/QtCore/qfileinfo_test.py diff --git a/tests/qtcore/qflags_test.py b/tests/QtCore/qflags_test.py similarity index 100% rename from tests/qtcore/qflags_test.py rename to tests/QtCore/qflags_test.py diff --git a/tests/qtcore/qhandle_test.py b/tests/QtCore/qhandle_test.py similarity index 100% rename from tests/qtcore/qhandle_test.py rename to tests/QtCore/qhandle_test.py diff --git a/tests/qtcore/qlatin1string_test.py b/tests/QtCore/qlatin1string_test.py similarity index 100% rename from tests/qtcore/qlatin1string_test.py rename to tests/QtCore/qlatin1string_test.py diff --git a/tests/qtcore/qlinef_test.py b/tests/QtCore/qlinef_test.py similarity index 100% rename from tests/qtcore/qlinef_test.py rename to tests/QtCore/qlinef_test.py diff --git a/tests/qtcore/qlocale_test.py b/tests/QtCore/qlocale_test.py similarity index 100% rename from tests/qtcore/qlocale_test.py rename to tests/QtCore/qlocale_test.py diff --git a/tests/qtcore/qmetaobject_test.py b/tests/QtCore/qmetaobject_test.py similarity index 100% rename from tests/qtcore/qmetaobject_test.py rename to tests/QtCore/qmetaobject_test.py diff --git a/tests/qtcore/qmodelindex_internalpointer_test.py b/tests/QtCore/qmodelindex_internalpointer_test.py similarity index 100% rename from tests/qtcore/qmodelindex_internalpointer_test.py rename to tests/QtCore/qmodelindex_internalpointer_test.py diff --git a/tests/qtcore/qobject_children_segfault_test.py b/tests/QtCore/qobject_children_segfault_test.py similarity index 100% rename from tests/qtcore/qobject_children_segfault_test.py rename to tests/QtCore/qobject_children_segfault_test.py diff --git a/tests/qtcore/qobject_connect_notify_test.py b/tests/QtCore/qobject_connect_notify_test.py similarity index 100% rename from tests/qtcore/qobject_connect_notify_test.py rename to tests/QtCore/qobject_connect_notify_test.py diff --git a/tests/qtcore/qobject_event_filter_test.py b/tests/QtCore/qobject_event_filter_test.py similarity index 100% rename from tests/qtcore/qobject_event_filter_test.py rename to tests/QtCore/qobject_event_filter_test.py diff --git a/tests/qtcore/qobject_inherits_test.py b/tests/QtCore/qobject_inherits_test.py similarity index 100% rename from tests/qtcore/qobject_inherits_test.py rename to tests/QtCore/qobject_inherits_test.py diff --git a/tests/qtcore/qobject_parent_test.py b/tests/QtCore/qobject_parent_test.py similarity index 100% rename from tests/qtcore/qobject_parent_test.py rename to tests/QtCore/qobject_parent_test.py diff --git a/tests/qtcore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py similarity index 100% rename from tests/qtcore/qobject_property_test.py rename to tests/QtCore/qobject_property_test.py diff --git a/tests/qtcore/qobject_protected_methods_test.py b/tests/QtCore/qobject_protected_methods_test.py similarity index 100% rename from tests/qtcore/qobject_protected_methods_test.py rename to tests/QtCore/qobject_protected_methods_test.py diff --git a/tests/qtcore/qobject_test.py b/tests/QtCore/qobject_test.py similarity index 100% rename from tests/qtcore/qobject_test.py rename to tests/QtCore/qobject_test.py diff --git a/tests/qtcore/qobject_timer_event_test.py b/tests/QtCore/qobject_timer_event_test.py similarity index 100% rename from tests/qtcore/qobject_timer_event_test.py rename to tests/QtCore/qobject_timer_event_test.py diff --git a/tests/qtcore/qobject_tr_as_instance_test.py b/tests/QtCore/qobject_tr_as_instance_test.py similarity index 100% rename from tests/qtcore/qobject_tr_as_instance_test.py rename to tests/QtCore/qobject_tr_as_instance_test.py diff --git a/tests/qtcore/qpoint_test.py b/tests/QtCore/qpoint_test.py similarity index 100% rename from tests/qtcore/qpoint_test.py rename to tests/QtCore/qpoint_test.py diff --git a/tests/qtcore/qprocess_test.py b/tests/QtCore/qprocess_test.py similarity index 100% rename from tests/qtcore/qprocess_test.py rename to tests/QtCore/qprocess_test.py diff --git a/tests/qtcore/qrect_test.py b/tests/QtCore/qrect_test.py similarity index 100% rename from tests/qtcore/qrect_test.py rename to tests/QtCore/qrect_test.py diff --git a/tests/qtcore/qresource_test.py b/tests/QtCore/qresource_test.py similarity index 100% rename from tests/qtcore/qresource_test.py rename to tests/QtCore/qresource_test.py diff --git a/tests/qtcore/qsize_test.py b/tests/QtCore/qsize_test.py similarity index 100% rename from tests/qtcore/qsize_test.py rename to tests/QtCore/qsize_test.py diff --git a/tests/qtcore/qslot_object_test.py b/tests/QtCore/qslot_object_test.py similarity index 100% rename from tests/qtcore/qslot_object_test.py rename to tests/QtCore/qslot_object_test.py diff --git a/tests/qtcore/qsrand_test.py b/tests/QtCore/qsrand_test.py similarity index 100% rename from tests/qtcore/qsrand_test.py rename to tests/QtCore/qsrand_test.py diff --git a/tests/qtcore/qstate_test.py b/tests/QtCore/qstate_test.py similarity index 100% rename from tests/qtcore/qstate_test.py rename to tests/QtCore/qstate_test.py diff --git a/tests/qtcore/qstatemachine_test.py b/tests/QtCore/qstatemachine_test.py similarity index 100% rename from tests/qtcore/qstatemachine_test.py rename to tests/QtCore/qstatemachine_test.py diff --git a/tests/qtcore/qstring_buffer_protocol_test.py b/tests/QtCore/qstring_buffer_protocol_test.py similarity index 100% rename from tests/qtcore/qstring_buffer_protocol_test.py rename to tests/QtCore/qstring_buffer_protocol_test.py diff --git a/tests/qtcore/qstring_operator_test.py b/tests/QtCore/qstring_operator_test.py similarity index 100% rename from tests/qtcore/qstring_operator_test.py rename to tests/QtCore/qstring_operator_test.py diff --git a/tests/qtcore/qstring_test.py b/tests/QtCore/qstring_test.py similarity index 100% rename from tests/qtcore/qstring_test.py rename to tests/QtCore/qstring_test.py diff --git a/tests/qtcore/qstringlist_test.py b/tests/QtCore/qstringlist_test.py similarity index 100% rename from tests/qtcore/qstringlist_test.py rename to tests/QtCore/qstringlist_test.py diff --git a/tests/qtcore/qtext_codec_test.py b/tests/QtCore/qtext_codec_test.py similarity index 100% rename from tests/qtcore/qtext_codec_test.py rename to tests/QtCore/qtext_codec_test.py diff --git a/tests/qtcore/qtextstream_test.py b/tests/QtCore/qtextstream_test.py similarity index 100% rename from tests/qtcore/qtextstream_test.py rename to tests/QtCore/qtextstream_test.py diff --git a/tests/qtcore/qthread_prod_cons_test.py b/tests/QtCore/qthread_prod_cons_test.py similarity index 100% rename from tests/qtcore/qthread_prod_cons_test.py rename to tests/QtCore/qthread_prod_cons_test.py diff --git a/tests/qtcore/qthread_signal_test.py b/tests/QtCore/qthread_signal_test.py similarity index 100% rename from tests/qtcore/qthread_signal_test.py rename to tests/QtCore/qthread_signal_test.py diff --git a/tests/qtcore/qthread_test.py b/tests/QtCore/qthread_test.py similarity index 100% rename from tests/qtcore/qthread_test.py rename to tests/QtCore/qthread_test.py diff --git a/tests/qtcore/qtimer_singleshot_test.py b/tests/QtCore/qtimer_singleshot_test.py similarity index 100% rename from tests/qtcore/qtimer_singleshot_test.py rename to tests/QtCore/qtimer_singleshot_test.py diff --git a/tests/qtcore/qtimer_timeout_test.py b/tests/QtCore/qtimer_timeout_test.py similarity index 100% rename from tests/qtcore/qtimer_timeout_test.py rename to tests/QtCore/qtimer_timeout_test.py diff --git a/tests/qtcore/qtnamespace_test.py b/tests/QtCore/qtnamespace_test.py similarity index 100% rename from tests/qtcore/qtnamespace_test.py rename to tests/QtCore/qtnamespace_test.py diff --git a/tests/qtcore/quoteEnUS.txt b/tests/QtCore/quoteEnUS.txt similarity index 100% rename from tests/qtcore/quoteEnUS.txt rename to tests/QtCore/quoteEnUS.txt diff --git a/tests/qtcore/qurl_test.py b/tests/QtCore/qurl_test.py similarity index 100% rename from tests/qtcore/qurl_test.py rename to tests/QtCore/qurl_test.py diff --git a/tests/qtcore/qvariant_pyobject_test.py b/tests/QtCore/qvariant_pyobject_test.py similarity index 100% rename from tests/qtcore/qvariant_pyobject_test.py rename to tests/QtCore/qvariant_pyobject_test.py diff --git a/tests/qtcore/qvariant_test.py b/tests/QtCore/qvariant_test.py similarity index 100% rename from tests/qtcore/qvariant_test.py rename to tests/QtCore/qvariant_test.py diff --git a/tests/qtcore/resources.qrc b/tests/QtCore/resources.qrc similarity index 100% rename from tests/qtcore/resources.qrc rename to tests/QtCore/resources.qrc diff --git a/tests/qtcore/resources_mc.py b/tests/QtCore/resources_mc.py similarity index 100% rename from tests/qtcore/resources_mc.py rename to tests/QtCore/resources_mc.py diff --git a/tests/qtcore/static_method_test.py b/tests/QtCore/static_method_test.py similarity index 100% rename from tests/qtcore/static_method_test.py rename to tests/QtCore/static_method_test.py diff --git a/tests/qtcore/static_protected_methods_test.py b/tests/QtCore/static_protected_methods_test.py similarity index 100% rename from tests/qtcore/static_protected_methods_test.py rename to tests/QtCore/static_protected_methods_test.py diff --git a/tests/qtcore/thread_signals.py b/tests/QtCore/thread_signals.py similarity index 70% rename from tests/qtcore/thread_signals.py rename to tests/QtCore/thread_signals.py index e2b6673..9eea829 100644 --- a/tests/qtcore/thread_signals.py +++ b/tests/QtCore/thread_signals.py @@ -5,14 +5,13 @@ import unittest import os from tempfile import mkstemp -from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer +from PySide.QtCore import QObject, SIGNAL, QFile, QThread, QTimer, Qt from helper import UsesQCoreApplication class MyThread(QThread): def run(self): - self.emit(SIGNAL("test(const QString&)"), - "INdT - PySide"); + self.emit(SIGNAL("test(const QString&)"), "INdT - PySide"); class TestThreadSignal(UsesQCoreApplication): @@ -20,18 +19,13 @@ class TestThreadSignal(UsesQCoreApplication): def _callback(self, msg): self.assertEqual(msg, "INdT - PySide") self.__called__ = True - self._quit() - - def _quit(self): self.app.quit() def testThread(self): t = MyThread() - QObject.connect(t, SIGNAL("test(const QString&)"), - self._callback); - + QObject.connect(t, SIGNAL("test(const QString&)"), self._callback); t.start() - QTimer.singleShot(100, self._quit) + self.app.exec_() self.assert_(self.__called__); diff --git a/tests/qtcore/translation_test.py b/tests/QtCore/translation_test.py similarity index 100% rename from tests/qtcore/translation_test.py rename to tests/QtCore/translation_test.py diff --git a/tests/qtcore/translations/trans_latin.ts b/tests/QtCore/translations/trans_latin.ts similarity index 100% rename from tests/qtcore/translations/trans_latin.ts rename to tests/QtCore/translations/trans_latin.ts diff --git a/tests/qtcore/translations/trans_russian.ts b/tests/QtCore/translations/trans_russian.ts similarity index 100% rename from tests/qtcore/translations/trans_russian.ts rename to tests/QtCore/translations/trans_russian.ts diff --git a/tests/qtcore/unaryoperator_test.py b/tests/QtCore/unaryoperator_test.py similarity index 100% rename from tests/qtcore/unaryoperator_test.py rename to tests/QtCore/unaryoperator_test.py diff --git a/tests/qtcore/unicode_test.py b/tests/QtCore/unicode_test.py similarity index 100% rename from tests/qtcore/unicode_test.py rename to tests/QtCore/unicode_test.py diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt new file mode 100644 index 0000000..4896010 --- /dev/null +++ b/tests/QtDeclarative/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(qdeclarativenetwork_test.py FALSE) +PYSIDE_TEST(qdeclarativeview_test.py FALSE) diff --git a/tests/qtdeclarative/network.qml b/tests/QtDeclarative/network.qml similarity index 100% rename from tests/qtdeclarative/network.qml rename to tests/QtDeclarative/network.qml diff --git a/tests/qtdeclarative/qdeclarativenetwork_test.py b/tests/QtDeclarative/qdeclarativenetwork_test.py similarity index 100% rename from tests/qtdeclarative/qdeclarativenetwork_test.py rename to tests/QtDeclarative/qdeclarativenetwork_test.py diff --git a/tests/qtdeclarative/qdeclarativeview_test.py b/tests/QtDeclarative/qdeclarativeview_test.py similarity index 100% rename from tests/qtdeclarative/qdeclarativeview_test.py rename to tests/QtDeclarative/qdeclarativeview_test.py diff --git a/tests/qtdeclarative/view.qml b/tests/QtDeclarative/view.qml similarity index 100% rename from tests/qtdeclarative/view.qml rename to tests/QtDeclarative/view.qml diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt new file mode 100644 index 0000000..fb6d801 --- /dev/null +++ b/tests/QtGui/CMakeLists.txt @@ -0,0 +1,58 @@ +PYSIDE_TEST(add_action_test.py) +PYSIDE_TEST(customproxywidget_test.py) +PYSIDE_TEST(float_to_int_implicit_conversion_test.py) +PYSIDE_TEST(grandparent_method_test.py) +PYSIDE_TEST(hashabletype_test.py) +PYSIDE_TEST(keep_reference_test.py) +PYSIDE_TEST(missing_symbols_test.py) +PYSIDE_TEST(paint_event_test.py) +PYSIDE_TEST(parent_method_test.py) +PYSIDE_TEST(python_properties_test.py) +PYSIDE_TEST(qapplication_exit_segfault_test.py) +PYSIDE_TEST(qapplication_singleton_test.py) +PYSIDE_TEST(qapp_test.py) +PYSIDE_TEST(qbrush_test.py) +PYSIDE_TEST(qcolor_test.py) +PYSIDE_TEST(qdatastream_gui_operators_test.py) +PYSIDE_TEST(qfontdialog_test.py) +PYSIDE_TEST(qfontmetrics_test.py) +PYSIDE_TEST(qgraphicsitem_isblocked_test.py) +PYSIDE_TEST(qgraphicsitem_test.py) +PYSIDE_TEST(qgraphicsproxywidget_test.py) +PYSIDE_TEST(qgraphicsscene_test.py) +PYSIDE_TEST(qinputdialog_get_test.py) +PYSIDE_TEST(qitemselection_test.py) +PYSIDE_TEST(qlayout_ref_test.py) +PYSIDE_TEST(qlayout_test.py) +PYSIDE_TEST(qlcdnumber_test.py) +PYSIDE_TEST(qlistwidgetitem_test.py) +PYSIDE_TEST(qmainwindow_test.py) +PYSIDE_TEST(qmatrix_test.py) +PYSIDE_TEST(qmenuadd_test.py) +PYSIDE_TEST(qmenu_test.py) +PYSIDE_TEST(qobject_mi_test.py) +PYSIDE_TEST(qpainter_test.py) +PYSIDE_TEST(qpen_test.py) +PYSIDE_TEST(qpixmap_test.py) +PYSIDE_TEST(qpushbutton_test.py) +PYSIDE_TEST(qradialgradient_test.py) +PYSIDE_TEST(qregion_test.py) +PYSIDE_TEST(qshortcut_test.py) +PYSIDE_TEST(qstandarditemmodel_test.py) +PYSIDE_TEST(qstring_qkeysequence_test.py) +PYSIDE_TEST(qstyle_test.py) +PYSIDE_TEST(qtableview_test.py) +PYSIDE_TEST(qtabwidget_test.py) +PYSIDE_TEST(qtextedit_test.py) +PYSIDE_TEST(qtoolbar_test.py) +PYSIDE_TEST(qtoolbox_test.py) +PYSIDE_TEST(qvariant_test.py) +PYSIDE_TEST(qwidget_setlayout_test.py) +PYSIDE_TEST(qwidget_test.py TRUE) #Bug 237 +PYSIDE_TEST(reference_count_test.py) +PYSIDE_TEST(standardpixmap_test.py) +PYSIDE_TEST(timed_app_test.py) +PYSIDE_TEST(virtual_protected_inheritance_test.py) +PYSIDE_TEST(virtual_pure_override.py) +PYSIDE_TEST(wrong_return_test.py) +PYSIDE_TEST(x11_symbols.py) diff --git a/tests/qtgui/add_action_test.py b/tests/QtGui/add_action_test.py similarity index 100% rename from tests/qtgui/add_action_test.py rename to tests/QtGui/add_action_test.py diff --git a/tests/qtgui/customproxywidget_test.py b/tests/QtGui/customproxywidget_test.py similarity index 100% rename from tests/qtgui/customproxywidget_test.py rename to tests/QtGui/customproxywidget_test.py diff --git a/tests/qtgui/float_to_int_implicit_conversion_test.py b/tests/QtGui/float_to_int_implicit_conversion_test.py similarity index 100% rename from tests/qtgui/float_to_int_implicit_conversion_test.py rename to tests/QtGui/float_to_int_implicit_conversion_test.py diff --git a/tests/qtgui/grandparent_method_test.py b/tests/QtGui/grandparent_method_test.py similarity index 100% rename from tests/qtgui/grandparent_method_test.py rename to tests/QtGui/grandparent_method_test.py diff --git a/tests/qtgui/hashabletype_test.py b/tests/QtGui/hashabletype_test.py similarity index 100% rename from tests/qtgui/hashabletype_test.py rename to tests/QtGui/hashabletype_test.py diff --git a/tests/qtgui/keep_reference_test.py b/tests/QtGui/keep_reference_test.py similarity index 100% rename from tests/qtgui/keep_reference_test.py rename to tests/QtGui/keep_reference_test.py diff --git a/tests/qtgui/missing_symbols_test.py b/tests/QtGui/missing_symbols_test.py similarity index 100% rename from tests/qtgui/missing_symbols_test.py rename to tests/QtGui/missing_symbols_test.py diff --git a/tests/qtgui/paint_event_test.py b/tests/QtGui/paint_event_test.py similarity index 100% rename from tests/qtgui/paint_event_test.py rename to tests/QtGui/paint_event_test.py diff --git a/tests/qtgui/parent_method_test.py b/tests/QtGui/parent_method_test.py similarity index 100% rename from tests/qtgui/parent_method_test.py rename to tests/QtGui/parent_method_test.py diff --git a/tests/qtgui/python_properties_test.py b/tests/QtGui/python_properties_test.py similarity index 100% rename from tests/qtgui/python_properties_test.py rename to tests/QtGui/python_properties_test.py diff --git a/tests/qtgui/qapp_test.py b/tests/QtGui/qapp_test.py similarity index 100% rename from tests/qtgui/qapp_test.py rename to tests/QtGui/qapp_test.py diff --git a/tests/qtgui/qapplication_exit_segfault_test.py b/tests/QtGui/qapplication_exit_segfault_test.py similarity index 100% rename from tests/qtgui/qapplication_exit_segfault_test.py rename to tests/QtGui/qapplication_exit_segfault_test.py diff --git a/tests/qtgui/qapplication_singleton_test.py b/tests/QtGui/qapplication_singleton_test.py similarity index 100% rename from tests/qtgui/qapplication_singleton_test.py rename to tests/QtGui/qapplication_singleton_test.py diff --git a/tests/qtgui/qbrush_test.py b/tests/QtGui/qbrush_test.py similarity index 100% rename from tests/qtgui/qbrush_test.py rename to tests/QtGui/qbrush_test.py diff --git a/tests/qtgui/qcolor_test.py b/tests/QtGui/qcolor_test.py similarity index 100% rename from tests/qtgui/qcolor_test.py rename to tests/QtGui/qcolor_test.py diff --git a/tests/qtgui/qdatastream_gui_operators_test.py b/tests/QtGui/qdatastream_gui_operators_test.py similarity index 100% rename from tests/qtgui/qdatastream_gui_operators_test.py rename to tests/QtGui/qdatastream_gui_operators_test.py diff --git a/tests/qtgui/qfontdialog_test.py b/tests/QtGui/qfontdialog_test.py similarity index 100% rename from tests/qtgui/qfontdialog_test.py rename to tests/QtGui/qfontdialog_test.py diff --git a/tests/qtgui/qfontmetrics_test.py b/tests/QtGui/qfontmetrics_test.py similarity index 100% rename from tests/qtgui/qfontmetrics_test.py rename to tests/QtGui/qfontmetrics_test.py diff --git a/tests/qtgui/qgraphicsitem_isblocked_test.py b/tests/QtGui/qgraphicsitem_isblocked_test.py similarity index 100% rename from tests/qtgui/qgraphicsitem_isblocked_test.py rename to tests/QtGui/qgraphicsitem_isblocked_test.py diff --git a/tests/qtgui/qgraphicsitem_test.py b/tests/QtGui/qgraphicsitem_test.py similarity index 100% rename from tests/qtgui/qgraphicsitem_test.py rename to tests/QtGui/qgraphicsitem_test.py diff --git a/tests/qtgui/qgraphicsproxywidget_test.py b/tests/QtGui/qgraphicsproxywidget_test.py similarity index 100% rename from tests/qtgui/qgraphicsproxywidget_test.py rename to tests/QtGui/qgraphicsproxywidget_test.py diff --git a/tests/qtgui/qgraphicsscene_test.py b/tests/QtGui/qgraphicsscene_test.py similarity index 100% rename from tests/qtgui/qgraphicsscene_test.py rename to tests/QtGui/qgraphicsscene_test.py diff --git a/tests/qtgui/qinputdialog_get_test.py b/tests/QtGui/qinputdialog_get_test.py similarity index 100% rename from tests/qtgui/qinputdialog_get_test.py rename to tests/QtGui/qinputdialog_get_test.py diff --git a/tests/qtgui/qitemselection_test.py b/tests/QtGui/qitemselection_test.py similarity index 100% rename from tests/qtgui/qitemselection_test.py rename to tests/QtGui/qitemselection_test.py diff --git a/tests/qtgui/qlayout_ref_test.py b/tests/QtGui/qlayout_ref_test.py similarity index 100% rename from tests/qtgui/qlayout_ref_test.py rename to tests/QtGui/qlayout_ref_test.py diff --git a/tests/qtgui/qlayout_test.py b/tests/QtGui/qlayout_test.py similarity index 100% rename from tests/qtgui/qlayout_test.py rename to tests/QtGui/qlayout_test.py diff --git a/tests/qtgui/qlcdnumber_test.py b/tests/QtGui/qlcdnumber_test.py similarity index 100% rename from tests/qtgui/qlcdnumber_test.py rename to tests/QtGui/qlcdnumber_test.py diff --git a/tests/qtgui/qlistwidgetitem_test.py b/tests/QtGui/qlistwidgetitem_test.py similarity index 100% rename from tests/qtgui/qlistwidgetitem_test.py rename to tests/QtGui/qlistwidgetitem_test.py diff --git a/tests/qtgui/qmainwindow_test.py b/tests/QtGui/qmainwindow_test.py similarity index 100% rename from tests/qtgui/qmainwindow_test.py rename to tests/QtGui/qmainwindow_test.py diff --git a/tests/qtgui/qmatrix_test.py b/tests/QtGui/qmatrix_test.py similarity index 100% rename from tests/qtgui/qmatrix_test.py rename to tests/QtGui/qmatrix_test.py diff --git a/tests/qtgui/qmenu_test.py b/tests/QtGui/qmenu_test.py similarity index 100% rename from tests/qtgui/qmenu_test.py rename to tests/QtGui/qmenu_test.py diff --git a/tests/qtgui/qmenuadd_test.py b/tests/QtGui/qmenuadd_test.py similarity index 100% rename from tests/qtgui/qmenuadd_test.py rename to tests/QtGui/qmenuadd_test.py diff --git a/tests/qtgui/qobject_mi_test.py b/tests/QtGui/qobject_mi_test.py similarity index 100% rename from tests/qtgui/qobject_mi_test.py rename to tests/QtGui/qobject_mi_test.py diff --git a/tests/qtgui/qpainter_test.py b/tests/QtGui/qpainter_test.py similarity index 100% rename from tests/qtgui/qpainter_test.py rename to tests/QtGui/qpainter_test.py diff --git a/tests/qtgui/qpen_test.py b/tests/QtGui/qpen_test.py similarity index 100% rename from tests/qtgui/qpen_test.py rename to tests/QtGui/qpen_test.py diff --git a/tests/qtgui/qpixmap_test.py b/tests/QtGui/qpixmap_test.py similarity index 100% rename from tests/qtgui/qpixmap_test.py rename to tests/QtGui/qpixmap_test.py diff --git a/tests/qtgui/qpushbutton_test.py b/tests/QtGui/qpushbutton_test.py similarity index 100% rename from tests/qtgui/qpushbutton_test.py rename to tests/QtGui/qpushbutton_test.py diff --git a/tests/qtgui/qradialgradient_test.py b/tests/QtGui/qradialgradient_test.py similarity index 100% rename from tests/qtgui/qradialgradient_test.py rename to tests/QtGui/qradialgradient_test.py diff --git a/tests/qtgui/qregion_test.py b/tests/QtGui/qregion_test.py similarity index 100% rename from tests/qtgui/qregion_test.py rename to tests/QtGui/qregion_test.py diff --git a/tests/qtgui/qshortcut_test.py b/tests/QtGui/qshortcut_test.py similarity index 100% rename from tests/qtgui/qshortcut_test.py rename to tests/QtGui/qshortcut_test.py diff --git a/tests/qtgui/qstandarditemmodel_test.py b/tests/QtGui/qstandarditemmodel_test.py similarity index 100% rename from tests/qtgui/qstandarditemmodel_test.py rename to tests/QtGui/qstandarditemmodel_test.py diff --git a/tests/qtgui/qstring_qkeysequence_test.py b/tests/QtGui/qstring_qkeysequence_test.py similarity index 100% rename from tests/qtgui/qstring_qkeysequence_test.py rename to tests/QtGui/qstring_qkeysequence_test.py diff --git a/tests/qtgui/qstyle_test.py b/tests/QtGui/qstyle_test.py similarity index 100% rename from tests/qtgui/qstyle_test.py rename to tests/QtGui/qstyle_test.py diff --git a/tests/qtgui/qtableview_test.py b/tests/QtGui/qtableview_test.py similarity index 100% rename from tests/qtgui/qtableview_test.py rename to tests/QtGui/qtableview_test.py diff --git a/tests/qtgui/qtabwidget_test.py b/tests/QtGui/qtabwidget_test.py similarity index 100% rename from tests/qtgui/qtabwidget_test.py rename to tests/QtGui/qtabwidget_test.py diff --git a/tests/qtgui/qtextedit_test.py b/tests/QtGui/qtextedit_test.py similarity index 100% rename from tests/qtgui/qtextedit_test.py rename to tests/QtGui/qtextedit_test.py diff --git a/tests/qtgui/qtoolbar_test.py b/tests/QtGui/qtoolbar_test.py similarity index 100% rename from tests/qtgui/qtoolbar_test.py rename to tests/QtGui/qtoolbar_test.py diff --git a/tests/qtgui/qtoolbox_test.py b/tests/QtGui/qtoolbox_test.py similarity index 100% rename from tests/qtgui/qtoolbox_test.py rename to tests/QtGui/qtoolbox_test.py diff --git a/tests/qtgui/qvariant_test.py b/tests/QtGui/qvariant_test.py similarity index 100% rename from tests/qtgui/qvariant_test.py rename to tests/QtGui/qvariant_test.py diff --git a/tests/qtgui/qwidget_setlayout_test.py b/tests/QtGui/qwidget_setlayout_test.py similarity index 100% rename from tests/qtgui/qwidget_setlayout_test.py rename to tests/QtGui/qwidget_setlayout_test.py diff --git a/tests/qtgui/qwidget_test.py b/tests/QtGui/qwidget_test.py similarity index 100% rename from tests/qtgui/qwidget_test.py rename to tests/QtGui/qwidget_test.py diff --git a/tests/qtgui/reference_count_test.py b/tests/QtGui/reference_count_test.py similarity index 100% rename from tests/qtgui/reference_count_test.py rename to tests/QtGui/reference_count_test.py diff --git a/tests/qtgui/sample.png b/tests/QtGui/sample.png similarity index 100% rename from tests/qtgui/sample.png rename to tests/QtGui/sample.png diff --git a/tests/qtgui/standardpixmap_test.py b/tests/QtGui/standardpixmap_test.py similarity index 100% rename from tests/qtgui/standardpixmap_test.py rename to tests/QtGui/standardpixmap_test.py diff --git a/tests/qtgui/timed_app_test.py b/tests/QtGui/timed_app_test.py similarity index 100% rename from tests/qtgui/timed_app_test.py rename to tests/QtGui/timed_app_test.py diff --git a/tests/qtgui/virtual_protected_inheritance_test.py b/tests/QtGui/virtual_protected_inheritance_test.py similarity index 100% rename from tests/qtgui/virtual_protected_inheritance_test.py rename to tests/QtGui/virtual_protected_inheritance_test.py diff --git a/tests/qtgui/virtual_pure_override.py b/tests/QtGui/virtual_pure_override.py similarity index 100% rename from tests/qtgui/virtual_pure_override.py rename to tests/QtGui/virtual_pure_override.py diff --git a/tests/qtgui/wrong_return_test.py b/tests/QtGui/wrong_return_test.py similarity index 100% rename from tests/qtgui/wrong_return_test.py rename to tests/QtGui/wrong_return_test.py diff --git a/tests/qtgui/x11_symbols.py b/tests/QtGui/x11_symbols.py similarity index 100% rename from tests/qtgui/x11_symbols.py rename to tests/QtGui/x11_symbols.py diff --git a/tests/QtHelp/CMakeLists.txt b/tests/QtHelp/CMakeLists.txt new file mode 100644 index 0000000..d0ba2d8 --- /dev/null +++ b/tests/QtHelp/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(help_test.py) diff --git a/tests/qthelp/help_test.py b/tests/QtHelp/help_test.py similarity index 100% rename from tests/qthelp/help_test.py rename to tests/QtHelp/help_test.py diff --git a/tests/QtMaemo5/CMakeLists.txt b/tests/QtMaemo5/CMakeLists.txt new file mode 100644 index 0000000..73bb316 --- /dev/null +++ b/tests/QtMaemo5/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(pickselector_test.py) +PYSIDE_TEST(qmaemo5import_test.py) diff --git a/tests/qtmaemo5/pickselector_test.py b/tests/QtMaemo5/pickselector_test.py similarity index 100% rename from tests/qtmaemo5/pickselector_test.py rename to tests/QtMaemo5/pickselector_test.py diff --git a/tests/qtmaemo5/qmaemo5import_test.py b/tests/QtMaemo5/qmaemo5import_test.py similarity index 100% rename from tests/qtmaemo5/qmaemo5import_test.py rename to tests/QtMaemo5/qmaemo5import_test.py diff --git a/tests/QtMultimedia/CMakeLists.txt b/tests/QtMultimedia/CMakeLists.txt new file mode 100644 index 0000000..62150eb --- /dev/null +++ b/tests/QtMultimedia/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(audio_test.py) diff --git a/tests/qtmultimedia/audio_test.py b/tests/QtMultimedia/audio_test.py similarity index 100% rename from tests/qtmultimedia/audio_test.py rename to tests/QtMultimedia/audio_test.py diff --git a/tests/QtNetwork/CMakeLists.txt b/tests/QtNetwork/CMakeLists.txt new file mode 100644 index 0000000..cae1470 --- /dev/null +++ b/tests/QtNetwork/CMakeLists.txt @@ -0,0 +1,4 @@ +PYSIDE_TEST(accessManager_test.py) +PYSIDE_TEST(http_test.py) +PYSIDE_TEST(tcpserver_test.py) +PYSIDE_TEST(udpsocket_test.py) diff --git a/tests/qtnetwork/accessManager_test.py b/tests/QtNetwork/accessManager_test.py similarity index 100% rename from tests/qtnetwork/accessManager_test.py rename to tests/QtNetwork/accessManager_test.py diff --git a/tests/qtnetwork/http_test.py b/tests/QtNetwork/http_test.py similarity index 100% rename from tests/qtnetwork/http_test.py rename to tests/QtNetwork/http_test.py diff --git a/tests/qtnetwork/tcpserver_test.py b/tests/QtNetwork/tcpserver_test.py similarity index 100% rename from tests/qtnetwork/tcpserver_test.py rename to tests/QtNetwork/tcpserver_test.py diff --git a/tests/qtnetwork/udpsocket_test.py b/tests/QtNetwork/udpsocket_test.py similarity index 100% rename from tests/qtnetwork/udpsocket_test.py rename to tests/QtNetwork/udpsocket_test.py diff --git a/tests/QtOpenGL/CMakeLists.txt b/tests/QtOpenGL/CMakeLists.txt new file mode 100644 index 0000000..3064edf --- /dev/null +++ b/tests/QtOpenGL/CMakeLists.txt @@ -0,0 +1,3 @@ +if(${QTVERSION} VERSION_GREATER 4.6.9) + PYSIDE_TEST(qglbuffer_test.py) +endif() diff --git a/tests/qtopengl/qglbuffer_test.py b/tests/QtOpenGL/qglbuffer_test.py similarity index 100% rename from tests/qtopengl/qglbuffer_test.py rename to tests/QtOpenGL/qglbuffer_test.py diff --git a/tests/QtScript/CMakeLists.txt b/tests/QtScript/CMakeLists.txt new file mode 100644 index 0000000..b76a262 --- /dev/null +++ b/tests/QtScript/CMakeLists.txt @@ -0,0 +1,3 @@ +PYSIDE_TEST(base_test.py) +PYSIDE_TEST(engine_test.py) +PYSIDE_TEST(test_base.py) diff --git a/tests/qtscript/base_test.py b/tests/QtScript/base_test.py similarity index 100% rename from tests/qtscript/base_test.py rename to tests/QtScript/base_test.py diff --git a/tests/qtscript/engine_test.py b/tests/QtScript/engine_test.py similarity index 100% rename from tests/qtscript/engine_test.py rename to tests/QtScript/engine_test.py diff --git a/tests/qtscript/test_base.py b/tests/QtScript/test_base.py similarity index 100% rename from tests/qtscript/test_base.py rename to tests/QtScript/test_base.py diff --git a/tests/QtScriptTools/CMakeLists.txt b/tests/QtScriptTools/CMakeLists.txt new file mode 100644 index 0000000..ee22737 --- /dev/null +++ b/tests/QtScriptTools/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(debugger_test.py) diff --git a/tests/qtscripttools/debugger_test.py b/tests/QtScriptTools/debugger_test.py similarity index 100% rename from tests/qtscripttools/debugger_test.py rename to tests/QtScriptTools/debugger_test.py diff --git a/tests/QtSql/CMakeLists.txt b/tests/QtSql/CMakeLists.txt new file mode 100644 index 0000000..a944691 --- /dev/null +++ b/tests/QtSql/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(qsqldatabaseandqueries_test.py) diff --git a/tests/qtsql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py similarity index 100% rename from tests/qtsql/qsqldatabaseandqueries_test.py rename to tests/QtSql/qsqldatabaseandqueries_test.py diff --git a/tests/QtSvg/CMakeLists.txt b/tests/QtSvg/CMakeLists.txt new file mode 100644 index 0000000..6a9c9d5 --- /dev/null +++ b/tests/QtSvg/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(qsvggenerator_test.py) diff --git a/tests/qtsvg/qsvggenerator_test.py b/tests/QtSvg/qsvggenerator_test.py similarity index 100% rename from tests/qtsvg/qsvggenerator_test.py rename to tests/QtSvg/qsvggenerator_test.py diff --git a/tests/QtTest/CMakeLists.txt b/tests/QtTest/CMakeLists.txt new file mode 100644 index 0000000..b1bdac0 --- /dev/null +++ b/tests/QtTest/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(click_test.py) +PYSIDE_TEST(eventfilter_test.py) diff --git a/tests/qttest/click_test.py b/tests/QtTest/click_test.py similarity index 100% rename from tests/qttest/click_test.py rename to tests/QtTest/click_test.py diff --git a/tests/qttest/eventfilter_test.py b/tests/QtTest/eventfilter_test.py similarity index 100% rename from tests/qttest/eventfilter_test.py rename to tests/QtTest/eventfilter_test.py diff --git a/tests/QtUiTools/CMakeLists.txt b/tests/QtUiTools/CMakeLists.txt new file mode 100644 index 0000000..9118b5b --- /dev/null +++ b/tests/QtUiTools/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(uiloader_test.py) +PYSIDE_TEST(ui_test.py) diff --git a/tests/qtuitools/test.ui b/tests/QtUiTools/test.ui similarity index 100% rename from tests/qtuitools/test.ui rename to tests/QtUiTools/test.ui diff --git a/tests/qtuitools/ui_test.py b/tests/QtUiTools/ui_test.py similarity index 100% rename from tests/qtuitools/ui_test.py rename to tests/QtUiTools/ui_test.py diff --git a/tests/qtuitools/uiloader_test.py b/tests/QtUiTools/uiloader_test.py similarity index 100% rename from tests/qtuitools/uiloader_test.py rename to tests/QtUiTools/uiloader_test.py diff --git a/tests/QtWebKit/CMakeLists.txt b/tests/QtWebKit/CMakeLists.txt new file mode 100644 index 0000000..5472865 --- /dev/null +++ b/tests/QtWebKit/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(webpage_test.py) +PYSIDE_TEST(webview_test.py) diff --git a/tests/qtwebkit/fox.html b/tests/QtWebKit/fox.html similarity index 100% rename from tests/qtwebkit/fox.html rename to tests/QtWebKit/fox.html diff --git a/tests/qtwebkit/webpage_test.py b/tests/QtWebKit/webpage_test.py similarity index 100% rename from tests/qtwebkit/webpage_test.py rename to tests/QtWebKit/webpage_test.py diff --git a/tests/qtwebkit/webview_test.py b/tests/QtWebKit/webview_test.py similarity index 100% rename from tests/qtwebkit/webview_test.py rename to tests/QtWebKit/webview_test.py diff --git a/tests/QtXml/CMakeLists.txt b/tests/QtXml/CMakeLists.txt new file mode 100644 index 0000000..2c21bf8 --- /dev/null +++ b/tests/QtXml/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(qdomdocument_test.py) +PYSIDE_TEST(qxmlsimplereader_test.py) diff --git a/tests/qtxml/qdomdocument_test.py b/tests/QtXml/qdomdocument_test.py similarity index 100% rename from tests/qtxml/qdomdocument_test.py rename to tests/QtXml/qdomdocument_test.py diff --git a/tests/qtxml/qxmlsimplereader_test.py b/tests/QtXml/qxmlsimplereader_test.py similarity index 100% rename from tests/qtxml/qxmlsimplereader_test.py rename to tests/QtXml/qxmlsimplereader_test.py diff --git a/tests/QtXmlPatterns/CMakeLists.txt b/tests/QtXmlPatterns/CMakeLists.txt new file mode 100644 index 0000000..7f570f1 --- /dev/null +++ b/tests/QtXmlPatterns/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(import_test.py) diff --git a/tests/qtxmlpatterns/import_test.py b/tests/QtXmlPatterns/import_test.py similarity index 100% rename from tests/qtxmlpatterns/import_test.py rename to tests/QtXmlPatterns/import_test.py diff --git a/tests/phonon/CMakeLists.txt b/tests/phonon/CMakeLists.txt new file mode 100644 index 0000000..1174709 --- /dev/null +++ b/tests/phonon/CMakeLists.txt @@ -0,0 +1,2 @@ +PYSIDE_TEST(basic_playing_test.py) +PYSIDE_TEST(capabilities_test.py) diff --git a/tests/qtgui/qlabel_pixmap_refcount.py b/tests/qtgui/qlabel_pixmap_refcount.py deleted file mode 100644 index db8783e..0000000 --- a/tests/qtgui/qlabel_pixmap_refcount.py +++ /dev/null @@ -1,46 +0,0 @@ - -'''Test cases for QLabel->pixmap refcount control''' - -import unittest -import sys - - -from helper import UsesQApplication -from PySide.QtGui import QApplication, QLabel, QPixmap - -class QLabelTest(UsesQApplication): - '''Test case for constructor of QBrush''' - - def testDestroyOwner(self): - p = QPixmap() - l = QLabel() - l.setPixmap(p) - - del p - - p1 = l.pixmap() - self.assertEqual(sys.getrefcount(p1), 2) - self.assertEqual(sys.getrefcount(l), 2) - - del l - self.assertEqual(sys.getrefcount(p1), 2) - - - def testRefCount(self): - p = QPixmap() - l = QLabel() - l.setPixmap(p) - - del p - - p1 = l.pixmap() - self.assertEqual(sys.getrefcount(p1), 2) - - p2 = l.pixmap() - self.assertEqual(sys.getrefcount(p2), 3) - - p3 = l.pixmap() - self.assertEqual(sys.getrefcount(p3), 4) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/run_test.sh b/tests/run_test.sh index 8671ce3..363fae5 100755 --- a/tests/run_test.sh +++ b/tests/run_test.sh @@ -1,13 +1,13 @@ -#!/usr/bin/python +#!/bin/sh # This is a nasty workaround of a CTest limitation # of setting the environment variables for the test. # $1: LD_LIBRARY_PATH -# $2: $PYTHON_PATH +# $2: $PYTHONPATH # $3: python executable # $4: test file -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$1 -export PYTHONPATH=$PYTHONPATH:$2 +export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH +export PYTHONPATH=$2:$PYTHONPATH $3 $4 diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt new file mode 100644 index 0000000..3e59684 --- /dev/null +++ b/tests/signals/CMakeLists.txt @@ -0,0 +1,32 @@ +PYSIDE_TEST(args_dont_match_test.py) +PYSIDE_TEST(decorators_test.py) +PYSIDE_TEST(invalid_callback_test.py) +PYSIDE_TEST(lambda_gui_test.py) +PYSIDE_TEST(lambda_test.py) +PYSIDE_TEST(multiple_connections_gui_test.py) +PYSIDE_TEST(multiple_connections_test.py) +PYSIDE_TEST(pysignal_test.py) +PYSIDE_TEST(qobject_destroyed_test.py) +PYSIDE_TEST(qobject_receivers_test.py) +PYSIDE_TEST(qobject_sender_test.py) +PYSIDE_TEST(ref01_test.py) +PYSIDE_TEST(ref02_test.py) +PYSIDE_TEST(ref03_test.py) +PYSIDE_TEST(ref04_test.py) +PYSIDE_TEST(ref05_test.py) +PYSIDE_TEST(ref06_test.py) +PYSIDE_TEST(segfault_proxyparent_test.py) +PYSIDE_TEST(self_connect_test.py) +PYSIDE_TEST(short_circuit_test.py) +PYSIDE_TEST(signal2signal_connect_test.py) +PYSIDE_TEST(signal_autoconnect_test.py) +PYSIDE_TEST(signal_connectiontype_support.py) +PYSIDE_TEST(signal_emission_gui_test.py) +PYSIDE_TEST(signal_emission_test.py) +PYSIDE_TEST(signal_func_test.py) +PYSIDE_TEST(signal_manager_refcount_test.py) +PYSIDE_TEST(signal_object_test.py) +PYSIDE_TEST(signal_with_primitive_type_test.py) +PYSIDE_TEST(slot_reference_count_test.py) +PYSIDE_TEST(static_metaobject_test.py) +PYSIDE_TEST(upstream_segfault_test.py) diff --git a/tests/signals/args_dont_match_test.py b/tests/signals/args_dont_match_test.py old mode 100644 new mode 100755 index b81c568..2521167 --- a/tests/signals/args_dont_match_test.py +++ b/tests/signals/args_dont_match_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python import unittest from PySide.QtCore import * diff --git a/tests/signals/decorators_test.py b/tests/signals/decorators_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/invalid_callback_test.py b/tests/signals/invalid_callback_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/lambda_gui_test.py b/tests/signals/lambda_gui_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/lambda_test.py b/tests/signals/lambda_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/multiple_connections_gui_test.py b/tests/signals/multiple_connections_gui_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/multiple_connections_test.py b/tests/signals/multiple_connections_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/pysignal_test.py b/tests/signals/pysignal_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/qobject_destroyed_test.py b/tests/signals/qobject_destroyed_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/qobject_receivers_test.py b/tests/signals/qobject_receivers_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/segfault_proxyparent_test.py b/tests/signals/segfault_proxyparent_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/self_connect_test.py b/tests/signals/self_connect_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/short_circuit_test.py b/tests/signals/short_circuit_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal2signal_connect_test.py b/tests/signals/signal2signal_connect_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_autoconnect_test.py b/tests/signals/signal_autoconnect_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_connectiontype_support.py b/tests/signals/signal_connectiontype_support.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_emission_gui_test.py b/tests/signals/signal_emission_gui_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_emission_test.py b/tests/signals/signal_emission_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_func_test.py b/tests/signals/signal_func_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_manager_refcount_test.py b/tests/signals/signal_manager_refcount_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/signal_with_primitive_type_test.py b/tests/signals/signal_with_primitive_type_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/slot_reference_count_test.py b/tests/signals/slot_reference_count_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/static_metaobject_test.py b/tests/signals/static_metaobject_test.py old mode 100644 new mode 100755 diff --git a/tests/signals/upstream_segfault_test.py b/tests/signals/upstream_segfault_test.py old mode 100644 new mode 100755 From 0f33e1d3d84f9c1d8540a64ab9ba8dbc0c73d0d9 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Tue, 8 Jun 2010 10:47:27 -0300 Subject: [PATCH 0004/1129] Updating QEasingCurve and QTest to compile for ARMEL platforms. --- PySide/QtCore/typesystem_core.xml | 9 ++++----- PySide/QtTest/typesystem_test.xml | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 9711e2d..3b3a46b 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2663,13 +2663,12 @@ + + - - - diff --git a/PySide/QtTest/typesystem_test.xml b/PySide/QtTest/typesystem_test.xml index cbf8add..d1057b2 100644 --- a/PySide/QtTest/typesystem_test.xml +++ b/PySide/QtTest/typesystem_test.xml @@ -6,6 +6,8 @@ + + From 1a698a7e954fbf005f46aadda2300f475bfec292 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Tue, 8 Jun 2010 15:47:21 -0300 Subject: [PATCH 0005/1129] Updating QtMaemo5 dependecies inside CMakeLists file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Marcelo Lira , Renato Araújo --- PySide/QtMaemo5/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/QtMaemo5/CMakeLists.txt b/PySide/QtMaemo5/CMakeLists.txt index ac85ea4..9251cc3 100644 --- a/PySide/QtMaemo5/CMakeLists.txt +++ b/PySide/QtMaemo5/CMakeLists.txt @@ -46,7 +46,7 @@ target_link_libraries(QtMaemo5 ${QT_QTGUI_LIBRARY} ${QT_QTMAEMO5_LIBRARY}) -#add_dependencies(QtMaemo5) +add_dependencies(QtMaemo5 QtGui) # install install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMaemo5${CMAKE_DEBUG_POSTFIX}.so From cf6e5f16687a0b28677a5c4ff035eebc5424272d Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 8 Jun 2010 17:41:32 -0300 Subject: [PATCH 0006/1129] Created unit test for QDate, QTime, QDateTime, QUrl hash function. Reviewer: Marcelo Lira , Luciano Wolf --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/hash_test.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/QtCore/hash_test.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 536d408..eef6ffe 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -3,6 +3,7 @@ PYSIDE_TEST(buffer_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deletelater_test.py) PYSIDE_TEST(duck_punching_test.py) +PYSIDE_TEST(hash_test.py) PYSIDE_TEST(missing_symbols_test.py) PYSIDE_TEST(qabs_test.py) PYSIDE_TEST(qabstracttransition_test.py) diff --git a/tests/QtCore/hash_test.py b/tests/QtCore/hash_test.py new file mode 100644 index 0000000..4fdecca --- /dev/null +++ b/tests/QtCore/hash_test.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +import unittest +from PySide.QtCore import QDate, QDateTime, QTime, QUrl + +class HashTest(unittest.TestCase): + def testInsert(self): + myHash = {} + qdate = QDate.currentDate() + qdatetime = QDateTime.currentDateTime() + qtime = QTime.currentTime() + qurl = QUrl("http://www.pyside.org") + + myHash[qdate] = "QDate" + myHash[qdatetime] = "QDateTime" + myHash[qtime] = "QTime" + myHash[qurl] = "QUrl" + + self.assertEqual(myHash[qdate], "QDate") + self.assertEqual(myHash[qdatetime], "QDateTime") + self.assertEqual(myHash[qtime], "QTime") + self.assertEqual(myHash[qurl], "QUrl") + + +if __name__ == '__main__': + unittest.main() From bf8a60db4cdbfc3e7c9c98778b219e9c83746d44 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 8 Jun 2010 17:42:43 -0300 Subject: [PATCH 0007/1129] Created support to hash objects with type QDate, QTime, QDateTime, QUrl. Reviewer: Marcelo Lira , Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 8 ++++---- libpyside/pyside.h | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 3b3a46b..d68addd 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -992,7 +992,7 @@ - + @@ -1024,7 +1024,7 @@ - + @@ -1063,7 +1063,7 @@ - + @@ -1681,7 +1681,7 @@ - + diff --git a/libpyside/pyside.h b/libpyside/pyside.h index 2048265..52aeec1 100644 --- a/libpyside/pyside.h +++ b/libpyside/pyside.h @@ -44,6 +44,15 @@ namespace PySide PYSIDE_API void init(PyObject *module); +/** + * Hash function used to enable hash on objects not supported on native Qt library which has toString function. + */ +template +inline uint hash(const T& value) +{ + return qHash(value.toString()); +} + /** * If the type \p T was registered on Qt meta type system with Q_DECLARE_METATYPE macro, this class will initialize * the meta type. From 009b6a8e9a70db61ad4b9d1021dd2ee4f9cdb650 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 9 Jun 2010 14:01:51 -0300 Subject: [PATCH 0008/1129] Fix cmake detection of phonon on MacOSX. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Luciano Wolf Renato Araújo --- PySide/phonon/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PySide/phonon/CMakeLists.txt b/PySide/phonon/CMakeLists.txt index 01b1f6a..7392063 100644 --- a/PySide/phonon/CMakeLists.txt +++ b/PySide/phonon/CMakeLists.txt @@ -1,5 +1,10 @@ project(phonon) +# workaround for a cmake bug under MacOSX, it finds phonon but not the include path +if (NOT QT_PHONON_INCLUDE_DIR AND CMAKE_HOST_APPLE) + set(QT_PHONON_INCLUDE_DIR "${QT_LIBRARY_DIR}/phonon.framework/Headers") +endif() + set(phonon_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_abstractaudiooutput_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_abstractmediastream_wrapper.cpp From 1a40cc79df157bec25a3439f8fb08c4809651146 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 9 Jun 2010 18:18:22 -0300 Subject: [PATCH 0009/1129] Fix compilation of QTest bindings on MacOSX. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtTest/typesystem_test.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PySide/QtTest/typesystem_test.xml b/PySide/QtTest/typesystem_test.xml index d1057b2..bc447ee 100644 --- a/PySide/QtTest/typesystem_test.xml +++ b/PySide/QtTest/typesystem_test.xml @@ -18,6 +18,19 @@ + + + + + + + + + + + + + From b2bf4f18cc7182384800914118dc66dd087cadf9 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 9 Jun 2010 18:13:23 -0300 Subject: [PATCH 0010/1129] Rename necessary arguments on QtCore typesystem. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index d68addd..8924fa4 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1079,6 +1079,16 @@ + + + + + + + + + + @@ -1195,7 +1205,11 @@ - + + + + + @@ -1275,12 +1289,18 @@ + + + // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %CPPSELF, %3, %4)); + + + // %FUNCTION_NAME() - disable generation of function call. %PYARG_0 = %CONVERTTOPYTHON[bool](qobjectConnect(%1, %2, %3, %4, %5)); @@ -1289,6 +1309,7 @@ + @@ -1299,6 +1320,7 @@ + @@ -1308,6 +1330,7 @@ + @@ -1433,6 +1456,12 @@ + + + + + + From 24a944590663582df72aefd1929ec19ba3c6414f Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Wed, 9 Jun 2010 19:34:40 -0300 Subject: [PATCH 0011/1129] Apply "rename to" tag to QtGui methods. Reviewer: Hugo Parente Lima , Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index f971f25..fac9f56 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -516,6 +516,11 @@ + + + + + @@ -780,6 +785,11 @@ + + + + + @@ -818,6 +828,11 @@ + + + + + @@ -2457,26 +2472,47 @@ + + + addLayoutOwnership(%CPPSELF, %1); + + + addLayoutOwnership(%CPPSELF, %1); + + + addLayoutOwnership(%CPPSELF, %1); + + + addLayoutOwnership(%CPPSELF, %1); + + + + + + + + + addLayoutOwnership(%CPPSELF, %1); @@ -3663,6 +3699,9 @@ + + + @@ -4077,6 +4116,19 @@ + + + + + + + + + + + + + @@ -4628,4 +4680,5 @@ + From e39bfefde9edda662f51eeaf9a482f209c7f1217 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 3 Jun 2010 15:34:17 -0300 Subject: [PATCH 0012/1129] Remove wrapper for classes: QString, QStringRef, QLatin1String, QStringMatcher, QChar and QLatin1Char. --- PySide/QtCore/CMakeLists.txt | 7 - PySide/QtCore/glue/qstring_bufferprotocol.cpp | 43 -- PySide/QtCore/glue/qstring_hashfunc.cpp | 6 - PySide/QtCore/qchar_conversions.h | 42 +- PySide/QtCore/qstring_conversions.h | 128 +++--- PySide/QtCore/qstringlist_conversions.h | 16 +- PySide/QtCore/qstringref_conversions.h | 19 + PySide/QtCore/typesystem_core.xml | 371 ++---------------- tests/QtCore/CMakeLists.txt | 6 - tests/QtCore/buffer_test.py | 13 - tests/QtCore/qbytearray_operator_iadd_test.py | 11 +- tests/QtCore/qbytearray_operator_test.py | 6 +- tests/QtCore/qchar_test.py | 59 --- tests/QtCore/qdatastream_test.py | 3 +- tests/QtCore/qenum_test.py | 4 +- tests/QtCore/qlatin1string_test.py | 21 - tests/QtCore/qobject_property_test.py | 8 +- tests/QtCore/qstring_buffer_protocol_test.py | 20 - tests/QtCore/qstring_operator_test.py | 161 -------- tests/QtCore/qstring_test.py | 176 +-------- tests/QtCore/qstringlist_test.py | 171 -------- tests/QtCore/qtextstream_test.py | 16 +- tests/QtCore/qvariant_pyobject_test.py | 7 +- tests/QtCore/qvariant_test.py | 19 +- tests/QtCore/translation_test.py | 4 +- tests/QtGui/qinputdialog_get_test.py | 2 +- tests/QtGui/qpixmap_test.py | 2 +- tests/QtGui/qstring_qkeysequence_test.py | 15 +- tests/QtSql/qsqldatabaseandqueries_test.py | 4 +- tests/phonon/capabilities_test.py | 4 +- tests/signals/decorators_test.py | 4 +- tests/signals/signal_object_test.py | 8 +- 32 files changed, 187 insertions(+), 1189 deletions(-) delete mode 100644 PySide/QtCore/glue/qstring_bufferprotocol.cpp delete mode 100644 PySide/QtCore/glue/qstring_hashfunc.cpp create mode 100644 PySide/QtCore/qstringref_conversions.h delete mode 100644 tests/QtCore/buffer_test.py delete mode 100644 tests/QtCore/qchar_test.py delete mode 100644 tests/QtCore/qlatin1string_test.py delete mode 100755 tests/QtCore/qstring_buffer_protocol_test.py delete mode 100644 tests/QtCore/qstring_operator_test.py delete mode 100644 tests/QtCore/qstringlist_test.py diff --git a/PySide/QtCore/CMakeLists.txt b/PySide/QtCore/CMakeLists.txt index 7572519..bbe8ba7 100644 --- a/PySide/QtCore/CMakeLists.txt +++ b/PySide/QtCore/CMakeLists.txt @@ -49,7 +49,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbitarray_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbuffer_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbytearray_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qbytearraymatcher_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qchar_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qchildevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qcoreapplication_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qcryptographichash_wrapper.cpp @@ -69,8 +68,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qfsfileengine_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qgenericargument_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qgenericreturnargument_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qiodevice_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlatin1char_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlatin1string_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlibraryinfo_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qline_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qlinef_wrapper.cpp @@ -101,10 +98,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsignalmapper_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsize_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsizef_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsocketnotifier_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstring_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstringlist_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstringmatcher_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qstringref_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsysinfo_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsystemlocale_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qsystemsemaphore_wrapper.cpp diff --git a/PySide/QtCore/glue/qstring_bufferprotocol.cpp b/PySide/QtCore/glue/qstring_bufferprotocol.cpp deleted file mode 100644 index 02ca32c..0000000 --- a/PySide/QtCore/glue/qstring_bufferprotocol.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -#if PY_VERSION_HEX < 0x03000000 - -// QByteArray buffer protocol functions -// see: http://www.python.org/dev/peps/pep-3118/ - -extern "C" { - -static Py_ssize_t SbkQString_segcountproc(PyObject* self, Py_ssize_t* lenp) -{ - if (lenp) - *lenp = self->ob_type->tp_as_sequence->sq_length(self); - return 1; -} - -static Py_ssize_t SbkQString_readbufferproc(PyObject* self, Py_ssize_t segment, char** ptrptr) -{ - if (segment || Shiboken::cppObjectIsInvalid(self)) - return -1; - - QString* cppSelf = Converter::toCpp(self); - QByteArray decodedData = cppSelf->toLocal8Bit(); - Shiboken::AutoDecRef decodedString(PyString_FromStringAndSize(decodedData.constData(), decodedData.size())); - - // delete __encodedStr attr if it exists - Shiboken::AutoDecRef attrName(PyString_FromStringAndSize("__encodedStr", sizeof("__encodedStr")-1)); - if (PyObject_HasAttr(self, attrName)) - PyObject_DelAttr(self, attrName); - PyObject_SetAttr(self, attrName, decodedString); - *ptrptr = PyString_AS_STRING(decodedString.object()); - return decodedData.size(); -} - -PyBufferProcs SbkQStringBufferProc = { - /*bf_getreadbuffer*/ 0, - /*bf_getwritebuffer*/ 0, - /*bf_getsegcount*/ &SbkQString_segcountproc, - /*bf_getcharbuffer*/ &SbkQString_readbufferproc -}; - -} - -#endif diff --git a/PySide/QtCore/glue/qstring_hashfunc.cpp b/PySide/QtCore/glue/qstring_hashfunc.cpp deleted file mode 100644 index b2fb6a1..0000000 --- a/PySide/QtCore/glue/qstring_hashfunc.cpp +++ /dev/null @@ -1,6 +0,0 @@ -static long QStringCustomHashFunction(const QString& str) -{ - QByteArray data = str.toUtf8(); - Shiboken::AutoDecRef unicodeObj(PyUnicode_DecodeUTF8(data.constData(), data.length(), 0)); - return unicodeObj->ob_type->tp_hash(unicodeObj); -} diff --git a/PySide/QtCore/qchar_conversions.h b/PySide/QtCore/qchar_conversions.h index 6347c93..ab477ef 100644 --- a/PySide/QtCore/qchar_conversions.h +++ b/PySide/QtCore/qchar_conversions.h @@ -1,30 +1,30 @@ namespace Shiboken { -inline bool Shiboken::Converter::isConvertible(PyObject* pyObj) -{ - return PyObject_TypeCheck(pyObj, SbkType()) - || SbkPySide_QtCore_QChar_SpecialCharacter_Check(pyObj) - || SbkQLatin1Char_Check(pyObj) - || (PyString_Check(pyObj) && (PyString_Size(pyObj) == 1)) - || PyInt_Check(pyObj); -} -inline QChar Shiboken::Converter::toCpp(PyObject* pyObj) +template<> +class Converter { - if (!Shiboken_TypeCheck(pyObj, QChar)) { - if (SbkPySide_QtCore_QChar_SpecialCharacter_Check(pyObj)) - return QChar(Shiboken::Converter::toCpp(pyObj)); - else if (SbkQLatin1Char_Check(pyObj)) - return QChar(Shiboken::Converter::toCpp(pyObj)); - else if (PyString_Check(pyObj) && PyString_Size(pyObj) == 1) +public: + static bool isConvertible(PyObject* pyObj) + { + return (PyString_Check(pyObj) && (PyString_Size(pyObj) == 1)) + || PyInt_Check(pyObj); + } + + static QChar toCpp(PyObject* pyObj) + { + if (PyString_Check(pyObj) && PyString_Size(pyObj) == 1) return QChar(Shiboken::Converter::toCpp(pyObj)); else if (PyInt_Check(pyObj)) return QChar(Shiboken::Converter::toCpp(pyObj)); + return QChar(); } - return *Converter::toCpp(pyObj); -} -inline PyObject* Converter::toPython(const QChar& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} + static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } + static PyObject* toPython(const QChar& cppObj) + { + wchar_t c = (wchar_t)cppObj.unicode(); + PyObject* pyObj = PyUnicode_FromWideChar(&c, 1); + return pyObj; + } +}; } diff --git a/PySide/QtCore/qstring_conversions.h b/PySide/QtCore/qstring_conversions.h index 2c59928..392f0e7 100644 --- a/PySide/QtCore/qstring_conversions.h +++ b/PySide/QtCore/qstring_conversions.h @@ -1,72 +1,70 @@ namespace Shiboken { -inline bool Converter::isConvertible(PyObject* pyObj) -{ - SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - return PyString_Check(pyObj) - || PyObject_TypeCheck(pyObj, SbkType()) - || PyUnicode_Check(pyObj) - || SbkQByteArray_Check(pyObj) - || SbkQLatin1String_Check(pyObj) - || pyObj == Py_None -#if PY_VERSION_HEX < 0x03000000 - || (pyObj->ob_type->tp_as_buffer - && PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER) - && pyObj->ob_type->tp_as_buffer->bf_getcharbuffer) -#endif - || SbkQChar_Check(pyObj) - || (shiboType->ext_isconvertible && shiboType->ext_isconvertible(pyObj)); -} -inline QString Converter::toCpp(PyObject* pyObj) +template<> +class Converter { - SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - if (SbkQChar_Check(pyObj)) { - return QString(Converter< QChar >::toCpp(pyObj)); - } else if (SbkQByteArray_Check(pyObj)) { - return QString(Converter< QByteArray >::toCpp(pyObj)); - } else if (SbkQLatin1String_Check(pyObj)) { - return QString(Converter< QLatin1String >::toCpp(pyObj)); - } else if (PyUnicode_Check(pyObj)) { - Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyObj); -#if defined(Py_UNICODE_WIDE) - // cast as Py_UNICODE can be a different type - return QString::fromUcs4(reinterpret_cast(unicode)); -#else - return QString::fromUtf16(unicode, PyUnicode_GET_SIZE(pyObj)); -#endif - } else if (PyString_Check(pyObj)) { - return QString(Converter< char * >::toCpp(pyObj)); - } else if (pyObj == Py_None) { +public: + static bool isConvertible(PyObject* pyObj) + { + return PyString_Check(pyObj) + || PyUnicode_Check(pyObj) + || SbkQByteArray_Check(pyObj) + || pyObj == Py_None + #if PY_VERSION_HEX < 0x03000000 + || (pyObj->ob_type->tp_as_buffer + && PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER) + && pyObj->ob_type->tp_as_buffer->bf_getcharbuffer) + #endif + ; + } + + static QString toCpp(PyObject* pyObj) + { + if (PyUnicode_Check(pyObj)) { + Py_UNICODE* unicode = PyUnicode_AS_UNICODE(pyObj); + #if defined(Py_UNICODE_WIDE) + // cast as Py_UNICODE can be a different type + return QString::fromUcs4(reinterpret_cast(unicode)); + #else + return QString::fromUtf16(unicode, PyUnicode_GET_SIZE(pyObj)); + #endif + } else if (PyString_Check(pyObj)) { + return QString(Converter< char * >::toCpp(pyObj)); + } else if (pyObj == Py_None) { + return QString(); + } else if (SbkQByteArray_Check(pyObj)) { + return QString(Converter< QByteArray >::toCpp(pyObj)); + } +#if PY_VERSION_HEX < 0x03000000 + // Support for buffer objects on QString constructor + else if (pyObj->ob_type->tp_as_buffer + && PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER) + && pyObj->ob_type->tp_as_buffer->bf_getcharbuffer) { + QByteArray data; + PyBufferProcs* bufferProcs = pyObj->ob_type->tp_as_buffer; + int segments = bufferProcs->bf_getsegcount(pyObj, 0); + for (int i = 0; i < segments; ++i) { + char* segmentData; + int length = bufferProcs->bf_getcharbuffer(pyObj, i, &segmentData); + if (length == -1) + break; + data.append(segmentData, length); + } + return QString(data); + } + #endif return QString(); } -#if PY_VERSION_HEX < 0x03000000 - // Support for buffer objects on QString constructor - else if (pyObj->ob_type->tp_as_buffer - && PyType_HasFeature(pyObj->ob_type, Py_TPFLAGS_HAVE_GETCHARBUFFER) - && pyObj->ob_type->tp_as_buffer->bf_getcharbuffer) { - QByteArray data; - PyBufferProcs* bufferProcs = pyObj->ob_type->tp_as_buffer; - int segments = bufferProcs->bf_getsegcount(pyObj, 0); - for (int i = 0; i < segments; ++i) { - char* segmentData; - int length = bufferProcs->bf_getcharbuffer(pyObj, i, &segmentData); - if (length == -1) - break; - data.append(segmentData, length); - } - return QString(data); - } -#endif - else if (shiboType->ext_isconvertible && shiboType->ext_tocpp && shiboType->ext_isconvertible(pyObj)) { - QString* cptr = reinterpret_cast(shiboType->ext_tocpp(pyObj)); - std::auto_ptr cptr_auto_ptr(cptr); - return *cptr; - } - return *Converter::toCpp(pyObj); -} -inline PyObject* Converter::toPython(const QString& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} + static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } + static PyObject* toPython(const QString& cppObj) + { + const int N = cppObj.length(); + wchar_t* str = new wchar_t[N]; + cppObj.toWCharArray(str); + PyObject* pyObj = PyUnicode_FromWideChar(str, N); + delete[] str; + return pyObj; + } +}; } diff --git a/PySide/QtCore/qstringlist_conversions.h b/PySide/QtCore/qstringlist_conversions.h index 9a5ec5f..6075c16 100644 --- a/PySide/QtCore/qstringlist_conversions.h +++ b/PySide/QtCore/qstringlist_conversions.h @@ -1,17 +1,5 @@ namespace Shiboken { -inline bool Converter::isConvertible(PyObject* pyObj) -{ - return StdListConverter::isConvertible(pyObj); -} - -inline QStringList Converter::toCpp(PyObject* pyObj) -{ - return StdListConverter::toCpp(pyObj); -} - -inline PyObject* Converter::toPython(const QStringList& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} +template<> +struct Converter : StdListConverter {}; } diff --git a/PySide/QtCore/qstringref_conversions.h b/PySide/QtCore/qstringref_conversions.h new file mode 100644 index 0000000..11e1b9c --- /dev/null +++ b/PySide/QtCore/qstringref_conversions.h @@ -0,0 +1,19 @@ +namespace Shiboken { + +template<> +struct Converter : public Converter +{ + static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } + + static PyObject* toPython(const QStringRef& cppObj) + { + const QString* str = cppObj.string(); + return Converter::toPython(*str); + } + + static QStringRef toCpp(PyObject* pyObj) + { + return QStringRef(); + } +}; +} diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 8924fa4..56c8b30 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -39,8 +39,15 @@ + + + + + + + @@ -66,15 +73,6 @@ - - - - - - - - - @@ -111,8 +109,6 @@ - - @@ -134,8 +130,7 @@ - - + @@ -145,9 +140,20 @@ - - - + + + + + + + + + + + + + + @@ -242,7 +248,6 @@ - @@ -542,20 +547,6 @@ - - - - - - - - - - - - - - @@ -699,7 +690,6 @@ - @@ -722,6 +712,8 @@ + Shiboken::TypeResolver::createValueTypeResolver<QString>("unicode"); + Shiboken::TypeResolver::createValueTypeResolver<QString>("str"); PySide::init(module); @@ -772,224 +764,6 @@ - - - - - - - - - - - - - #if PY_VERSION_HEX < 0x03000000 - Shiboken::SbkType<QString>()->tp_as_buffer = &SbkQStringBufferProc; - Shiboken::SbkType<QString>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; - #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - QByteArray utf8 = %CPPSELF.toUtf8(); - %PYARG_0 = PyUnicode_DecodeUTF8(utf8.data(), utf8.count(), 0); - - - - - return %CPPSELF.count(); - - - - - if (_i < 0 || _i >= %CPPSELF.size()) { - PyErr_SetString(PyExc_IndexError, "index out of bounds"); - return 0; - } - return %CONVERTTOPYTHON[%TYPE](%CPPSELF.at(_i)); - - - - - %CPPSELF.remove(_i, 1); - PyObject* args = Py_BuildValue("(nO)", _i, _value); - PyObject* result = SbkQStringFunc_insert(self, args); - Py_DECREF(args); - Py_XDECREF(result); - return !result ? -1 : 0; - - - - - - - - - - - - - - - - - - - - - - - Implementation note: This constructor is a replacement for - QChar(char), as the char type check also catches numbers, - conflicting with QChar(int). - - - if (PyString_Size(%PYARG_1) == 1) { - char value = %CONVERTTOCPP[char](%PYARG_1); - %0 = new %TYPE(value); - } else { - PyErr_SetString(PyExc_TypeError, "expected string of size 1"); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1062,7 +836,6 @@ - @@ -1493,7 +1266,6 @@ - @@ -1635,75 +1407,6 @@ - - - - - - return %CPPSELF.count(); - - - - - if (_i < 0 || _i >= %CPPSELF.size()) { - PyErr_SetString(PyExc_IndexError, "index out of bounds"); - return 0; - } - return %CONVERTTOPYTHON[QString](%CPPSELF.at(_i)); - - - - - PyObject* args = Py_BuildValue("(nO)", _i, _value); - PyObject* result = SbkQStringListFunc_replace(self, args); - Py_DECREF(args); - Py_XDECREF(result); - return !result ? -1 : 0; - - - - - - - - - - - return 0; - - - @@ -1759,9 +1462,7 @@ - - @@ -2134,15 +1835,12 @@ - - - - + + + - - - + @@ -2506,7 +2204,10 @@ + + + @@ -2526,6 +2227,11 @@ + + + + + @@ -2553,10 +2259,6 @@ - - - - @@ -2566,6 +2268,7 @@ + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index eef6ffe..4a78bf6 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -1,5 +1,4 @@ PYSIDE_TEST(blocking_signals_test.py) -PYSIDE_TEST(buffer_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deletelater_test.py) PYSIDE_TEST(duck_punching_test.py) @@ -14,7 +13,6 @@ PYSIDE_TEST(qbytearray_concatenation_operator_test.py) PYSIDE_TEST(qbytearray_operator_iadd_test.py) PYSIDE_TEST(qbytearray_operator_test.py) PYSIDE_TEST(qbytearray_test.py) -PYSIDE_TEST(qchar_test.py) PYSIDE_TEST(qcoreapplication_instance_test.py) PYSIDE_TEST(qdatastream_test.py) PYSIDE_TEST(qdate_test.py) @@ -24,7 +22,6 @@ PYSIDE_TEST(qfileinfo_test.py) PYSIDE_TEST(qfile_test.py) PYSIDE_TEST(qflags_test.py) PYSIDE_TEST(qhandle_test.py) -PYSIDE_TEST(qlatin1string_test.py) PYSIDE_TEST(qlinef_test.py) PYSIDE_TEST(qlocale_test.py) PYSIDE_TEST(qmetaobject_test.py) @@ -48,9 +45,6 @@ PYSIDE_TEST(qslot_object_test.py) PYSIDE_TEST(qsrand_test.py) PYSIDE_TEST(qstatemachine_test.py) PYSIDE_TEST(qstate_test.py) -PYSIDE_TEST(qstring_buffer_protocol_test.py) -PYSIDE_TEST(qstringlist_test.py) -PYSIDE_TEST(qstring_operator_test.py) PYSIDE_TEST(qstring_test.py) PYSIDE_TEST(qtext_codec_test.py) PYSIDE_TEST(qtextstream_test.py) diff --git a/tests/QtCore/buffer_test.py b/tests/QtCore/buffer_test.py deleted file mode 100644 index 2917232..0000000 --- a/tests/QtCore/buffer_test.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/python - -import unittest -from PySide.QtCore import QString - -class BufferTest(unittest.TestCase): - def testQByteArray(self): - data = buffer("PySide") - str = QString(data) - self.assertEqual(data, str) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtCore/qbytearray_operator_iadd_test.py b/tests/QtCore/qbytearray_operator_iadd_test.py index 168f22d..f92fc19 100644 --- a/tests/QtCore/qbytearray_operator_iadd_test.py +++ b/tests/QtCore/qbytearray_operator_iadd_test.py @@ -2,12 +2,12 @@ import unittest import new -from PySide.QtCore import QByteArray, QString +from PySide.QtCore import * from helper.docmodifier import DocModifier class BaseQByteArrayOperatorIAdd(object): '''Base class for QByteArray += operator tests. - + Implementing classes should inherit from unittest.TestCase and implement setUp, setting self.obj and self.orig_obj to the target QByteArray and original one, respectively''' @@ -41,13 +41,6 @@ class BaseQByteArrayOperatorIAdd(object): self.assertEqual(self.obj, self.orig_obj + s) self.assertEqual(self.obj.size(), self.orig_obj.size() + 1) - def testQString(self): - '''QByteArray += QString''' - s = QString('dummy') - self.obj += s - self.assertEqual(self.obj, self.orig_obj + s) - self.assertEqual(self.obj.size(), self.orig_obj.size() + s.size()) - class NullQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd): '''Test case for operator QByteArray += on null QByteArrays''' diff --git a/tests/QtCore/qbytearray_operator_test.py b/tests/QtCore/qbytearray_operator_test.py index 4a20c04..662bc6e 100644 --- a/tests/QtCore/qbytearray_operator_test.py +++ b/tests/QtCore/qbytearray_operator_test.py @@ -4,7 +4,7 @@ import unittest -from PySide.QtCore import QByteArray, QString +from PySide.QtCore import * class QByteArrayOperatorEqual(unittest.TestCase): '''TestCase for operator QByteArray == QByteArray''' @@ -26,9 +26,9 @@ class QByteArrayOperatorEqual(unittest.TestCase): self.assertEqual(QByteArray(string), string) def testQString(self): - #QByteArray(string) == QString(string) + #QByteArray(string) == string string = 'another test string' - self.assertEqual(QByteArray(string), QString(string)) + self.assertEqual(QByteArray(string), string) class QByteArrayOperatorAt(unittest.TestCase): '''TestCase for operator QByteArray[]''' diff --git a/tests/QtCore/qchar_test.py b/tests/QtCore/qchar_test.py deleted file mode 100644 index a40724b..0000000 --- a/tests/QtCore/qchar_test.py +++ /dev/null @@ -1,59 +0,0 @@ - -'''Test cases for QChar''' - -import unittest - -from PySide.QtCore import QString, QChar, QTextStream, QLatin1Char - - -class EqualTest(unittest.TestCase): - '''Tests for '__equal__''' - - def testEqualQChar(self): - '''QChar == QChar''' - self.assertEqual(QChar('a'), QChar('a')) - - def testEqualPyString(self): - '''QChar == Python string''' - self.assertEqual(QChar('a'), 'a') - - -class ImplicitConvQLatin1Char(unittest.TestCase): - '''Tests for implicit conversion from QLatin1Char to QChar''' - - def testQLatin1CharToChar(self): - '''QLatin1Char implicitly convertible to QChar''' - stream = QTextStream() - stream.setPadChar(QLatin1Char('-')) - self.assertEqual(QChar('-'), stream.padChar()) - - -class QCharCtorBigNumber(unittest.TestCase): - '''QChar constructors receiving ints''' - - def testInt(self): - '''QChar(int)''' - codepoint = 512 - qchar = QChar(codepoint) - reference = unichr(codepoint) - self.assertEqual(qchar.unicode(), codepoint) - - -class QCharCtorString(unittest.TestCase): - '''QChar constructor receiving strings''' - - def testBasic(self): - '''QChar(char)''' - reference = 'a' - qchar = QChar(reference) - self.assertEqual(ord(reference), ord(qchar.toAscii())) - - def testError(self): - '''QChar(char)''' - reference = 'aaaaaa' - self.assertRaises(TypeError, QChar, reference) - - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py index d71ed2f..e809185 100644 --- a/tests/QtCore/qdatastream_test.py +++ b/tests/QtCore/qdatastream_test.py @@ -3,8 +3,7 @@ import unittest -from PySide.QtCore import QDataStream, QString, QIODevice, QByteArray -from PySide.QtCore import QBitArray, QDate, QTime, QDateTime, QLine, QChar +from PySide.QtCore import * def create_bitarray(string): array = QBitArray(len(string)) diff --git a/tests/QtCore/qenum_test.py b/tests/QtCore/qenum_test.py index e3f9638..d896ae6 100644 --- a/tests/QtCore/qenum_test.py +++ b/tests/QtCore/qenum_test.py @@ -3,7 +3,7 @@ import unittest -from PySide.QtCore import QIODevice, QString, Qt, QVariant +from PySide.QtCore import * class TestEnum(unittest.TestCase): @@ -18,7 +18,7 @@ class TestEnum(unittest.TestCase): self.assertEqual(QIODevice.Unbuffered, 32) def testToIntInFunction(self): - self.assertEqual(QString.number(QIODevice.WriteOnly), "2") + self.assertEqual(str(int(QIODevice.WriteOnly)), "2") class TestQFlags(unittest.TestCase): def testToItn(self): diff --git a/tests/QtCore/qlatin1string_test.py b/tests/QtCore/qlatin1string_test.py deleted file mode 100644 index fdcf6ec..0000000 --- a/tests/QtCore/qlatin1string_test.py +++ /dev/null @@ -1,21 +0,0 @@ - -'''Test cases for QLatin1String''' - -import unittest - -from PySide.QtCore import QString, QLatin1String, QObject - - -class ImplicitConvQLatin1String(unittest.TestCase): - '''Tests for implicit conversion from QLatin1String to QString''' - - def testQLatin1String(self): - '''QString implicit convertion from QLatin1String''' - obj = QObject() - obj.setObjectName(QLatin1String('dummy')) - - self.assertEqual(QString('dummy'), obj.objectName()) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index 33df2ac..d1f12b3 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -3,7 +3,7 @@ import unittest -from PySide.QtCore import QObject, QVariant, QString +from PySide.QtCore import * class PropertyCase(unittest.TestCase): '''Test case for QObject properties''' @@ -41,14 +41,14 @@ class PropertyCase(unittest.TestCase): # QVariant.toInt has a bool* arg in C++, so returns a tuple self.assertEqual(obj.property('dummy').toInt(), (42, True)) - def testQStringProperty(self): + def testStringProperty(self): obj = QObject() - self.assert_(not obj.setProperty('dummy', QString('data'))) + self.assert_(not obj.setProperty('dummy', 'data')) prop = obj.property('dummy') self.assert_(isinstance(prop, QVariant)) self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), QString('data')) + self.assertEqual(obj.property('dummy').toString(), 'data') def testImplicitQVariantProperty(self): obj = QObject() diff --git a/tests/QtCore/qstring_buffer_protocol_test.py b/tests/QtCore/qstring_buffer_protocol_test.py deleted file mode 100755 index f8475d0..0000000 --- a/tests/QtCore/qstring_buffer_protocol_test.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Tests QString implementation of Python buffer protocol''' - -import unittest - -from os.path import isdir -from PySide.QtCore import QString - -class QStringBufferProtocolTest(unittest.TestCase): - '''Tests QString implementation of Python buffer protocol''' - - def testQStringBufferProtocol(self): - #Tests QString implementation of Python buffer protocol using the os.path.isdir - #function which an unicode object or other object implementing the Python buffer protocol - isdir(QString('/tmp')) - -if __name__ == '__main__': - unittest.main() - diff --git a/tests/QtCore/qstring_operator_test.py b/tests/QtCore/qstring_operator_test.py deleted file mode 100644 index 6d7ae31..0000000 --- a/tests/QtCore/qstring_operator_test.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QString operators''' - -import unittest - -from PySide.QtCore import QString, QByteArray - -class QStringOperatorEqual(unittest.TestCase): - '''TestCase for operator QString == QString''' - - def testDefault(self): - #QString() == QString() - obj1 = QString() - obj2 = QString() - self.assertEqual(obj1, obj2) - - def testSimple(self): - #QString(some_string) == QString(some_string) - string = 'egg snakes' - self.assertEqual(QString(string), QString(string)) - - def testUnicode(self): - #QString(unicode) == QString(unicode) - string = u'àâãá' - self.assertEqual(QString(string), QString(string)) - - def testPyString(self): - #QString(string) == string - string = 'my test string' - self.assertEqual(QString(string), string) - self.assertEqual(string, QString(string)) - - def testPyUnicodeString(self): - #QString(unicode) == unicode - string = u'àâãá' - self.assertEqual(QString(string), string) - self.assertEqual(string, unicode(QString(string))) - - def testQByteArray(self): - #QString(string) == QByteArray(string) - string = 'another test string' - self.assertEqual(QString(string), QByteArray(string)) - - -class QStringOperatorAtSetter(unittest.TestCase): - '''Test case for operator QString[] - __setitem__''' - - def testSetterString(self): - '''QString[x] = pythonstring''' - obj = QString('123456') - obj[1] = '0' - self.assertEqual(obj, QString('103456')) - - def testSetterStringLarge(self): - '''QString[x] = pythonstring (larget than 1 char)''' - obj = QString('123456') - obj[3] = 'abba' - self.assertEqual(obj, QString('123abba56')) - - def testSetterQString(self): - '''QString[x] = QString''' - obj = QString('123456') - obj[3] = QString('string') - self.assertEqual(obj, QString('123string56')) - - def testSetterQByteArray(self): - '''QString[x] = qbytearray''' - obj = QString('123456') - obj[3] = QByteArray('array') - self.assertEqual(obj, QString('123array56')) - - -class QStringOperatorAtSetterNegativeIndex(unittest.TestCase): - '''Test case for QString[] - __setitem__ - for negative index''' - - def testSetterNegativeIndex(self): - '''QString[x] = string - negative index''' - obj = QString('123456') - obj[-3] = 'array' - self.assertEqual(obj, QString('123array56')) - - -class QStringOperatorAtSetterLargeIndex(unittest.TestCase): - '''Test case for QString[] - __setitem__ - for 'overflown' index''' - - def testSetterLargeIndexEmpty(self): - '''QString[x] = somestring - Overflow index on empty string''' - # should pad with spaces if the index is larger - obj = QString('') - obj[2] = 'a' - self.assertEqual(obj, QString(' a')) - - def testSetterLargeIndexNormal(self): - '''QString[x] = somestring - Overflow index on normal string''' - # should pad with spaces if the index is larger - obj = QString('mystring') - obj[10] = 'normal' - self.assertEqual(obj, QString('mystring normal')) - - -class QStringOperatorAt(unittest.TestCase): - '''TestCase for operator QString[] - __getitem__''' - - def testInRange(self): - #QString[x] where x is a valid index - string = 'abcdefgh' - obj = QString(string) - - for i in range(len(string)): - self.assertEqual(obj[i], string[i]) - - def testInRangeReverse(self): - #QString[x] where x is a valid index (reverse order) - string = 'abcdefgh' - obj = QString(string) - - for i in range(len(string)-1, 0, -1): - self.assertEqual(obj[i], string[i]) - - - def testInRangeUnicode(self): - #QString[x] where x is a valid index (unicode) - string = u'àâãá' - obj = QString(string) - - for i in range(len(string)): - self.assertEqual(obj[i], string[i]) - - def testInRangeUnicodeReverse(self): - #QString[x] where x is a valid index (unicode) (reverse order) - string = u'àâãá' - obj = QString(string) - - for i in range(len(string)-1, 0, -1): - self.assertEqual(obj[i], string[i]) - - def testOutOfRange(self): - #QString[x] where x is out of index - string = '1234567' - obj = QString(string) - self.assertRaises(IndexError, lambda :obj[len(string)]) - - def testReturnQString(self): - #QString[x] must return a QString - string = QString('123456') - data = string[0] - self.assert_(isinstance(data, QString)) - -class QStringOperatorAdd(unittest.TestCase): - '''TestCase for operator QString[]''' - - def testOperatorAdd(self): - str1 = '123' - str2 = QString('456') - self.assertEquals('123456', str1 + str2) - self.assertEquals('456123', str2 + str1) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtCore/qstring_test.py b/tests/QtCore/qstring_test.py index 3f0fb49..fbaa6d4 100644 --- a/tests/QtCore/qstring_test.py +++ b/tests/QtCore/qstring_test.py @@ -6,173 +6,19 @@ import unittest import ctypes import sys -from PySide.QtCore import QString, QByteArray, QObject - -class QStringToNumber(unittest.TestCase): - def testReturnValueTypes(self): - obj = QString('37') - val, ok = obj.toInt() - self.assertEqual(type(val), int) - self.assertEqual(type(ok), bool) - - def testToNumberInt(self): - obj = QString('37') - self.assertEqual((37, True), obj.toInt()) - - def testToNumberLong(self): - obj = QString('3700000') - self.assertEqual((3700000, True), obj.toInt()) - - def testToNumberShort(self): - obj = QString('33') - self.assertEqual((ctypes.c_short(33).value, True), obj.toShort()) - - def testToNumberShortNegative(self): - obj = QString('-4') - self.assertEqual((ctypes.c_short(-4).value, True), obj.toShort()) - - def testToNumberShortOverflow(self): - obj = QString('1000000') - self.assertEqual(False, obj.toShort()[1]) - - def testToNumberUInt(self): - obj = QString('33') - self.assertEqual((ctypes.c_uint(33).value, True), obj.toUInt()) - - def testToNumberUIntNegative(self): - obj = QString('-4') - self.assertEqual(False, obj.toUInt()[1]) - - def testToNumberUIntOverflow(self): - obj = QString('10000000000000') - self.assertEqual(False, obj.toUInt()[1]) - - def testToNumberULong(self): - obj = QString('33') - self.assertEqual((ctypes.c_ulong(33).value, True), obj.toULong()) - - def testToNumberULongNegative(self): - obj = QString('-4') - self.assertEqual(False, obj.toULong()[1]) - - def testToNumberUShort(self): - obj = QString('33') - self.assertEqual((ctypes.c_ushort(33).value, True), obj.toUShort()) - - def testToNumberUShortLarge(self): - obj = QString('128') - self.assertEqual((ctypes.c_ushort(128).value, True), obj.toUShort()) - - def testToNumberUShortOverflow(self): - obj = QString('205000') - self.assertEqual(False, obj.toUShort()[1]) - - def testToNumberUShortNegative(self): - obj = QString('-4') - self.assertEqual(False, obj.toUShort()[1]) - - def testToNumberIntUsingHex(self): - obj = QString('2A') - self.assertEquals((0, False), obj.toInt()) - self.assertEqual((int(str(obj), 16), True), obj.toInt(16)) - - def testToNumberIntUsingHex(self): - obj = QString('101010') - self.assertEqual((int(str(obj), 2), True), obj.toInt(2)) - - def testToNumberFloat(self): - obj = QString('37.109') - self.assertEqual(ctypes.c_float(37.109).value, - obj.toFloat()[0]) - - def testToNumberDouble(self): - obj = QString('37.109') - self.assertEqual(ctypes.c_double(37.109).value, - obj.toDouble()[0]) - - def testToULongLong(self): - obj = QString('37109') - self.assertEqual(ctypes.c_ulong(37109).value, - obj.toULongLong()[0]) +from PySide.QtCore import * class QStringConstructor(unittest.TestCase): '''Test case for QString constructors''' def testQStringDefault(self): - #QString() - obj1 = QString() - obj2 = QString() - - self.assertEqual(obj1, obj2) - - def testNullQString(self): - s = QString(None) - self.assertTrue(s.isNull()) - - def testQStringFromPy(self): - #QString(const char*) - sample = 'a new string' - obj1 = QString(sample) - obj2 = QString(sample) - self.assertEqual(obj1, obj2) - - def testQStringFromUnicode(self): - sample = u'áâãà' - obj1 = QString(sample) - obj2 = QString(sample) - self.assertEqual(obj1, obj2) - self.assertEqual(obj1, sample) - self.assertEqual(obj2, sample) - - def testQStringFromByteArray(self): - # QByteArray(const char *) must be working - sample = QByteArray('foo') - obj1 = QString(sample) - obj2 = QString(sample) - self.assertEqual(obj1, obj2) - - def testQStringArg(self): - a = QString("%1 %2 %3").arg(1).arg("two").arg(3.14) - self.assertEquals("1 two 3.14", str(a)) - - def testQStringArgNegative(self): - a = QString("%1").arg(-20) - self.assertEquals("-20", str(a)) - - -class QStringComparison(unittest.TestCase): - '''Test case for comparison to python strings''' - - def testComparePyString(self): - #Compare QStrings and Python strings. - py = '' - qstr = QString() - self.assertEqual(py, qstr) - - py = 'The quick brown fox jumps over the lazy dog' - qstr = QString(py) - self.assertEqual(py, qstr) - -class QStringRange(unittest.TestCase): - '''Test case for ranges in python strings''' - - def testSimpleRange(self): - #Test open start and open end intervals - py = 'The quick brown fox jumps over the lazy dog' - qstr = QString(py) - self.assertEqual(py[5:], qstr[5:]) - self.assertEqual(py[:7], qstr[:7]) - -class QStringIndexOf(unittest.TestCase): - def testEmpty(self): - string = QString() - self.assertEqual(string.indexOf(QString("aaa")), -1) - self.assertEqual(string.indexOf(QString()), 0) - - def testString(self): - string = QString("the quick brown fox") - self.assertEqual(string.indexOf("quick", 0), 4) - + obj = QObject() + obj.setObjectName('foo') + self.assertEqual(obj.objectName(), u'foo') + obj.setObjectName(u'áâãà') + self.assertEqual(obj.objectName(), u'áâãà') + obj.setObjectName(None) + self.assertEqual(obj.objectName(), u'') class QStringImplicitConvertion(unittest.TestCase): '''Implicit conversions for QString''' @@ -181,12 +27,8 @@ class QStringImplicitConvertion(unittest.TestCase): '''QString implicitly conversion: QByteArray''' obj = QObject() obj.setObjectName(QByteArray('foobar')) - self.assertEqual(obj.objectName(), QString('foobar')) + self.assertEqual(obj.objectName(), u'foobar') -class QStringHash(unittest.TestCase): - def testHash(self): - self.assertEqual(hash("key"), hash(QString("key"))) - self.assertEqual(hash(u"aéióu"), hash(QString(u"aéióu"))) if __name__ == '__main__': unittest.main() diff --git a/tests/QtCore/qstringlist_test.py b/tests/QtCore/qstringlist_test.py deleted file mode 100644 index 0310516..0000000 --- a/tests/QtCore/qstringlist_test.py +++ /dev/null @@ -1,171 +0,0 @@ - -# -*- coding: utf-8 -*- - -'''Test cases for QStringList''' - -import unittest -from random import shuffle - -from PySide.QtCore import QStringList, QString - -from helper import random_string - -class UsesManyStrings(unittest.TestCase): - '''Helper class to setup a list of strings and QStrings''' - def setUp(self): - #Creates a list of strings and python strings - self.size = 10 - # List of Python strings - self.samples = [random_string() for x in range(self.size)] - # List of QStrings - self.strings = map(QString, self.samples) - - self.obj = QStringList(self.strings) - - -class TestConstructorBasic(unittest.TestCase): - '''Basic constructor test''' - - def testEmpty(self): - #QStringList() - default constructor - obj = QStringList() - self.assert_(isinstance(obj, QStringList)) - - def testQString(self): - #QStringList(QString) - qstr = QString('aaaa') - obj = QStringList(qstr) - self.assert_(isinstance(obj, QStringList)) - - def testPyString(self): - #QStringList(python_string) constructor - string = 'forty two' - obj = QStringList(string) - self.assert_(isinstance(obj, QStringList)) - - def testPyStringUnicode(self): - #QStringList(unicode python_string) constructor - string = 'Nação Zumbi' - obj = QStringList(string) - self.assert_(isinstance(obj, QStringList)) - - -class TestConstructorList(UsesManyStrings): - '''Test case for QStringList(List) constructor''' - - def testListQString(self): - #QStringList([QString]) constructor - obj = QStringList(self.strings) - self.assert_(isinstance(obj, QStringList)) - - def testListPyString(self): - #QStringList([python_string]) constructor - obj = QStringList(self.samples) - self.assert_(isinstance(obj, QStringList)) - - def testListMixed(self): - #QStringList([python_string and QString]) mixed constructor - mixed = self.samples + self.strings - shuffle(mixed) - obj = QStringList(mixed) - self.assert_(isinstance(obj, QStringList)) - - def testCopyList(self): - #QStringList(QStringList(list)) - copy constructor - obj = QStringList(self.strings) - obj2 = QStringList(obj) - self.assert_(isinstance(obj2, QStringList)) - self.assertEqual(obj, obj2) - - -class TestComparison(unittest.TestCase): - '''Test case for comparison of QStringLists''' - - def testEqual(self): - #QStringList == QStringList - string = QString('aaaabvbbcccedde') - obj1 = QStringList(string) - obj2 = QStringList(string) - self.assertEqual(obj1, obj2) - - -class TestIndexing(unittest.TestCase): - '''Test case for indexing through []''' - def testInvalidIndexEmpty(self): - #QStringList[x] for empty list - obj = QStringList() - self.assertRaises(IndexError, lambda:obj[0]) - - def testInvalidIndexQString(self): - #QStringList[1] raising IndexError for QStringList(QString) - obj = QStringList(QString('aaaaa')) - self.assertRaises(IndexError, lambda:obj[1]) - - def testValidIndexQString(self): - #QStringList[0] not raising IndexError for QStringList(QString) - string = QString('abcdefg') - obj = QStringList(string) - self.assertEqual(obj[0], string) - - def testNegativeIndexing(self): - #QStringList[-1] not raising IndexError for QStringList(QString) - string = QString('abcdefg') - obj = QStringList(string) - self.assertEqual(obj[-1], string) - - -class TestListIndexing(UsesManyStrings): - '''Test case for indexing QStringList longer than 1 string''' - - def testValid(self): - #QStringList[] for valid indexes - for i in range(self.size): - self.assertEqual(self.strings[i], self.obj[i]) - - def testNegativeValid(self): - #QStringList[] for valid indexes - for i in range(-1, -self.size, -1): - self.assertEqual(self.strings[i], self.obj[i]) - - def testInvalid(self): - #QStringList[] for invalid negative indexes - self.assertRaises(IndexError, lambda : self.obj[self.size]) - self.assertRaises(IndexError, lambda : self.obj[-(self.size+1)]) - - -class TestSlicing(UsesManyStrings): - '''Test case for slicing a QStringList''' - - def testSlicing(self): - #QStringList slicing - for i in range(self.size): - self.assertEqual(self.obj[i:], self.strings[i:]) - self.assertEqual(self.obj[:i], self.strings[:i]) - for j in range(i): - self.assertEqual(self.obj[j:i], self.strings[j:i]) - - for i in range(-1, -self.size, -1): - self.assertEqual(self.obj[:i], self.strings[:i]) - - -class TestShiftOperator(UsesManyStrings): - '''Test case for QStringList lshift operator''' - - def testShiftOperator(self): - #QStringList lshift - a = QStringList() - a << "a" << "b" << "c"; - self.assertEquals(3, a.count()) - b = ["1", "2", "3"] - c = ["4", "5", "6"] - a << b << c - self.assertEquals(9, a.count()) - - def testShiftOperator(self): - #QStringList lshift - a = QStringList() - b = ["1", 2, "3"] - self.assertRaises(TypeError, a.__lshift__, b) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtCore/qtextstream_test.py b/tests/QtCore/qtextstream_test.py index 13dc651..a8f561c 100644 --- a/tests/QtCore/qtextstream_test.py +++ b/tests/QtCore/qtextstream_test.py @@ -3,8 +3,7 @@ import unittest -from PySide.QtCore import QTextStream, QIODevice, QString, QByteArray -from PySide.QtCore import QTextCodec, QFile +from PySide.QtCore import * class QTextStreamShiftTest(unittest.TestCase): @@ -16,18 +15,11 @@ class QTextStreamShiftTest(unittest.TestCase): def testNumber(self): '''QTextStream << number''' - self.write << QString('4') + self.write << '4' self.write.flush() res = self.read.readLine() - self.assert_(isinstance(res, QString)) - self.assertEqual(res, QString('4')) - - def testString(self): - self.write << QString('Test_it!') - self.write.flush() - res = QString() - self.read >> res - self.assertEqual(res, QString('Test_it!')) + self.assert_(isinstance(res, unicode)) + self.assertEqual(res, '4') class QTextStreamGetSet(unittest.TestCase): diff --git a/tests/QtCore/qvariant_pyobject_test.py b/tests/QtCore/qvariant_pyobject_test.py index 82da555..2000a01 100644 --- a/tests/QtCore/qvariant_pyobject_test.py +++ b/tests/QtCore/qvariant_pyobject_test.py @@ -3,19 +3,17 @@ import unittest -from PySide.QtCore import QSize, QVariant, QString +from PySide.QtCore import * class Dummy(object): '''Pure python sample class''' pass - class MySize(QSize): '''Extended class''' pass - class QVariantPurePython(unittest.TestCase): '''QVariant + pure python classes''' @@ -26,7 +24,6 @@ class QVariantPurePython(unittest.TestCase): # inherited type name from other binding self.assertEqual('PyQt_PyObject', obj.typeName()) - class QVariantInheritedPython(unittest.TestCase): '''QVariant + classes inherited from C++''' @@ -63,7 +60,7 @@ class QVariantToPyObject(unittest.TestCase): '''QVariant(python string).toPyObject() return an equal QString''' d = 'abc' obj = QVariant('abc') - self.assert_(isinstance(obj.toPyObject(), QString)) + self.assert_(isinstance(obj.toPyObject(), unicode)) self.assertEqual(d, obj.toPyObject()) diff --git a/tests/QtCore/qvariant_test.py b/tests/QtCore/qvariant_test.py index 5c23b40..6be7b81 100644 --- a/tests/QtCore/qvariant_test.py +++ b/tests/QtCore/qvariant_test.py @@ -5,7 +5,7 @@ import unittest import sys -from PySide.QtCore import QSize, QVariant, QByteArray, QStringList, QString +from PySide.QtCore import * class QVariantToNumber(unittest.TestCase): @@ -50,11 +50,6 @@ class QVariantToNumber(unittest.TestCase): class QVariantTypeName(unittest.TestCase): '''QVariant.typeName()''' - def testTypeNameQString(self): - '''QVariant(QString).typeName()''' - obj = QVariant(QString('aaaa')) - self.assertEqual('QString', obj.typeName()) - def testTypeNameString(self): '''QVariant(PyString).typeName()''' obj = QVariant('aaaa') @@ -96,18 +91,6 @@ class QVariantTypeName(unittest.TestCase): obj = QVariant(['aaa', 'bbb', 'ccc', 'dddd']) self.assertEqual('QVariantList', obj.typeName()) - obj = QVariant([QString('aaa'), QString('bbb'), - QString('ccc'), QString('dddd')]) - self.assertEqual('QVariantList', obj.typeName()) - - def testTypeNameQStringList(self): - '''QVariant(QStringList).typeName()''' - obj = QVariant(QStringList()) - self.assertEqual('QStringList', obj.typeName()) - obj = QVariant(QStringList(['aaa', 'bbb', 'ccc'])) - self.assertEqual('QStringList', obj.typeName()) - - class QVariantConstructor(unittest.TestCase): '''More qvariant constructions''' diff --git a/tests/QtCore/translation_test.py b/tests/QtCore/translation_test.py index 870c8c5..6b75bee 100644 --- a/tests/QtCore/translation_test.py +++ b/tests/QtCore/translation_test.py @@ -5,7 +5,7 @@ import os import unittest -from PySide.QtCore import QObject, QTranslator, QCoreApplication, QString +from PySide.QtCore import * from helper import UsesQCoreApplication @@ -54,7 +54,7 @@ class TranslationTest(UsesQCoreApplication): def testTranslateWithNoneDisambiguation(self): value = 'String here' obj = QCoreApplication.translate('context', value, None, QCoreApplication.UnicodeUTF8) - self.assert_(isinstance(obj, QString)) + self.assert_(isinstance(obj, unicode)) self.assertEqual(obj, value) if __name__ == '__main__': diff --git a/tests/QtGui/qinputdialog_get_test.py b/tests/QtGui/qinputdialog_get_test.py index c75f712..ce3a60d 100644 --- a/tests/QtGui/qinputdialog_get_test.py +++ b/tests/QtGui/qinputdialog_get_test.py @@ -15,7 +15,7 @@ class TestInputDialog(TimedQApplication): self.assertEquals(QtGui.QInputDialog.getInteger(None, "title", "label"), (0, False)) def testGetItem(self): - (item, bool) = QtGui.QInputDialog.getItem(None, "title", "label", QtCore.QStringList(["1", "2", "3"])) + (item, bool) = QtGui.QInputDialog.getItem(None, "title", "label", ["1", "2", "3"]) self.assertEquals(str(item), "1") def testGetText(self): diff --git a/tests/QtGui/qpixmap_test.py b/tests/QtGui/qpixmap_test.py index 4814094..7ba7454 100644 --- a/tests/QtGui/qpixmap_test.py +++ b/tests/QtGui/qpixmap_test.py @@ -16,7 +16,7 @@ class QPixmapTest(UsesQApplication): self.assert_(pixmap.size().height(), 20) def testQStringConstructor(self): - pixmap = QPixmap(QString("Testing!")) + pixmap = QPixmap("Testing!") def testQVariantConstructor2(self): v = QVariant(QPixmap()) diff --git a/tests/QtGui/qstring_qkeysequence_test.py b/tests/QtGui/qstring_qkeysequence_test.py index 1f435e6..15db935 100644 --- a/tests/QtGui/qstring_qkeysequence_test.py +++ b/tests/QtGui/qstring_qkeysequence_test.py @@ -5,7 +5,7 @@ import unittest from helper import UsesQApplication -from PySide.QtCore import QString +from PySide.QtCore import * from PySide.QtGui import QKeySequence, QAction class QStringQKeySequenceTest(UsesQApplication): @@ -14,21 +14,12 @@ class QStringQKeySequenceTest(UsesQApplication): def testQStringFromQKeySequence(self): '''Creates a QString from a QKeySequence.''' keyseq = 'Ctrl+A' - a = QString(QKeySequence(keyseq)) + a = QKeySequence(keyseq) self.assertEqual(a, keyseq) - def testQStringAsQKeySequence(self): - '''Passes a QString to an argument expecting a QKeySequence.''' - keyseq = QString('Ctrl+A') - action = QAction(None) - action.setShortcut(keyseq) - shortcut = action.shortcut() - self.assert_(isinstance(shortcut, QKeySequence)) - self.assertEqual(shortcut.toString(), keyseq) - def testPythonStringAsQKeySequence(self): '''Passes a Python string to an argument expecting a QKeySequence.''' - keyseq = 'Ctrl+A' + keyseq = u'Ctrl+A' action = QAction(None) action.setShortcut(keyseq) shortcut = action.shortcut() diff --git a/tests/QtSql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py index 49f2209..2d5a0a3 100755 --- a/tests/QtSql/qsqldatabaseandqueries_test.py +++ b/tests/QtSql/qsqldatabaseandqueries_test.py @@ -5,14 +5,14 @@ import sys import unittest from PySide import QtSql -from PySide.QtCore import QVariant, QString +from PySide.QtCore import * class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase): '''Test cases for QtSql database creation, destruction and queries''' def setUp(self): #Acquire resources - self.assertFalse(QtSql.QSqlDatabase.drivers().isEmpty(), "installed Qt has no DB drivers") + self.assertFalse(not QtSql.QSqlDatabase.drivers(), "installed Qt has no DB drivers") self.assertTrue("QSQLITE" in QtSql.QSqlDatabase.drivers(), "\"QSQLITE\" driver not available in this Qt version") self.db = QtSql.QSqlDatabase.addDatabase("QSQLITE") self.db.setDatabaseName(":memory:") diff --git a/tests/phonon/capabilities_test.py b/tests/phonon/capabilities_test.py index 5f4b7da..99c6473 100644 --- a/tests/phonon/capabilities_test.py +++ b/tests/phonon/capabilities_test.py @@ -1,7 +1,7 @@ import unittest -from PySide.QtCore import QString +from PySide.QtCore import * from PySide import phonon from helper import UsesQCoreApplication @@ -36,7 +36,7 @@ class CapabilitiesTest(UsesQCoreApplication): # TODO Improve this test mimeTypes = phonon.Phonon.BackendCapabilities.availableMimeTypes() for mime in mimeTypes: - self.assert_(isinstance(mime, QString)) + self.assert_(isinstance(mime, unicode)) def testAudioEffects(self): # TODO Improve this test diff --git a/tests/signals/decorators_test.py b/tests/signals/decorators_test.py index db068d0..db32ec9 100755 --- a/tests/signals/decorators_test.py +++ b/tests/signals/decorators_test.py @@ -24,7 +24,7 @@ class MyObject(QObject): def foo(self): self._slotCalledCount = self._slotCalledCount + 1 - @Slot(QString, int) + @Slot(unicode, int) def mySlot4(self, a, b): self._slotCalledCount = self._slotCalledCount + 1 @@ -41,7 +41,7 @@ class StaticMetaObjectTest(unittest.TestCase): self.assert_(m.indexOfSlot('mySlot2(int)') > 0) self.assert_(m.indexOfSlot('mySlot2(QString)') > 0) self.assert_(m.indexOfSlot('mySlot3()') > 0) - self.assert_(m.indexOfSlot('mySlot4(QString,int)') > 0) + self.assert_(m.indexOfSlot('mySlot4(unicode,int)') > 0) def testEmission(self): o = MyObject() diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py index 614c0e6..d36665c 100755 --- a/tests/signals/signal_object_test.py +++ b/tests/signals/signal_object_test.py @@ -11,8 +11,8 @@ class MyObject(QTimer): sig1 = Signal() sig2 = Signal(int, name='rangeChanged') sig3 = Signal(int) - sig4 = Signal((int,), (QString,)) - sig5 = Signal((QString,), (int,)) + sig4 = Signal((int,), (unicode,)) + sig5 = Signal((unicode,), (int,)) @Slot(int) @@ -50,8 +50,8 @@ class SignalObjectTest(UsesQCoreApplication): def testDictOperator(self): o = MyObject() - o.sig4[QString].connect(o.slotString) - o.sig4[QString].emit("PySide") + o.sig4[unicode].connect(o.slotString) + o.sig4[unicode].emit("PySide") self.assertEqual(o._s, "PySide") def testGeneretedSignal(self): From ccd189d30c284e9a67a802193ef05c4149108f9a Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 8 Jun 2010 09:57:21 -0300 Subject: [PATCH 0013/1129] Add checkType method to PySide custom converters. --- PySide/QtCore/qchar_conversions.h | 9 +++++++-- PySide/QtCore/qstring_conversions.h | 8 ++++++-- PySide/QtCore/qstringref_conversions.h | 3 +-- PySide/QtCore/qvariant_conversions.h | 5 +++++ PySide/QtGui/qpixmap_conversion.h | 23 ++++++++++++++--------- libpyside/pysideconversions.h | 16 ++++++++++++++++ 6 files changed, 49 insertions(+), 15 deletions(-) diff --git a/PySide/QtCore/qchar_conversions.h b/PySide/QtCore/qchar_conversions.h index ab477ef..1ebcb64 100644 --- a/PySide/QtCore/qchar_conversions.h +++ b/PySide/QtCore/qchar_conversions.h @@ -1,12 +1,17 @@ namespace Shiboken { template<> -class Converter +struct Converter { -public: + static bool checkType(PyObject* pyObj) + { + return PyString_Check(pyObj) && (PyString_Size(pyObj) == 1); + } + static bool isConvertible(PyObject* pyObj) { return (PyString_Check(pyObj) && (PyString_Size(pyObj) == 1)) + || pyObj == Py_None || PyInt_Check(pyObj); } diff --git a/PySide/QtCore/qstring_conversions.h b/PySide/QtCore/qstring_conversions.h index 392f0e7..04b46f4 100644 --- a/PySide/QtCore/qstring_conversions.h +++ b/PySide/QtCore/qstring_conversions.h @@ -1,9 +1,13 @@ namespace Shiboken { template<> -class Converter +struct Converter { -public: + static bool checkType(PyObject* pyObj) + { + return PyString_Check(pyObj) || PyUnicode_Check(pyObj); + } + static bool isConvertible(PyObject* pyObj) { return PyString_Check(pyObj) diff --git a/PySide/QtCore/qstringref_conversions.h b/PySide/QtCore/qstringref_conversions.h index 11e1b9c..db3eefc 100644 --- a/PySide/QtCore/qstringref_conversions.h +++ b/PySide/QtCore/qstringref_conversions.h @@ -7,8 +7,7 @@ struct Converter : public Converter static PyObject* toPython(const QStringRef& cppObj) { - const QString* str = cppObj.string(); - return Converter::toPython(*str); + return Converter::toPython(cppObj.toString()); } static QStringRef toCpp(PyObject* pyObj) diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index f0f78a0..aa6d521 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -12,6 +12,11 @@ Q_DECLARE_METATYPE(PyQt_PyObject) namespace Shiboken { +inline bool Converter::checkType(PyObject* pyObj) +{ + return ValueTypeConverter::checkType(pyObj); +} + // all types are convertible to QVariant inline bool Converter::isConvertible(PyObject* pyObj) { diff --git a/PySide/QtGui/qpixmap_conversion.h b/PySide/QtGui/qpixmap_conversion.h index 10b4803..1423959 100644 --- a/PySide/QtGui/qpixmap_conversion.h +++ b/PySide/QtGui/qpixmap_conversion.h @@ -1,14 +1,19 @@ namespace Shiboken { -inline bool Converter< QPixmap >::isConvertible(PyObject* pyobj) +inline bool Converter::checkType(PyObject* pyObj) +{ + return ValueTypeConverter::checkType(pyObj); +} + +inline bool Converter::isConvertible(PyObject* pyobj) { if (ValueTypeConverter::isConvertible(pyobj)) return true; SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - bool isVariant = SbkQVariant_Check(pyobj); + bool isVariant = Converter::checkType(pyobj); if (isVariant) { QVariant var(Converter::toCpp(pyobj)); return var.type() == QVariant::Pixmap; - } else if (SbkQSize_Check(pyobj) || SbkQString_Check(pyobj)) { + } else if (Converter::checkType(pyobj) || Converter::checkType(pyobj)) { return true; } else if (shiboType->ext_isconvertible) { return shiboType->ext_isconvertible(pyobj); @@ -17,17 +22,17 @@ inline bool Converter< QPixmap >::isConvertible(PyObject* pyobj) } -inline QPixmap Converter< QPixmap >::toCpp(PyObject* pyobj) +inline QPixmap Converter::toCpp(PyObject* pyobj) { SbkBaseWrapperType* shiboType = reinterpret_cast(SbkType()); - bool isVariant = SbkQVariant_Check(pyobj); + bool isVariant = Converter::checkType(pyobj); if (isVariant) { QVariant var(Converter::toCpp(pyobj)); return var.value(); - } else if (SbkQSize_Check(pyobj)) { - return QPixmap(Shiboken::Converter::toCpp(pyobj)); - } else if (SbkQString_Check(pyobj)) { - return QPixmap(Shiboken::Converter::toCpp(pyobj)); + } else if (Converter::checkType(pyobj)) { + return QPixmap(Shiboken::Converter::toCpp(pyobj)); + } else if (Converter::checkType(pyobj)) { + return QPixmap(Shiboken::Converter::toCpp(pyobj)); } else if (shiboType->ext_isconvertible && shiboType->ext_tocpp && shiboType->ext_isconvertible(pyobj)) { QPixmap* cptr = reinterpret_cast(shiboType->ext_tocpp(pyobj)); std::auto_ptr cptr_auto_ptr(cptr); diff --git a/libpyside/pysideconversions.h b/libpyside/pysideconversions.h index 9539b11..86f5003 100644 --- a/libpyside/pysideconversions.h +++ b/libpyside/pysideconversions.h @@ -41,6 +41,11 @@ template struct QtDictConverter { + static inline bool checkType(PyObject* pyObj) + { + return isConvertible(pyObj); + } + static inline bool isConvertible(PyObject* pyObj) { if (PyObject_TypeCheck(pyObj, Shiboken::SbkType())) @@ -95,6 +100,11 @@ struct QtDictConverter template struct QtMultiMapConverter { + static inline bool checkType(PyObject* pyObj) + { + return isConvertible(pyObj); + } + static inline bool isConvertible(PyObject* pyObj) { if (PyObject_TypeCheck(pyObj, Shiboken::SbkType())) @@ -145,6 +155,7 @@ struct QtMultiMapConverter return result; } + static inline MultiMap toCpp(PyObject* pyObj) { if (PyObject_TypeCheck(pyObj, Shiboken::SbkType())) @@ -165,6 +176,11 @@ struct QtMultiMapConverter template struct QSequenceConverter { + static inline bool checkType(PyObject* pyObj) + { + return isConvertible(pyObj); + } + static inline bool isConvertible(PyObject* pyObj) { if (PyObject_TypeCheck(pyObj, Shiboken::SbkType())) From 00918cb847dfa1b28acb791c66cb444bc2123f79 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 8 Jun 2010 09:59:01 -0300 Subject: [PATCH 0014/1129] Added QDataStream methods to read and write QString, QChar and QStringList. --- PySide/QtCore/typesystem_core.xml | 52 ++++++++++++++++++++++++++++++- tests/QtCore/qdatastream_test.py | 46 +++++++++------------------ 2 files changed, 66 insertions(+), 32 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 56c8b30..6258861 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2050,6 +2050,7 @@ + @@ -2062,8 +2063,57 @@ - + + + + *(%CPPSELF) << %1; + + + + + %RETURN_TYPE val; + *(%CPPSELF) >> val; + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); + + + + + *(%CPPSELF) << %1; + + + + + %RETURN_TYPE val; + *(%CPPSELF) >> val; + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); + + + + + *(%CPPSELF) << %1; + + + + + %RETURN_TYPE val; + *(%CPPSELF) >> val; + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); + + + + + *(%CPPSELF) << %1; + + + + + %RETURN_TYPE val; + *(%CPPSELF) >> val; + %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](val); + + + diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py index e809185..b634a7e 100644 --- a/tests/QtCore/qdatastream_test.py +++ b/tests/QtCore/qdatastream_test.py @@ -76,22 +76,17 @@ class QDataStreamShift(unittest.TestCase): def testQCharValid(self): '''QDataStream <<>> QChar - valid''' - self.stream << QChar(42) + self.stream.writeQChar(42) - res = QChar() - - self.read_stream >> res - self.assertEqual(res, QChar(42)) + res = self.read_stream.readQChar() + self.assertEqual(res, unichr(42)) def testQCharNull(self): '''QDataStream <<>> QChar - null''' - self.stream << QChar() + self.stream.writeQChar(None) - res = QChar() - - self.read_stream >> res - self.assertEqual(res, QChar()) - self.assert_(res.isNull()) + res = self.read_stream.readQChar() + self.assertEqual(res, u'\x00') def testQByteArrayValid(self): '''QDataStream <<>> QByteArray - valid''' @@ -126,35 +121,24 @@ class QDataStreamShift(unittest.TestCase): def testQStringValid(self): '''QDataStream <<>> QString - valid''' - self.stream << QString('Ka-boom') + self.stream.writeQString('Ka-boom') - res = QString() - - self.read_stream >> res - self.assertEqual(res, QString('Ka-boom')) + res = self.read_stream.readQString() + self.assertEqual(res, u'Ka-boom') def testQStringEmpty(self): '''QDataStream <<>> QString - empty''' - self.stream << QString('') + self.stream.writeQString('') - res = QString() - - self.read_stream >> res - self.assertEqual(res, QString("")) - self.assert_(res.isEmpty()) - self.assert_(not res.isNull()) + res = self.read_stream.readQString() + self.assertEqual(res, u'') def testQStringNull(self): '''QDataStream <<>> QString - null''' - self.stream << QString() - - res = QString() - - self.read_stream >> res - self.assertEqual(res, QString()) - self.assert_(res.isEmpty()) - self.assert_(res.isNull()) + self.stream.writeQString(None) + res = self.read_stream.readQString() + self.assertEqual(res, u'') def testQBitArrayNull(self): '''QDataStream <<>> QBitArray - null''' From e47b49f86d63845fe214768838c4fc7c55e3012a Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 8 Jun 2010 11:17:48 -0300 Subject: [PATCH 0015/1129] Re-add the possibility to run tests by module. --- tests/CMakeLists.txt | 5 +++-- tests/QtCore/CMakeLists.txt | 3 +-- tests/QtCore/{thread_signals.py => thread_signals_test.py} | 0 tests/QtGui/CMakeLists.txt | 4 ++-- ...irtual_pure_override.py => virtual_pure_override_test.py} | 0 tests/QtGui/{x11_symbols.py => x11_symbols_test.py} | 0 tests/QtScript/CMakeLists.txt | 1 - tests/QtScript/test_base.py | 4 ---- tests/signals/CMakeLists.txt | 2 +- ...type_support.py => signal_connectiontype_support_test.py} | 0 10 files changed, 7 insertions(+), 12 deletions(-) rename tests/QtCore/{thread_signals.py => thread_signals_test.py} (100%) rename tests/QtGui/{virtual_pure_override.py => virtual_pure_override_test.py} (100%) rename tests/QtGui/{x11_symbols.py => x11_symbols_test.py} (100%) delete mode 100644 tests/QtScript/test_base.py rename tests/signals/{signal_connectiontype_support.py => signal_connectiontype_support_test.py} (100%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d87414f..d446151 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,8 @@ macro(TEST_QT_MODULE var name) endmacro(TEST_QT_MODULE) macro(PYSIDE_TEST) - set(TEST_NAME ${ARGV0}) + string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" ) + set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") if (${ARGC} EQUAL 1) set(EXPECT_TO_FAIL 0) elseif(${ARGC} EQUAL 2) @@ -15,7 +16,7 @@ macro(PYSIDE_TEST) else() message(WARNING "Ivalid call of macro PYSIDE_TEST") endif() - set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_NAME}") + set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") add_test(${TEST_NAME} ${TEST_CMD}) set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT ${PYSIDE_TIMEOUT} diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 4a78bf6..cce1332 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -57,10 +57,9 @@ PYSIDE_TEST(qtnamespace_test.py) PYSIDE_TEST(qurl_test.py) PYSIDE_TEST(qvariant_pyobject_test.py) PYSIDE_TEST(qvariant_test.py) -PYSIDE_TEST(resources_mc.py) PYSIDE_TEST(static_method_test.py) PYSIDE_TEST(static_protected_methods_test.py) -PYSIDE_TEST(thread_signals.py) +PYSIDE_TEST(thread_signals_test.py) PYSIDE_TEST(translation_test.py) PYSIDE_TEST(unaryoperator_test.py) PYSIDE_TEST(unicode_test.py) diff --git a/tests/QtCore/thread_signals.py b/tests/QtCore/thread_signals_test.py similarity index 100% rename from tests/QtCore/thread_signals.py rename to tests/QtCore/thread_signals_test.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index fb6d801..fa5de4a 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -53,6 +53,6 @@ PYSIDE_TEST(reference_count_test.py) PYSIDE_TEST(standardpixmap_test.py) PYSIDE_TEST(timed_app_test.py) PYSIDE_TEST(virtual_protected_inheritance_test.py) -PYSIDE_TEST(virtual_pure_override.py) +PYSIDE_TEST(virtual_pure_override_test.py) PYSIDE_TEST(wrong_return_test.py) -PYSIDE_TEST(x11_symbols.py) +PYSIDE_TEST(x11_symbols_test.py) diff --git a/tests/QtGui/virtual_pure_override.py b/tests/QtGui/virtual_pure_override_test.py similarity index 100% rename from tests/QtGui/virtual_pure_override.py rename to tests/QtGui/virtual_pure_override_test.py diff --git a/tests/QtGui/x11_symbols.py b/tests/QtGui/x11_symbols_test.py similarity index 100% rename from tests/QtGui/x11_symbols.py rename to tests/QtGui/x11_symbols_test.py diff --git a/tests/QtScript/CMakeLists.txt b/tests/QtScript/CMakeLists.txt index b76a262..e496591 100644 --- a/tests/QtScript/CMakeLists.txt +++ b/tests/QtScript/CMakeLists.txt @@ -1,3 +1,2 @@ PYSIDE_TEST(base_test.py) PYSIDE_TEST(engine_test.py) -PYSIDE_TEST(test_base.py) diff --git a/tests/QtScript/test_base.py b/tests/QtScript/test_base.py deleted file mode 100644 index 6ad27e0..0000000 --- a/tests/QtScript/test_base.py +++ /dev/null @@ -1,4 +0,0 @@ -from PySide import QtScript - - -#only test if the module import works fine bug #278 diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index 3e59684..a6d564f 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -20,7 +20,7 @@ PYSIDE_TEST(self_connect_test.py) PYSIDE_TEST(short_circuit_test.py) PYSIDE_TEST(signal2signal_connect_test.py) PYSIDE_TEST(signal_autoconnect_test.py) -PYSIDE_TEST(signal_connectiontype_support.py) +PYSIDE_TEST(signal_connectiontype_support_test.py) PYSIDE_TEST(signal_emission_gui_test.py) PYSIDE_TEST(signal_emission_test.py) PYSIDE_TEST(signal_func_test.py) diff --git a/tests/signals/signal_connectiontype_support.py b/tests/signals/signal_connectiontype_support_test.py similarity index 100% rename from tests/signals/signal_connectiontype_support.py rename to tests/signals/signal_connectiontype_support_test.py From f1327b5a5fe52ac41a96096f214c93c6a082195d Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 8 Jun 2010 11:23:56 -0300 Subject: [PATCH 0016/1129] chmod -x on some tests, because we need to follow a pattern. --- tests/QtCore/qbitarray_test.py | 0 tests/QtCore/qbytearray_buffer_protocol_test.py | 0 tests/QtCore/qbytearray_concatenation_operator_test.py | 0 tests/QtCore/qcoreapplication_instance_test.py | 0 tests/QtCore/qthread_signal_test.py | 0 tests/QtCore/static_method_test.py | 0 tests/QtCore/unaryoperator_test.py | 0 tests/QtGui/customproxywidget_test.py | 0 tests/QtGui/keep_reference_test.py | 0 tests/QtGui/qgraphicsitem_isblocked_test.py | 0 tests/QtGui/qgraphicsproxywidget_test.py | 0 tests/QtGui/qstyle_test.py | 0 tests/QtSql/qsqldatabaseandqueries_test.py | 0 tests/phonon/basic_playing_test.py | 0 tests/signals/args_dont_match_test.py | 0 tests/signals/decorators_test.py | 0 tests/signals/invalid_callback_test.py | 0 tests/signals/lambda_gui_test.py | 0 tests/signals/lambda_test.py | 0 tests/signals/multiple_connections_gui_test.py | 0 tests/signals/multiple_connections_test.py | 0 tests/signals/pysignal_test.py | 0 tests/signals/qobject_destroyed_test.py | 0 tests/signals/qobject_receivers_test.py | 0 tests/signals/qobject_sender_test.py | 0 tests/signals/ref01_test.py | 0 tests/signals/ref02_test.py | 0 tests/signals/ref03_test.py | 0 tests/signals/ref04_test.py | 0 tests/signals/ref05_test.py | 0 tests/signals/ref06_test.py | 0 tests/signals/segfault_proxyparent_test.py | 0 tests/signals/self_connect_test.py | 0 tests/signals/short_circuit_test.py | 0 tests/signals/signal2signal_connect_test.py | 0 tests/signals/signal_autoconnect_test.py | 0 tests/signals/signal_connectiontype_support_test.py | 0 tests/signals/signal_emission_gui_test.py | 0 tests/signals/signal_emission_test.py | 0 tests/signals/signal_func_test.py | 0 tests/signals/signal_manager_refcount_test.py | 0 tests/signals/signal_object_test.py | 0 tests/signals/signal_with_primitive_type_test.py | 0 tests/signals/slot_reference_count_test.py | 0 tests/signals/static_metaobject_test.py | 0 tests/signals/upstream_segfault_test.py | 0 tests/util/processtimer.py | 0 tests/util/pyqtcheck.py | 0 48 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/QtCore/qbitarray_test.py mode change 100755 => 100644 tests/QtCore/qbytearray_buffer_protocol_test.py mode change 100755 => 100644 tests/QtCore/qbytearray_concatenation_operator_test.py mode change 100755 => 100644 tests/QtCore/qcoreapplication_instance_test.py mode change 100755 => 100644 tests/QtCore/qthread_signal_test.py mode change 100755 => 100644 tests/QtCore/static_method_test.py mode change 100755 => 100644 tests/QtCore/unaryoperator_test.py mode change 100755 => 100644 tests/QtGui/customproxywidget_test.py mode change 100755 => 100644 tests/QtGui/keep_reference_test.py mode change 100755 => 100644 tests/QtGui/qgraphicsitem_isblocked_test.py mode change 100755 => 100644 tests/QtGui/qgraphicsproxywidget_test.py mode change 100755 => 100644 tests/QtGui/qstyle_test.py mode change 100755 => 100644 tests/QtSql/qsqldatabaseandqueries_test.py mode change 100755 => 100644 tests/phonon/basic_playing_test.py mode change 100755 => 100644 tests/signals/args_dont_match_test.py mode change 100755 => 100644 tests/signals/decorators_test.py mode change 100755 => 100644 tests/signals/invalid_callback_test.py mode change 100755 => 100644 tests/signals/lambda_gui_test.py mode change 100755 => 100644 tests/signals/lambda_test.py mode change 100755 => 100644 tests/signals/multiple_connections_gui_test.py mode change 100755 => 100644 tests/signals/multiple_connections_test.py mode change 100755 => 100644 tests/signals/pysignal_test.py mode change 100755 => 100644 tests/signals/qobject_destroyed_test.py mode change 100755 => 100644 tests/signals/qobject_receivers_test.py mode change 100755 => 100644 tests/signals/qobject_sender_test.py mode change 100755 => 100644 tests/signals/ref01_test.py mode change 100755 => 100644 tests/signals/ref02_test.py mode change 100755 => 100644 tests/signals/ref03_test.py mode change 100755 => 100644 tests/signals/ref04_test.py mode change 100755 => 100644 tests/signals/ref05_test.py mode change 100755 => 100644 tests/signals/ref06_test.py mode change 100755 => 100644 tests/signals/segfault_proxyparent_test.py mode change 100755 => 100644 tests/signals/self_connect_test.py mode change 100755 => 100644 tests/signals/short_circuit_test.py mode change 100755 => 100644 tests/signals/signal2signal_connect_test.py mode change 100755 => 100644 tests/signals/signal_autoconnect_test.py mode change 100755 => 100644 tests/signals/signal_connectiontype_support_test.py mode change 100755 => 100644 tests/signals/signal_emission_gui_test.py mode change 100755 => 100644 tests/signals/signal_emission_test.py mode change 100755 => 100644 tests/signals/signal_func_test.py mode change 100755 => 100644 tests/signals/signal_manager_refcount_test.py mode change 100755 => 100644 tests/signals/signal_object_test.py mode change 100755 => 100644 tests/signals/signal_with_primitive_type_test.py mode change 100755 => 100644 tests/signals/slot_reference_count_test.py mode change 100755 => 100644 tests/signals/static_metaobject_test.py mode change 100755 => 100644 tests/signals/upstream_segfault_test.py mode change 100755 => 100644 tests/util/processtimer.py mode change 100755 => 100644 tests/util/pyqtcheck.py diff --git a/tests/QtCore/qbitarray_test.py b/tests/QtCore/qbitarray_test.py old mode 100755 new mode 100644 diff --git a/tests/QtCore/qbytearray_buffer_protocol_test.py b/tests/QtCore/qbytearray_buffer_protocol_test.py old mode 100755 new mode 100644 diff --git a/tests/QtCore/qbytearray_concatenation_operator_test.py b/tests/QtCore/qbytearray_concatenation_operator_test.py old mode 100755 new mode 100644 diff --git a/tests/QtCore/qcoreapplication_instance_test.py b/tests/QtCore/qcoreapplication_instance_test.py old mode 100755 new mode 100644 diff --git a/tests/QtCore/qthread_signal_test.py b/tests/QtCore/qthread_signal_test.py old mode 100755 new mode 100644 diff --git a/tests/QtCore/static_method_test.py b/tests/QtCore/static_method_test.py old mode 100755 new mode 100644 diff --git a/tests/QtCore/unaryoperator_test.py b/tests/QtCore/unaryoperator_test.py old mode 100755 new mode 100644 diff --git a/tests/QtGui/customproxywidget_test.py b/tests/QtGui/customproxywidget_test.py old mode 100755 new mode 100644 diff --git a/tests/QtGui/keep_reference_test.py b/tests/QtGui/keep_reference_test.py old mode 100755 new mode 100644 diff --git a/tests/QtGui/qgraphicsitem_isblocked_test.py b/tests/QtGui/qgraphicsitem_isblocked_test.py old mode 100755 new mode 100644 diff --git a/tests/QtGui/qgraphicsproxywidget_test.py b/tests/QtGui/qgraphicsproxywidget_test.py old mode 100755 new mode 100644 diff --git a/tests/QtGui/qstyle_test.py b/tests/QtGui/qstyle_test.py old mode 100755 new mode 100644 diff --git a/tests/QtSql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py old mode 100755 new mode 100644 diff --git a/tests/phonon/basic_playing_test.py b/tests/phonon/basic_playing_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/args_dont_match_test.py b/tests/signals/args_dont_match_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/decorators_test.py b/tests/signals/decorators_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/invalid_callback_test.py b/tests/signals/invalid_callback_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/lambda_gui_test.py b/tests/signals/lambda_gui_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/lambda_test.py b/tests/signals/lambda_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/multiple_connections_gui_test.py b/tests/signals/multiple_connections_gui_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/multiple_connections_test.py b/tests/signals/multiple_connections_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/pysignal_test.py b/tests/signals/pysignal_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/qobject_destroyed_test.py b/tests/signals/qobject_destroyed_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/qobject_receivers_test.py b/tests/signals/qobject_receivers_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/qobject_sender_test.py b/tests/signals/qobject_sender_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/ref01_test.py b/tests/signals/ref01_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/ref02_test.py b/tests/signals/ref02_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/ref03_test.py b/tests/signals/ref03_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/ref04_test.py b/tests/signals/ref04_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/ref05_test.py b/tests/signals/ref05_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/ref06_test.py b/tests/signals/ref06_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/segfault_proxyparent_test.py b/tests/signals/segfault_proxyparent_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/self_connect_test.py b/tests/signals/self_connect_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/short_circuit_test.py b/tests/signals/short_circuit_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal2signal_connect_test.py b/tests/signals/signal2signal_connect_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_autoconnect_test.py b/tests/signals/signal_autoconnect_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_connectiontype_support_test.py b/tests/signals/signal_connectiontype_support_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_emission_gui_test.py b/tests/signals/signal_emission_gui_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_emission_test.py b/tests/signals/signal_emission_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_func_test.py b/tests/signals/signal_func_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_manager_refcount_test.py b/tests/signals/signal_manager_refcount_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/signal_with_primitive_type_test.py b/tests/signals/signal_with_primitive_type_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/slot_reference_count_test.py b/tests/signals/slot_reference_count_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/static_metaobject_test.py b/tests/signals/static_metaobject_test.py old mode 100755 new mode 100644 diff --git a/tests/signals/upstream_segfault_test.py b/tests/signals/upstream_segfault_test.py old mode 100755 new mode 100644 diff --git a/tests/util/processtimer.py b/tests/util/processtimer.py old mode 100755 new mode 100644 diff --git a/tests/util/pyqtcheck.py b/tests/util/pyqtcheck.py old mode 100755 new mode 100644 From d8a192b5e14e996992a98766cd39ca2028e6474e Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 9 Jun 2010 16:45:24 -0300 Subject: [PATCH 0017/1129] Remove registration of PySide primitive types, the generator do this automatically. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Luciano Wolf Renato Araújo --- libpyside/signalmanager.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index f1b39b9..80d7254 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -202,23 +202,6 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate) qRegisterMetaType(PYTHON_TYPE); TypeResolver::createValueTypeResolver(PYTHON_TYPE); - TypeResolver::createValueTypeResolver("qint8"); - TypeResolver::createValueTypeResolver("qint16"); - TypeResolver::createValueTypeResolver("qint32"); - TypeResolver::createValueTypeResolver("qint64"); - TypeResolver::createValueTypeResolver("qlonglong"); - TypeResolver::createValueTypeResolver("qptrdiff"); - TypeResolver::createValueTypeResolver("qreal"); - TypeResolver::createValueTypeResolver("quint8"); - TypeResolver::createValueTypeResolver("quint16"); - TypeResolver::createValueTypeResolver("quint32"); - TypeResolver::createValueTypeResolver("quint64"); - TypeResolver::createValueTypeResolver("quintptr"); - TypeResolver::createValueTypeResolver("qulonglong"); - TypeResolver::createValueTypeResolver("uchar"); - TypeResolver::createValueTypeResolver("uint"); - TypeResolver::createValueTypeResolver("ulong"); - TypeResolver::createValueTypeResolver("ushort"); } void SignalManager::clear() From 1b6337d8b4a65988dfbeb0eed67bc6584b25fdee Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 10 Jun 2010 19:57:18 -0300 Subject: [PATCH 0018/1129] Removed QVariant from PySide. Reviewer: Luciano Wolf Marcelo Lira --- PySide/QtCore/CMakeLists.txt | 1 - PySide/QtCore/qvariant_conversions.h | 155 +++++++++-------- PySide/QtCore/typesystem_core.xml | 187 +-------------------- libpyside/pyside.cpp | 3 + libpyside/signalmanager.cpp | 25 +-- libpyside/signalmanager.h | 14 ++ tests/QtCore/CMakeLists.txt | 2 - tests/QtCore/qabstracttransition_test.py | 7 +- tests/QtCore/qanimationgroup_test.py | 2 +- tests/QtCore/qobject_property_test.py | 66 +++++--- tests/QtCore/qstate_test.py | 8 +- tests/QtCore/qvariant_pyobject_test.py | 68 -------- tests/QtCore/qvariant_test.py | 124 -------------- tests/QtGui/CMakeLists.txt | 1 - tests/QtGui/keep_reference_test.py | 4 +- tests/QtGui/qpixmap_test.py | 11 +- tests/QtGui/qvariant_test.py | 85 ---------- tests/QtSql/qsqldatabaseandqueries_test.py | 8 +- 18 files changed, 170 insertions(+), 601 deletions(-) delete mode 100644 tests/QtCore/qvariant_pyobject_test.py delete mode 100644 tests/QtCore/qvariant_test.py delete mode 100644 tests/QtGui/qvariant_test.py diff --git a/PySide/QtCore/CMakeLists.txt b/PySide/QtCore/CMakeLists.txt index bbe8ba7..12a2f4a 100644 --- a/PySide/QtCore/CMakeLists.txt +++ b/PySide/QtCore/CMakeLists.txt @@ -120,7 +120,6 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtimerevent_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qtranslator_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qurl_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/quuid_wrapper.cpp -${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qvariant_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qwaitcondition_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qwritelocker_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/qxmlstreamattribute_wrapper.cpp diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index aa6d521..076ed7f 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -1,86 +1,83 @@ -// We use this thin wrapper instead of the plain PyObject pointer to avoid conflicts with specializations of T* -// in QVariant. -struct PyQt_PyObject -{ - PyObject* m_me; - PyQt_PyObject(PyObject* me) : m_me(me) {} - PyQt_PyObject() : m_me(Py_None) {} - operator PyObject*() { return m_me; } -}; - -Q_DECLARE_METATYPE(PyQt_PyObject) - namespace Shiboken { -inline bool Converter::checkType(PyObject* pyObj) +template<> +struct Converter { - return ValueTypeConverter::checkType(pyObj); -} - -// all types are convertible to QVariant -inline bool Converter::isConvertible(PyObject* pyObj) -{ - return true; -} - -inline QVariant Converter::toCpp(PyObject* pyObj) -{ - if (SbkQVariant_Check(pyObj)) - return *Converter::toCpp(pyObj); - - // Primitive types - if (PyBool_Check(pyObj)) { - // QVariant(bool) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyString_CheckExact(pyObj)) { - // QVariant(const char*) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyFloat_CheckExact(pyObj)) { - // QVariant(double) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyInt_CheckExact(pyObj)) { - // QVariant(int) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (PyLong_CheckExact(pyObj)) { - // QVariant(qlonglong) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (Shiboken::isShibokenEnum(pyObj)) { - // QVariant(enum) - return QVariant(Shiboken::Converter::toCpp(pyObj)); - } else if (!Shiboken::isShibokenType(pyObj) || Shiboken::isUserType(pyObj)) { - // QVariant(User class) - Py_INCREF(pyObj); - return QVariant::fromValue(pyObj); - } else { - // a class supported by QVariant? - const char* typeName = pyObj->ob_type->tp_name; - // check if the name starts with PySide. - if (!strncmp("PySide.", typeName, 7)) { - // get the type name - const char* lastDot = typeName; - for (int i = 8; typeName[i]; ++i) { - if (typeName[i] == '.') - lastDot = &typeName[i]; - } - lastDot++; - uint typeCode = QMetaType::type(lastDot); - if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller* - QString typeName(lastDot); - typeName += '*'; - typeCode = QMetaType::type(typeName.toAscii()); - } - if (typeCode) - return QVariant(typeCode, reinterpret_cast(pyObj)->cptr[0]); - } - // Is a shiboken type not known by Qt - Py_INCREF(pyObj); - return QVariant::fromValue(pyObj); + static bool checkType(PyObject* pyObj) + { + return false; // lets avoid the chaos } -} -inline PyObject* Converter::toPython(const QVariant& cppObj) -{ - return ValueTypeConverter::toPython(cppObj); -} + // all types are convertible to QVariant + static bool isConvertible(PyObject* pyObj) + { + return true; + } + static QVariant toCpp(PyObject* pyObj) + { + using namespace Shiboken; + + // Primitive types + if (Converter::checkType(pyObj)) { + // QVariant(bool) + return QVariant(Converter::toCpp(pyObj)); + } else if (pyObj == Py_None) { + // QVariant() + return QVariant(); + } else if (Converter::checkType(pyObj)) { + // QVariant(const char*) + return QVariant(Converter::toCpp(pyObj)); + } else if (PyFloat_CheckExact(pyObj)) { + // QVariant(double) + return QVariant(Converter::toCpp(pyObj)); + } else if (PyInt_CheckExact(pyObj)) { + // QVariant(int) + return QVariant(Converter::toCpp(pyObj)); + } else if (PyLong_CheckExact(pyObj)) { + // QVariant(qlonglong) + return QVariant(Converter::toCpp(pyObj)); + } else if (Shiboken::isShibokenEnum(pyObj)) { + // QVariant(enum) + return QVariant(Converter::toCpp(pyObj)); + } else if (!isShibokenType(pyObj) || isUserType(pyObj)) { + // QVariant(User class) + return QVariant::fromValue(pyObj); + } else { + // a class supported by QVariant? + const char* typeName = pyObj->ob_type->tp_name; + // check if the name starts with PySide. + if (!strncmp("PySide.", typeName, 7)) { + // get the type name + const char* lastDot = typeName; + for (int i = 8; typeName[i]; ++i) { + if (typeName[i] == '.') + lastDot = &typeName[i]; + } + lastDot++; + uint typeCode = QMetaType::type(lastDot); + if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller* + QString typeName(lastDot); + typeName += '*'; + typeCode = QMetaType::type(typeName.toAscii()); + } + if (typeCode) + return QVariant(typeCode, reinterpret_cast(pyObj)->cptr[0]); + } + // Is a shiboken type not known by Qt + return QVariant::fromValue(pyObj); + } + } + + static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } + static PyObject* toPython(const QVariant& cppObj) + { + if (cppObj.isValid()) { + Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(cppObj.typeName()); + if (tr) + return tr->toPython(const_cast(cppObj.data())); + } + Py_RETURN_NONE; + } +}; } diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 6258861..85694e4 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -74,7 +74,6 @@ - @@ -129,7 +128,10 @@ - + + + + @@ -154,6 +156,10 @@ + + + + @@ -248,7 +254,6 @@ - @@ -541,16 +546,6 @@ - - - - - - - - - - @@ -1241,172 +1236,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %0 = new %TYPE(%CONVERTTOCPP[QVariant](%PYARG_1)); - - - - - uint typeId = %CPPSELF.userType(); - if (typeId == qMetaTypeId<PyQt_PyObject>()) { - %PYARG_0 = %CPPSELF.value<PyQt_PyObject>(); - } else if (typeId == QVariant::String) { - %PYARG_0 = %CONVERTTOPYTHON[QString](%CPPSELF.toString()); - } else { - %PYARG_0 = Py_None; - Py_INCREF(Py_None); - } - - - - - if (%CPPSELF.isNull()) { - %PYARG_0 = Py_None; - Py_INCREF(Py_None); - } else if (%CPPSELF.userType() == qMetaTypeId<PyQt_PyObject>()) { - // emulate PyQt4 behaviour - PyObject* obj = %CPPSELF.value<PyQt_PyObject>(); - if (PySequence_Check(obj)) - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE]("QVariantList"); - } - if (!%PYARG_0) - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); - - - - - if (%CPPSELF.userType() == qMetaTypeId<PyQt_PyObject>()) { - PyObject* val = %CPPSELF.value<PyQt_PyObject>(); - if (PySequence_Check(val)) { - %PYARG_0 = val; - Py_INCREF(val); - } else { - %PYARG_0 = Py_None; - Py_INCREF(Py_None); - } - } else { - %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp index 3fa63a4..93271c8 100644 --- a/libpyside/pyside.cpp +++ b/libpyside/pyside.cpp @@ -34,6 +34,7 @@ #include "pyside.h" +#include "signalmanager.h" extern "C" void init_signal(PyObject* module); extern "C" void init_slot(PyObject* module); @@ -45,6 +46,8 @@ void init(PyObject *module) { init_signal(module); init_slot(module); + // Init signal manager, so it will register some meta types used by QVariant. + SignalManager::instance(); } } //namespace PySide diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 80d7254..7ac3f30 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -54,35 +54,22 @@ #define PYTHON_TYPE "PyObject" - -// Use this to wrap PyObject during the Signal/Slot handling -struct PyObjectWrapper -{ - PyObject* m_me; - PyObjectWrapper(const PyObjectWrapper &other) : m_me(other.m_me) {} - PyObjectWrapper(PyObject* me) : m_me(me) { Py_INCREF(m_me); } - PyObjectWrapper() : m_me(Py_None) {} - operator PyObject*() const { return m_me; } -}; - -Q_DECLARE_METATYPE(PyObjectWrapper) - namespace Shiboken { template<> -struct Converter +struct Converter { - static PyObjectWrapper toCpp(PyObject* obj) + static PySide::PyObjectWrapper toCpp(PyObject* obj) { - return PyObjectWrapper(obj); + return PySide::PyObjectWrapper(obj); } static PyObject* toPython(void* obj) { - return toPython(*reinterpret_cast(obj)); + return toPython(*reinterpret_cast(obj)); } - static PyObject* toPython(const PyObjectWrapper& obj) + static PyObject* toPython(const PySide::PyObjectWrapper& obj) { return obj; } @@ -202,6 +189,8 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate) qRegisterMetaType(PYTHON_TYPE); TypeResolver::createValueTypeResolver(PYTHON_TYPE); + TypeResolver::createValueTypeResolver("object"); + TypeResolver::createValueTypeResolver("PySide::PyObjectWrapper"); } void SignalManager::clear() diff --git a/libpyside/signalmanager.h b/libpyside/signalmanager.h index 233adf1..9687dcc 100644 --- a/libpyside/signalmanager.h +++ b/libpyside/signalmanager.h @@ -46,6 +46,17 @@ class QObject; namespace PySide { +/// Thin wrapper for PyObject which increases the reference count at the constructor but *NOT* at destructor. +class PYSIDE_API PyObjectWrapper +{ +public: + PyObjectWrapper(PyObject* me) : m_me(me) { Py_INCREF(m_me); } + PyObjectWrapper() : m_me(Py_None) { Py_INCREF(m_me); } + operator PyObject*() const { return m_me; } +private: + PyObject* m_me; +}; + PYSIDE_API bool isSignal(const char* signal); PYSIDE_API bool checkSignal(const char* signal); PYSIDE_API QString getCallbackSignature(const char* signal, PyObject* callback, bool encodeName); @@ -84,4 +95,7 @@ private: }; } + +Q_DECLARE_METATYPE(PySide::PyObjectWrapper) + #endif diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index cce1332..35fa7b9 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -55,8 +55,6 @@ PYSIDE_TEST(qtimer_singleshot_test.py) PYSIDE_TEST(qtimer_timeout_test.py) PYSIDE_TEST(qtnamespace_test.py) PYSIDE_TEST(qurl_test.py) -PYSIDE_TEST(qvariant_pyobject_test.py) -PYSIDE_TEST(qvariant_test.py) PYSIDE_TEST(static_method_test.py) PYSIDE_TEST(static_protected_methods_test.py) PYSIDE_TEST(thread_signals_test.py) diff --git a/tests/QtCore/qabstracttransition_test.py b/tests/QtCore/qabstracttransition_test.py index 510b8ef..4ba6d83 100644 --- a/tests/QtCore/qabstracttransition_test.py +++ b/tests/QtCore/qabstracttransition_test.py @@ -1,8 +1,7 @@ #!/usr/bin/python import unittest from sys import getrefcount -from PySide.QtCore import QObject, SIGNAL, QCoreApplication, QTimer, QVariant -from PySide.QtCore import QState, QFinalState, QStateMachine, QParallelAnimationGroup, QEventTransition +from PySide.QtCore import * def addStates(transition): sx = QState() @@ -19,11 +18,11 @@ class QAbstractTransitionTest(unittest.TestCase): app = QCoreApplication([]) o = QObject() - o.setProperty("text", QVariant("INdT")) + o.setProperty("text", "INdT") machine = QStateMachine() s1 = QState() - s1.assignProperty(o, "text", QVariant("Rocks")) + s1.assignProperty(o, "text", "Rocks") s2 = QFinalState() t = s1.addTransition(o, SIGNAL("change()"), s2) diff --git a/tests/QtCore/qanimationgroup_test.py b/tests/QtCore/qanimationgroup_test.py index 05bd81e..58886d1 100644 --- a/tests/QtCore/qanimationgroup_test.py +++ b/tests/QtCore/qanimationgroup_test.py @@ -1,6 +1,6 @@ #!/usr/bin/python import unittest -from PySide.QtCore import QObject, QState, QFinalState, SIGNAL, QCoreApplication, QTimer, QStateMachine, QSignalTransition, QVariant, QParallelAnimationGroup, QSequentialAnimationGroup, QAnimationGroup +from PySide.QtCore import * class QAnimationGroupTest(unittest.TestCase): diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index d1f12b3..e94562c 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -5,16 +5,24 @@ import unittest from PySide.QtCore import * +class Dummy(object): + '''Pure python sample class''' + pass + +class MySize(QSize): + '''Extended class''' + pass + class PropertyCase(unittest.TestCase): '''Test case for QObject properties''' def testObjectNameProperty(self): #QObject.setProperty() for existing C++ property obj = QObject() - self.assert_(obj.setProperty('objectName', QVariant('dummy'))) + self.assert_(obj.setProperty('objectName', 'dummy')) self.assertEqual(obj.objectName(), 'dummy') - self.assert_(obj.setProperty('objectName', QVariant('foobar'))) + self.assert_(obj.setProperty('objectName', 'foobar')) self.assertEqual(obj.objectName(), 'foobar') def testDynamicProperty(self): @@ -22,50 +30,66 @@ class PropertyCase(unittest.TestCase): obj = QObject() # Should return false when creating a new dynamic property - self.assert_(not obj.setProperty('dummy', QVariant('mydata'))) + self.assert_(not obj.setProperty('dummy', 'mydata')) prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'mydata') + self.assert_(isinstance(prop, unicode)) + self.assertEqual(obj.property('dummy'), 'mydata') - self.assert_(not obj.setProperty('dummy', QVariant('zigzag'))) + self.assert_(not obj.setProperty('dummy', 'zigzag')) prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'zigzag') + self.assert_(isinstance(prop, unicode)) + self.assertEqual(obj.property('dummy'), 'zigzag') - self.assert_(not obj.setProperty('dummy', QVariant(42))) + self.assert_(not obj.setProperty('dummy', 42)) prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) + self.assert_(isinstance(prop, int)) # QVariant.toInt has a bool* arg in C++, so returns a tuple - self.assertEqual(obj.property('dummy').toInt(), (42, True)) + self.assertEqual(obj.property('dummy'), 42) def testStringProperty(self): obj = QObject() self.assert_(not obj.setProperty('dummy', 'data')) prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'data') + self.assert_(isinstance(prop, unicode)) + self.assertEqual(obj.property('dummy'), 'data') def testImplicitQVariantProperty(self): obj = QObject() self.assert_(not obj.setProperty('dummy', 'data')) prop = obj.property('dummy') - self.assert_(isinstance(prop, QVariant)) - self.assert_(prop.isValid()) - self.assertEqual(obj.property('dummy').toString(), 'data') + self.assert_(isinstance(prop, unicode)) + self.assertEqual(obj.property('dummy'), 'data') def testInvalidProperty(self): #QObject.property() for invalid properties obj = QObject() prop = obj.property('dummy') - self.assert_(not prop.isValid()) + self.assertEqual(prop, None) + def testTypeNamePythonClasses(self): + '''QVariant of pure python classes''' + d = Dummy() + obj = QObject() + obj.setProperty('foo', d) + # inherited type name from other binding + self.assertEqual(obj.property('foo'), d) + + def testQVariantPyList(self): + '''QVariant(QVariantList).toPyObject() equals original list''' + obj = QObject() + obj.setProperty('foo', [1, 'two', 3]) + self.assertEqual(obj.property('foo'), [1, 'two', 3]) + + def testSubClassConvertion(self): + '''QVariant(QSize subclass) type is UserType and returns same object''' + mysize = MySize(0, 0) + obj = QObject() + obj.setProperty('foo', mysize) + + self.assertTrue(obj.property('foo') is mysize) if __name__ == '__main__': unittest.main() diff --git a/tests/QtCore/qstate_test.py b/tests/QtCore/qstate_test.py index d7c9a4c..bee73e4 100644 --- a/tests/QtCore/qstate_test.py +++ b/tests/QtCore/qstate_test.py @@ -1,6 +1,6 @@ #!/usr/bin/python import unittest -from PySide.QtCore import QObject, QState, QFinalState, SIGNAL, QCoreApplication, QTimer, QStateMachine, QSignalTransition, QVariant +from PySide.QtCore import * class QStateTest(unittest.TestCase): @@ -8,11 +8,11 @@ class QStateTest(unittest.TestCase): app = QCoreApplication([]) o = QObject() - o.setProperty("text", QVariant("INdT")) + o.setProperty("text", "INdT") machine = QStateMachine() s1 = QState() - s1.assignProperty(o, "text", QVariant("Rocks")); + s1.assignProperty(o, "text", "Rocks"); s2 = QFinalState() t = s1.addTransition(o, SIGNAL("change()"), s2); @@ -28,7 +28,7 @@ class QStateTest(unittest.TestCase): QTimer.singleShot(100, app.quit) app.exec_() - txt = o.property("text").toString() + txt = o.property("text") self.assert_(txt, "Rocks") if __name__ == '__main__': diff --git a/tests/QtCore/qvariant_pyobject_test.py b/tests/QtCore/qvariant_pyobject_test.py deleted file mode 100644 index 2000a01..0000000 --- a/tests/QtCore/qvariant_pyobject_test.py +++ /dev/null @@ -1,68 +0,0 @@ - -'''QVariant handling of PyObjects, including pure-python or derived from Qt''' - -import unittest - -from PySide.QtCore import * - - -class Dummy(object): - '''Pure python sample class''' - pass - -class MySize(QSize): - '''Extended class''' - pass - -class QVariantPurePython(unittest.TestCase): - '''QVariant + pure python classes''' - - def testTypeNamePythonClasses(self): - '''QVariant of pure python classes''' - d = Dummy() - obj = QVariant(d) - # inherited type name from other binding - self.assertEqual('PyQt_PyObject', obj.typeName()) - -class QVariantInheritedPython(unittest.TestCase): - '''QVariant + classes inherited from C++''' - - # This works only on PyQt4 4.5.x, not on PyQt4 4.4.x or PySide - def testSubClassConvertion(self): - '''QVariant(QSize subclass) type is UserType and returns same object''' - mysize = MySize(0, 0) - variant = QVariant(mysize) - - self.assertEqual(variant.type(), QVariant.UserType) - self.assertTrue(variant.toPyObject() is mysize) - - -class QVariantToPyObject(unittest.TestCase): - '''QVariant.toPyObject tests''' - - def testQVariantPyList(self): - '''QVariant(QVariantList).toPyObject() equals original list''' - obj = QVariant([1, 'two', 3]) - self.assertEqual(obj.toPyObject(), [1, 'two', 3]) - - def testPyObject(self): - '''QVariant(pure PyObject).toPyObject should return the same object''' - d = Dummy() - obj = QVariant(d) - self.assert_(d is obj.toPyObject()) - - def testNoneToPyObject(self): - '''QVariant().toPyObject() should return None''' - obj = QVariant() - self.assertEqual(None, obj.toPyObject()) - - def testQStringToPyObject(self): - '''QVariant(python string).toPyObject() return an equal QString''' - d = 'abc' - obj = QVariant('abc') - self.assert_(isinstance(obj.toPyObject(), unicode)) - self.assertEqual(d, obj.toPyObject()) - - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtCore/qvariant_test.py b/tests/QtCore/qvariant_test.py deleted file mode 100644 index 6be7b81..0000000 --- a/tests/QtCore/qvariant_test.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QVariant''' - -import unittest -import sys - -from PySide.QtCore import * - - -class QVariantToNumber(unittest.TestCase): - '''QVariant of number types''' - - def testToNumberInt(self): - '''QVariant(int).toInt()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toInt()) - - def testToNumberLongLong(self): - '''QVariant(int).toLongLong()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toLongLong()) - - def testToNumberUInt(self): - '''QVariant(int).toUInt()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toUInt()) - - def testToNumberUIntNegative(self): - '''QVariant(negative int).toUInt()''' - obj = QVariant('-37') - self.assert_(not obj.toUInt()[1]) - - def testToNumberULongLong(self): - '''QVariant(int).toULongLong()''' - obj = QVariant('37') - self.assertEqual((37, True), obj.toULongLong()) - - def testToNumberULongLongNegative(self): - '''QVariant(negative int).toULongLong()''' - obj = QVariant('-37') - self.assert_(not obj.toULongLong()[1]) - - def testToNumberFloat(self): - '''QVariant(double).toFloat()''' - obj = QVariant('37.109') - self.assertEqual((37.109, True), obj.toDouble()) - - -class QVariantTypeName(unittest.TestCase): - '''QVariant.typeName()''' - - def testTypeNameString(self): - '''QVariant(PyString).typeName()''' - obj = QVariant('aaaa') - self.assertEqual('QString', obj.typeName()) - - def testTypeNameInt(self): - '''QVariant(int).typeName()''' - obj = QVariant(34) - self.assertEqual('int', obj.typeName()) - - def testTypeNameDouble(self): - '''QVariant(double).typeName()''' - obj = QVariant(3.14) - self.assertEqual('double', obj.typeName()) - - def testTypeNameBool(self): - '''QVariant(bool).typeName()''' - obj = QVariant(True) - self.assertEqual('bool', obj.typeName()) - - def testTypeNameQByteArray(self): - '''QVariant(QByteArray).typeName()''' - obj = QVariant(QByteArray('aaaa')) - self.assertEqual('QByteArray', obj.typeName()) - - def testTypeNameNone(self): - '''QVariant().typeName()''' - obj = QVariant() - self.assertEqual(None, obj.typeName()) - - def testTypeNameQVariantList(self): - '''QVariant(QVariantList).typeName()''' - obj = QVariant([1, 2, 3, 4]) - self.assertEqual('QVariantList', obj.typeName()) - - obj = QVariant([1.0, 2.2, 3.3, 4.2]) - self.assertEqual('QVariantList', obj.typeName()) - - obj = QVariant(['aaa', 'bbb', 'ccc', 'dddd']) - self.assertEqual('QVariantList', obj.typeName()) - -class QVariantConstructor(unittest.TestCase): - '''More qvariant constructions''' - - def testCopyConstructor(self): - '''QVariant copy constructor''' - obj = QVariant(1) - cpy = QVariant(obj) - - self.assertEqual(obj.type(), cpy.type()) - - def testQStringConstructor(self): - '''QVariant(PyString).type == QVariant.string''' - obj = QVariant("PySide") - self.assertEqual(obj.type(), QVariant.String) - - def testQSizeConstructor(self): - '''QVariant(QSize).type == QVariant.Size''' - mysize = QSize(0, 0) - variant = QVariant(mysize) - - self.assertEqual(variant.type(), QVariant.Size) - self.assertEqual(variant.toSize(), mysize) - - def testToList(self): - v = QVariant((1,2,3)) - self.assertEqual(v.toList(), (1, 2, 3)) - v = QVariant([0,1,2]) - self.assertEqual(v.toList(), [0, 1, 2]) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index fa5de4a..d2d89ee 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -46,7 +46,6 @@ PYSIDE_TEST(qtabwidget_test.py) PYSIDE_TEST(qtextedit_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) -PYSIDE_TEST(qvariant_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) PYSIDE_TEST(qwidget_test.py TRUE) #Bug 237 PYSIDE_TEST(reference_count_test.py) diff --git a/tests/QtGui/keep_reference_test.py b/tests/QtGui/keep_reference_test.py index d0962d5..310361a 100644 --- a/tests/QtGui/keep_reference_test.py +++ b/tests/QtGui/keep_reference_test.py @@ -4,7 +4,7 @@ import unittest from sys import getrefcount from helper import UsesQApplication -from PySide.QtCore import QAbstractTableModel, QVariant +from PySide.QtCore import * from PySide.QtGui import QTableView class TestModel(QAbstractTableModel): @@ -15,7 +15,7 @@ class TestModel(QAbstractTableModel): def columnCount(self, parent): return 0 def data(self, index, role): - return QVariant() + return None class KeepReferenceTest(UsesQApplication): diff --git a/tests/QtGui/qpixmap_test.py b/tests/QtGui/qpixmap_test.py index 7ba7454..1a0339f 100644 --- a/tests/QtGui/qpixmap_test.py +++ b/tests/QtGui/qpixmap_test.py @@ -7,9 +7,10 @@ from PySide.QtCore import * class QPixmapTest(UsesQApplication): def testQVariantConstructor(self): + obj = QObject() pixmap = QPixmap() - v = QVariant(pixmap) - pixmap_copy = QPixmap(v) + obj.setProperty('foo', pixmap) + self.assertEqual(type(obj.property('foo')), QPixmap) def testQSizeConstructor(self): pixmap = QPixmap(QSize(10,20)) @@ -18,12 +19,6 @@ class QPixmapTest(UsesQApplication): def testQStringConstructor(self): pixmap = QPixmap("Testing!") - def testQVariantConstructor2(self): - v = QVariant(QPixmap()) - pixmap2 = QPixmap(v) - v = QVariant(QImage()) - pixmap2 = QPixmap(v) - def testQPixmapLoadFromDataWithQFile(self): f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png')) self.assert_(f.open(QIODevice.ReadOnly)) diff --git a/tests/QtGui/qvariant_test.py b/tests/QtGui/qvariant_test.py deleted file mode 100644 index 138e432..0000000 --- a/tests/QtGui/qvariant_test.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- -'''Test cases for QVariant with QtGui types''' - -import unittest - -from PySide.QtCore import * -from PySide.QtGui import * - -from helper import UsesQApplication - -class Dummy(object): - pass - -class QVariantTypeName(unittest.TestCase): - def testQPen(self): - obj = QVariant(QPen(Qt.red)) - self.assertEqual('QPen', obj.typeName()) - - def testQColor(self): - obj = QVariant(QColor(Qt.red)) - self.assertEqual('QColor', obj.typeName()) - - def testGlobalColor(self): - obj = QVariant(Qt.red) - # XXX: PyQt4 returns int instead of QColor like the C++ version - self.assertEqual('QColor', obj.typeName()) - - def testEnums(self): - obj = QVariant(Qt.SolidLine) - self.assertEqual('int', obj.typeName()) - -class QVariantQColorImplicitlyConvertion(unittest.TestCase): - def testConversions(self): - c1 = QColor(0, 0, 0) - v = QVariant(c1) - c2 = QColor(v) - self.assertEqual(c1, c2) - -class QVariantQPixmap(UsesQApplication): - '''QVariant(QPixmap)''' - - def testBasic(self): - '''QVariant(QPixmap)''' - pixmap = QPixmap(10,20) - pixmap.fill(Qt.blue) - variant = QVariant(pixmap) - - self.assertEqual(variant.typeName(), "QPixmap") - - def testQObject(self): - obj = QObject() - v = QVariant(obj) - self.assertEqual(v.typeName(), 'QObject*') - - def testQWidget(self): - obj = QWidget() - v = QVariant(obj) - self.assertEqual(v.typeName(), 'QWidget*') - -class MyColor(QColor): - pass - -class MyPrimitive(int): - pass - -class QVariantMess(unittest.TestCase): - def testMyColor(self): - c1 = MyColor() - v = QVariant(c1) - self.assertEqual(type(v.toPyObject()), MyColor) - - def testMyPrimitive(self): - p = MyPrimitive(3) - v = QVariant(p) - self.assertNotEqual(v.type(), QVariant.Int) - self.assertTrue(v.toPyObject() is p) - - def testMatrix2x2(self): - m = QMatrix2x2() - v = QVariant(m) - self.assertEqual('QMatrix2x2', v.typeName()) - -if __name__ == '__main__': - unittest.main() diff --git a/tests/QtSql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py index 2d5a0a3..7a9d30a 100644 --- a/tests/QtSql/qsqldatabaseandqueries_test.py +++ b/tests/QtSql/qsqldatabaseandqueries_test.py @@ -39,16 +39,16 @@ class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase): query.exec_("INSERT INTO person VALUES(101, 'George', 'Harrison')") query.prepare("INSERT INTO person (id, firstname, lastname) " "VALUES (:id, :firstname, :lastname)") - query.bindValue(":id", QVariant(102)) - query.bindValue(":firstname", QVariant("John")) - query.bindValue(":lastname", QVariant("Lennon")) + query.bindValue(":id", 102) + query.bindValue(":firstname", "John") + query.bindValue(":lastname", "Lennon") query.exec_() lastname = '' query.exec_("SELECT lastname FROM person where id=101") self.assertTrue(query.isActive()) query.next() - lastname = query.value(0).toString() + lastname = query.value(0) self.assertEqual(lastname, 'Harrison') if __name__ == '__main__': From fc059316968e5bdc079a2ebd84800297ecce7d2a Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 14 Jun 2010 11:23:42 -0300 Subject: [PATCH 0019/1129] GENERATOR_EXTRA_FLAGS must be a cmake string, not a cmake list. Reviewer: Luciano Wolf Marcelo Lira --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b26d1c..ae254b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,7 +122,7 @@ if (NOT SITE_PACKAGE) message(FATAL_ERROR "Could not detect Python module installation directory.") endif() -set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) +set(GENERATOR_EXTRA_FLAGS "--generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic") enable_testing() From 89167fa56ebef6e8d596495ad912196f274587da Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 14 Jun 2010 14:22:55 -0300 Subject: [PATCH 0020/1129] Revert "GENERATOR_EXTRA_FLAGS must be a cmake string, not a cmake list." This reverts commit fc059316968e5bdc079a2ebd84800297ecce7d2a. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae254b2..4b26d1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,7 +122,7 @@ if (NOT SITE_PACKAGE) message(FATAL_ERROR "Could not detect Python module installation directory.") endif() -set(GENERATOR_EXTRA_FLAGS "--generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic") +set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) enable_testing() From 4284ae6cc69f6281140d960cfd6d62a94066bf36 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 10 Jun 2010 15:33:06 -0300 Subject: [PATCH 0021/1129] Fixed thread test to avoid memory leaks. Reviewer: Hugo Parente Lima , Marcelo Lira --- tests/QtCore/thread_signals_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/QtCore/thread_signals_test.py b/tests/QtCore/thread_signals_test.py index 9eea829..1d2f750 100644 --- a/tests/QtCore/thread_signals_test.py +++ b/tests/QtCore/thread_signals_test.py @@ -27,6 +27,7 @@ class TestThreadSignal(UsesQCoreApplication): t.start() self.app.exec_() + t.wait() self.assert_(self.__called__); if __name__ == '__main__': From 569d1ab60e9b2227b2f4ed407718d17cc179d265 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 14 Jun 2010 14:59:26 -0300 Subject: [PATCH 0022/1129] Fixed parent function return ownership. Fixed QMainWindow functions ownership. Fixes #241. Reviewer: Hugo Parente Lima , Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 3 ++ PySide/QtGui/typesystem_gui_common.xml | 56 +++++++++++++++++--------- PySide/typesystem_templates.xml | 9 +++++ tests/QtGui/qmainwindow_test.py | 42 +++++++++++++++++++ 4 files changed, 92 insertions(+), 18 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 85694e4..7249338 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1049,6 +1049,9 @@ + + + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index fac9f56..7509850 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1260,12 +1260,12 @@ - - - + + + @@ -1689,26 +1689,46 @@ - - - + + + + + + + + - - - - + + + + + + + + + - - - + + + + + + + + - - - - - + + + + + + + + + + diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 3badcf2..46911fa 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -1,5 +1,14 @@ + + + + + + + + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index d2d89ee..5d1cec4 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -1,3 +1,4 @@ +PYSIDE_TEST(api2_test.py) PYSIDE_TEST(add_action_test.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/api2_test.py b/tests/QtGui/api2_test.py new file mode 100644 index 0000000..e458d8b --- /dev/null +++ b/tests/QtGui/api2_test.py @@ -0,0 +1,60 @@ +'''Test cases for PySide API2 support''' + + +import unittest + +from PySide.QtCore import QObject +from PySide.QtGui import * + +from helper import UsesQApplication + +class WidgetValidatorQInt(QWidget, QIntValidator): + def __init__(self, parent=None): + QWidget.__init__(self, parent) + QIntValidator.__init__(self, parent) + +class WidgetValidatorQSpinBox(QSpinBox): + def __init__(self, parent=None): + QSpinBox.__init__(self, parent) + + def fixup(self, text): + print "It was called!" + +class DoubleQObjectInheritanceTest(UsesQApplication): + + def testDouble(self): + '''Double inheritance from QObject classes''' + + obj = WidgetValidatorQInt() + + #QIntValidator methods + state, string, number = obj.validate('Test', 0) + self.assertEqual(state, QValidator.Invalid) + state, string, number = obj.validate('33', 0) + self.assertEqual(state, QValidator.Acceptable) + + def testQSpinBox(self): + obj = WidgetValidatorQSpinBox() + + obj.setRange(1, 10) + obj.setValue(0) + print "Value:", obj.value() + +class QClipboardTest(UsesQApplication): + + def testQClipboard(self): + clip = QClipboard() + clip.setText("Testing this thing!") + + text, subtype = clip.text("") + self.assertEqual(subtype, "plain") + self.assertEqual(text, "Testing this thing!") + +#class QFileDialog(UsesQApplication): +# +# def testQFileDialog(self): +# string, filtr = QFileDialog.getOpenFileName() +# print string, filtr + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qobject_mi_test.py b/tests/QtGui/qobject_mi_test.py index 8ccc1d3..28b3cbd 100644 --- a/tests/QtGui/qobject_mi_test.py +++ b/tests/QtGui/qobject_mi_test.py @@ -29,8 +29,10 @@ class DoubleQObjectInheritanceTest(UsesQApplication): self.assertFalse(obj.isVisible()) #QIntValidator methods - self.assertEqual(obj.validate('aaaa', 0), QValidator.Invalid) - self.assertEqual(obj.validate('33', 0), QValidator.Acceptable) + state, string, number = obj.validate('aaaa', 0) + self.assertEqual(state, QValidator.Invalid) + state, string, number = obj.validate('33', 0) + self.assertEqual(state, QValidator.Acceptable) if __name__ == '__main__': From ab40ddbb2f06ceaceda886d386583f25e03cd640 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 16 Jun 2010 14:55:26 -0300 Subject: [PATCH 0032/1129] Fix LD_LIBRARY_PATH variable to be possible to run tests when using CMAKE_SKIP_RPATH=true --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d446151..7938ea7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,7 +16,7 @@ macro(PYSIDE_TEST) else() message(WARNING "Ivalid call of macro PYSIDE_TEST") endif() - set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") + set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${libpyside_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") add_test(${TEST_NAME} ${TEST_CMD}) set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT ${PYSIDE_TIMEOUT} From cdde96f3a4c12c03ec8272d1e75c2f4a30e29cf6 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 16 Jun 2010 14:56:29 -0300 Subject: [PATCH 0033/1129] Add a default constructor value to QVariant::Type. Reviewer: Marcelo Lira Luciano Wolf --- 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 5331fa9..8b1bab6 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -161,7 +161,7 @@ - + From ef7eb0fca443ca1df624034c6e6ede597f2dab3c Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Wed, 16 Jun 2010 18:16:17 -0300 Subject: [PATCH 0034/1129] Fix the template used by QFileDialog methods. Reviewer: Hugo Parente Lima , Marcelo Lira --- PySide/typesystem_templates.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 8bc9eb5..40e2345 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -159,8 +159,8 @@ From 4cca85f52585b17f53e26f81ca26504fe561e578 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 15 Jun 2010 13:34:42 -0300 Subject: [PATCH 0035/1129] Implement inject-code to functions using QChar in QFontMetrics and QFontMetricsF Reviewer: Luciano Wolf Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 48 ++++++++++++++++++++++++++ tests/QtGui/qfontmetrics_test.py | 10 ++++++ 2 files changed, 58 insertions(+) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 92856d9..7a6f2b0 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1,5 +1,16 @@ + + @@ -1057,6 +1068,24 @@ + + + + + + + + + + + + + + + + + + @@ -1118,6 +1147,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/QtGui/qfontmetrics_test.py b/tests/QtGui/qfontmetrics_test.py index 7964d91..96c022f 100644 --- a/tests/QtGui/qfontmetrics_test.py +++ b/tests/QtGui/qfontmetrics_test.py @@ -185,5 +185,15 @@ class FSizeTest(QFontMetricsFTest): 'PySide by INdT', 20, ['aaaa', 'ase']) +class QCharTest(QFontMetricsFTest): + + def testBoundingRect(self): + retCh = self.metrics.boundingRectChar('a') + self.assertEqual(type(retCh), QRectF) + + def testWith(self): + retCh = self.metrics.widthChar('a') + self.assert_(retCh > 0) + if __name__ == '__main__': unittest.main() From 83cf37f609ca3adb343be090054188dc254b9741 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 16 Jun 2010 13:52:09 -0300 Subject: [PATCH 0036/1129] Create unit-test for signal with QObject. Reviewer: Hugo Parente Lima , Luciano Wolf --- libpyside/qsignal.cpp | 8 ++++++-- libpyside/signalmanager.cpp | 13 ++++++++++--- tests/signals/signal_object_test.py | 13 ++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index 1edc13c..43c02f1 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -246,7 +246,12 @@ char* signal_get_type_name(PyObject* type) if (PyType_Check(type)) { //tp_name return the full name Shiboken::AutoDecRef typeName(PyObject_GetAttrString(type, "__name__")); - return strdup(PyString_AS_STRING(typeName.object())); + char *aux = strdup(PyString_AS_STRING(typeName.object())); + if (Shiboken::TypeResolver::getType(aux) == Shiboken::TypeResolver::ObjectType) { + aux = reinterpret_cast(realloc(aux, strlen(aux) + 1)); + aux = strcat(aux, "*"); + } + return aux; } else if (PyString_Check(type)) { return strdup(PyString_AS_STRING(type)); } @@ -281,7 +286,6 @@ char* signal_parse_signature(PyObject *args) } } } - return signature; } diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 7ac3f30..6ea05c9 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -253,7 +253,12 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa for (i = 0; i < argsGiven; ++i) { Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get(qPrintable(argTypes[i])); if (typeResolver) { - signalArgs[i+1] = typeResolver->toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i)); + void *data = typeResolver->toCpp(PySequence_Fast_GET_ITEM(sequence.object(), i)); + if (Shiboken::TypeResolver::getType(qPrintable(argTypes[i])) == Shiboken::TypeResolver::ObjectType) { + signalArgs[i+1] = &data; + } else { + signalArgs[i+1] = data; + } } else { PyErr_Format(PyExc_TypeError, "Unknown type used to emit a signal: %s", qPrintable(argTypes[i])); break; @@ -289,7 +294,6 @@ bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* ar else return emitNormalSignal(source, signalIndex, signal, args, argTypes); } - qDebug() << "Signal" << signal << "not found, probably a typo or you are emitting a dynamic signal that has never been used in a connection until now."; return false; } @@ -316,7 +320,10 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, 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]); + void* data = args[i+1]; + const char* dataType = paramTypes[i].constData(); + + PyObject* arg = Shiboken::TypeResolver::get(dataType)->toPython(data); PyTuple_SET_ITEM(preparedArgs.object(), i, arg); } diff --git a/tests/signals/signal_object_test.py b/tests/signals/signal_object_test.py index d36665c..1b1f222 100644 --- a/tests/signals/signal_object_test.py +++ b/tests/signals/signal_object_test.py @@ -13,7 +13,7 @@ class MyObject(QTimer): sig3 = Signal(int) sig4 = Signal((int,), (unicode,)) sig5 = Signal((unicode,), (int,)) - + sig6 = Signal(QObject) @Slot(int) def myRange(self, r): @@ -25,6 +25,9 @@ class MyObject(QTimer): def slotString(self, s): self._s = s + def slotObject(self, o): + self._o = o + class SignalObjectTest(UsesQCoreApplication): def cb(self): @@ -75,8 +78,12 @@ class SignalObjectTest(UsesQCoreApplication): o.sig5[int].emit(10) self.assertEqual(o._range, 10) - - + def testSignalWithObject(self): + o = MyObject() + o.sig6.connect(o.slotObject) + arg = QObject() + o.sig6.emit(arg) + self.assertEqual(arg, o._o) if __name__ == '__main__': unittest.main() From cf90354ff99bc90ecfc6ea57e3cbddcad6bab9a1 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 16 Jun 2010 17:45:09 -0300 Subject: [PATCH 0037/1129] Create QAction signal test. Reviewer: Hugo Parente Lima , Luciano Wolf --- tests/QtGui/CMakeLists.txt | 3 +++ tests/QtGui/qaction_test.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/QtGui/qaction_test.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 5d1cec4..5ff4579 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -1,3 +1,5 @@ +#Keep this in alphabetical sort + PYSIDE_TEST(api2_test.py) PYSIDE_TEST(add_action_test.py) PYSIDE_TEST(customproxywidget_test.py) @@ -14,6 +16,7 @@ PYSIDE_TEST(qapplication_singleton_test.py) PYSIDE_TEST(qapp_test.py) PYSIDE_TEST(qbrush_test.py) PYSIDE_TEST(qcolor_test.py) +PYSIDE_TEST(qaction_test.py) PYSIDE_TEST(qdatastream_gui_operators_test.py) PYSIDE_TEST(qfontdialog_test.py) PYSIDE_TEST(qfontmetrics_test.py) diff --git a/tests/QtGui/qaction_test.py b/tests/QtGui/qaction_test.py new file mode 100644 index 0000000..b926ad6 --- /dev/null +++ b/tests/QtGui/qaction_test.py @@ -0,0 +1,22 @@ +import unittest + +from PySide.QtGui import QAction, QWidget +from helper import UsesQApplication + +class QPainterDrawText(UsesQApplication): + + def _cb(self, checked): + self._called = True + + def testSignal(self): + o = QWidget() + act = QAction(o) + self._called = False + act.triggered.connect(self._cb) + act.trigger() + self.assert_(self._called) + + +if __name__ == '__main__': + unittest.main() + From d699a3abedfe60e7146fad8381b03687ce476699 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 16 Jun 2010 18:03:07 -0300 Subject: [PATCH 0038/1129] Created test for Connection between new Signal API and Slots Reviewer: Hugo Parente Lima , Luciano Wolf --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/qtextedit_signal_test.py | 37 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/QtGui/qtextedit_signal_test.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 5ff4579..5f50ea8 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -48,6 +48,7 @@ PYSIDE_TEST(qstyle_test.py) PYSIDE_TEST(qtableview_test.py) PYSIDE_TEST(qtabwidget_test.py) PYSIDE_TEST(qtextedit_test.py) +PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) diff --git a/tests/QtGui/qtextedit_signal_test.py b/tests/QtGui/qtextedit_signal_test.py new file mode 100644 index 0000000..3195e0e --- /dev/null +++ b/tests/QtGui/qtextedit_signal_test.py @@ -0,0 +1,37 @@ +from PySide import QtGui, QtCore +from helper import UsesQApplication + +import unittest + +class MyWindow(QtGui.QMainWindow): + appendText = QtCore.Signal(str) + + @QtCore.Slot() + def onButtonPressed(self): + self.appendText.emit("PySide") + + def __init__(self, parent=None): + super(MyWindow, self).__init__(parent) + + self.textEdit = QtGui.QTextEdit() + self.btn = QtGui.QPushButton("ClickMe") + self.btn.clicked.connect(self.onButtonPressed) + self.appendText.connect(self.textEdit.append) + + def start(self): + self.btn.click() + + def text(self): + return self.textEdit.toPlainText() + + +class testSignalWithCPPSlot(UsesQApplication): + + def testEmission(self): + w = MyWindow() + w.start() + self.assertEqual(w.text(), "PySide") + +if __name__ == '__main__': + unittest.main() + From 6b70a1362ccfd140617c610e52f2abbbbe08afc4 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 17 Jun 2010 14:02:29 -0300 Subject: [PATCH 0039/1129] Fixed signal connection with native slot. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtCore/glue/qobject_connect.cpp | 4 +-- libpyside/signalmanager.cpp | 41 ++++++++++++++++++-------- libpyside/signalmanager.h | 2 +- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp index 5b6f254..e9de411 100644 --- a/PySide/QtCore/glue/qobject_connect.cpp +++ b/PySide/QtCore/glue/qobject_connect.cpp @@ -56,7 +56,7 @@ static bool qobjectConnectCallback(QObject* source, const char* signal, PyObject return false; const QMetaObject* metaObject = receiver->metaObject(); - const QByteArray callbackSig = PySide::getCallbackSignature(signal, callback, usingGlobalReceiver).toAscii(); + const QByteArray callbackSig = PySide::getCallbackSignature(signal, receiver, callback, usingGlobalReceiver).toAscii(); const char* slot = callbackSig.constData(); int slotIndex = metaObject->indexOfSlot(slot); if (slotIndex == -1) { @@ -103,7 +103,7 @@ static bool qobjectDisconnectCallback(QObject* source, const char* signal, PyObj return false; const QMetaObject* metaObject = receiver->metaObject(); - const QByteArray callbackSig = PySide::getCallbackSignature(signal, callback, usingGlobalReceiver).toAscii(); + const QByteArray callbackSig = PySide::getCallbackSignature(signal, receiver, callback, usingGlobalReceiver).toAscii(); QByteArray qtSlotName(callbackSig); qtSlotName = qtSlotName.prepend('1'); diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 6ea05c9..d44743c 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -104,12 +104,13 @@ static QString codeCallbackName(PyObject* callback, const QString& funcName) return funcName+QString::number(quint64(callback), 16); } -QString PySide::getCallbackSignature(const char* signal, PyObject* callback, bool encodeName) +QString PySide::getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName) { QString functionName; + QString signature; + QStringList args; int numArgs = -1; bool useSelf = false; - bool isMethod = PyMethod_Check(callback); bool isFunction = PyFunction_Check(callback); @@ -123,25 +124,41 @@ QString PySide::getCallbackSignature(const char* signal, PyObject* callback, boo functionName = ((PyCFunctionObject*)callback)->m_ml->ml_name; useSelf = ((PyCFunctionObject*)callback)->m_self; int flags = ((PyCFunctionObject*)callback)->m_ml->ml_flags; - if (flags & METH_O) - numArgs = 1; - else if (flags & METH_VARARGS) - numArgs = -1; - else if (flags & METH_NOARGS) - numArgs = 0; + + if (receiver) { + //Search for signature on metaobject + const QMetaObject *mo = receiver->metaObject(); + for(int i=0; i < mo->methodCount(); i++) { + QMetaMethod me = mo->method(i); + if (QString(me.signature()).startsWith(functionName)) { + numArgs = me.parameterTypes().size()+1; + break; + } + } + } + + if (numArgs == -1) { + if (flags & METH_O) + numArgs = 1; + else if (flags & METH_VARARGS) + numArgs = -1; + else if (flags & METH_NOARGS) + numArgs = 0; + } } else if (PyCallable_Check(callback)) { functionName = "__callback"+QString::number((size_t)callback); } + Q_ASSERT(!functionName.isEmpty()); - QString signature; + bool isShortCircuit = false; + if (encodeName) signature = codeCallbackName(callback, functionName); else signature = functionName; - bool isShortCircuit; - QStringList args = getArgsFromSignature(signal, &isShortCircuit); + args = getArgsFromSignature(signal, &isShortCircuit); if (!isShortCircuit) { signature.append('('); @@ -313,10 +330,8 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, } else { // call python slot Shiboken::GilState gil; - QList paramTypes = method.parameterTypes(); PyObject* self = Shiboken::BindingManager::instance().retrieveWrapper(object); - Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count())); for (int i = 0, max = paramTypes.count(); i < max; ++i) { diff --git a/libpyside/signalmanager.h b/libpyside/signalmanager.h index 9687dcc..70d7f08 100644 --- a/libpyside/signalmanager.h +++ b/libpyside/signalmanager.h @@ -59,7 +59,7 @@ private: PYSIDE_API bool isSignal(const char* signal); PYSIDE_API bool checkSignal(const char* signal); -PYSIDE_API QString getCallbackSignature(const char* signal, PyObject* callback, bool encodeName); +PYSIDE_API QString getCallbackSignature(const char* signal, QObject* receiver, PyObject* callback, bool encodeName); QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit = 0); class PYSIDE_API SignalManager From e34105a7499fe1c2edd6fbee6dc2acb3993f5827 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Thu, 17 Jun 2010 16:07:15 -0300 Subject: [PATCH 0040/1129] Fix phonon test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now it checks for ogg backend before playing. The timeout was moved to 10s to avoid phonon timeout. Reviewer: Marcelo Lira Renato Araújo --- tests/CMakeLists.txt | 2 +- tests/phonon/basic_playing_test.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7938ea7..c1a0376 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -set(PYSIDE_TIMEOUT 5) +set(PYSIDE_TIMEOUT 10) macro(TEST_QT_MODULE var name) if(NOT DISABLE_${name} AND ${var}) diff --git a/tests/phonon/basic_playing_test.py b/tests/phonon/basic_playing_test.py index fe295e8..45f6c12 100644 --- a/tests/phonon/basic_playing_test.py +++ b/tests/phonon/basic_playing_test.py @@ -54,13 +54,17 @@ class TestSimplePlaying(UsesQCoreApplication): self.called = True def testStateChanged(self): - QtCore.QObject.connect(self.media, + # Check for ogg support before playing it + if (phonon.Phonon.BackendCapabilities.isMimeTypeAvailable('audio/ogg')): + QtCore.QObject.connect(self.media, QtCore.SIGNAL('stateChanged(Phonon::State, Phonon::State)'), self.state_cb) - self.media.play() - self.app.exec_() - self.assert_(self.called) + self.media.play() + self.app.exec_() + self.assert_(self.called) + else: + print 'Ogg format not supported! Playback test skipped!' if __name__ == '__main__': unittest.main() From 33f7ff2b4d26cede665a087178ca444c6d0894dd Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 17 Jun 2010 17:25:00 -0300 Subject: [PATCH 0041/1129] Fix bug#242 - "PySide is installed into wrong path on Mac OS X" If the cmake variable SITE_PACKAGE is set, we wont try to detect the SITE_PACKAGES variable. Reviewed: Marcelo Lira Luciano Wolf --- CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b26d1c..d0461bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,13 +113,17 @@ add_custom_target(dist echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2.\n" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) -execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ - print sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}')" - OUTPUT_VARIABLE SITE_PACKAGE - OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT SITE_PACKAGE) - message(FATAL_ERROR "Could not detect Python module installation directory.") + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ + print sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}')" + OUTPUT_VARIABLE SITE_PACKAGE + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (NOT SITE_PACKAGE) + message(FATAL_ERROR "Could not detect Python module installation directory.") + elseif (APPLE) + message(STATUS "!!! The generated bindings will be installed on ${SITE_PACKAGE}, is it right!?") + endif() endif() set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) From 5ce7c945367f1d673a25666c1cc3ab300b23df49 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 17 Jun 2010 18:49:12 -0300 Subject: [PATCH 0042/1129] Fixed udpsocket to work on offline computer. Reviewed: Marcelo Lira Luciano Wolf --- tests/QtNetwork/udpsocket_test.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/QtNetwork/udpsocket_test.py b/tests/QtNetwork/udpsocket_test.py index 26cff7f..66f8920 100644 --- a/tests/QtNetwork/udpsocket_test.py +++ b/tests/QtNetwork/udpsocket_test.py @@ -14,16 +14,13 @@ class HttpSignalsCase(unittest.TestCase): def setUp(self): #Acquire resources + self.called = False self.app = QCoreApplication([]) + self.socket = QUdpSocket() - self.socket.bind(45454) + self.server = QUdpSocket() - self.timer = QTimer.singleShot(1000, self.app.quit) - self.a = QTimer.singleShot(100, self.broadcast) - #self.a = QTimer() - #self.a.setInterval(100) - #QObject.connect(self.a, SIGNAL('timeout()'), self.broadcast) - #self.a.start() + self.server.bind(QHostAddress(QHostAddress.LocalHost), 45454) def tearDown(self): #Release resources @@ -31,21 +28,21 @@ class HttpSignalsCase(unittest.TestCase): del self.server del self.app - def broadcast(self): - addr = QHostAddress(QHostAddress.Broadcast) - self.server.writeDatagram('datagram', addr, 45454) + def sendPackage(self): + addr = QHostAddress(QHostAddress.LocalHost) + self.socket.writeDatagram('datagram', addr, 45454) def callback(self): - while self.socket.hasPendingDatagrams(): - datagram, host, port = self.socket.readDatagram( - self.socket.pendingDatagramSize()) + while self.server.hasPendingDatagrams(): + datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize()) self.called = True self.app.quit() def testDefaultArgs(self): #QUdpSocket.readDatagram pythonic return # @bug 124 - QObject.connect(self.socket, SIGNAL('readyRead()'), self.callback) + QObject.connect(self.server, SIGNAL('readyRead()'), self.callback) + self.sendPackage() self.app.exec_() self.assert_(self.called) From 88146cf500008c13912e03213dc98bab491b15a2 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 18 Jun 2010 16:11:54 -0300 Subject: [PATCH 0043/1129] Implemented a dummy http server to run unit-test on a offline computer. Reviewed: Marcelo Lira Luciano Wolf --- tests/QtNetwork/CMakeLists.txt | 2 + tests/QtNetwork/basic_auth_test.py | 38 ++++++++++++++++ tests/QtNetwork/http_test.py | 39 +++------------- tests/util/httpd.py | 71 ++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 32 deletions(-) create mode 100644 tests/QtNetwork/basic_auth_test.py create mode 100644 tests/util/httpd.py diff --git a/tests/QtNetwork/CMakeLists.txt b/tests/QtNetwork/CMakeLists.txt index cae1470..0eb5037 100644 --- a/tests/QtNetwork/CMakeLists.txt +++ b/tests/QtNetwork/CMakeLists.txt @@ -1,3 +1,5 @@ + +PYSIDE_TEST(basic_auth_test.py) PYSIDE_TEST(accessManager_test.py) PYSIDE_TEST(http_test.py) PYSIDE_TEST(tcpserver_test.py) diff --git a/tests/QtNetwork/basic_auth_test.py b/tests/QtNetwork/basic_auth_test.py new file mode 100644 index 0000000..8087eed --- /dev/null +++ b/tests/QtNetwork/basic_auth_test.py @@ -0,0 +1,38 @@ +import unittest + +from PySide.QtCore import * +from PySide.QtNetwork import * + +from helper import UsesQApplication +from httpd import TestServer + +class testAuthenticationSignal(UsesQApplication): + + def setUp(self): + super(testAuthenticationSignal, self).setUp() + self.httpd = TestServer(secure=True) + self.httpd.start() + self._resultOk = False + + def tearDown(self): + self.httpd.shutdown() + del self.httpd + super(testAuthenticationSignal, self).tearDown() + + def onAuthRequest(self, hostname, port, auth): + self.assert_(isinstance(auth, QAuthenticator)) + self._resultOk = True + self.app.quit() + + + def testwaitSignal(self): + http = QHttp() + http.setHost("localhost", self.httpd.port()) + http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest) + path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/") + data = http.get(path) + self.app.exec_() + self.assert_(self._resultOk) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py index 379ff5d..5d40405 100644 --- a/tests/QtNetwork/http_test.py +++ b/tests/QtNetwork/http_test.py @@ -7,24 +7,27 @@ from PySide.QtCore import * from PySide.QtNetwork import * from helper import UsesQApplication +from httpd import TestServer -""" class HttpSignalsCase(UsesQApplication): '''Test case for launching QHttp signals''' def setUp(self): super(HttpSignalsCase, self).setUp() - self.http = QHttp() - self.url = QUrl('http://www.google.com') - self.timer = QTimer.singleShot(250, self.app.quit) + self.httpd = TestServer() + self.httpd.start() + self.url = QUrl('localhost:' + str(self.httpd.port())) + self.called = False def tearDown(self): + self.httpd.shutdown() del self.http super(HttpSignalsCase, self).tearDown() def callback(self, ident): self.called = True + self.app.quit() def testDefaultArgs(self): #QHttp signal requestStarted signal @@ -35,33 +38,5 @@ class HttpSignalsCase(UsesQApplication): self.app.exec_() self.assert_(self.called) -class testHttp(UsesQApplication): - def testRead(self): - header = QHttpRequestHeader("GET", QString(QUrl.toPercentEncoding("/index.html"))) - header.setValue("Host", "qtsoftware.com"); - http = QHttp() - http.setHost("qtsoftware.com") - http.request(header) - data = http.read(100) -""" - -class testAuthenticationSignal(UsesQApplication): - def onAuthRequest(self, hostname, port, auth): - self.assert_(isinstance(auth, QAuthenticator)) - print auth.realm() - self._resultOk = True - self.app.exit() - - def testwaitSignal(self): - self._resultOk = False - http = QHttp() - http.setHost("projects.maemo.org", QHttp.ConnectionModeHttps, 0) - http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest) - path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/") - print http.get(path) - self.app.exec_() - self.assert_(self._resultOk) - - if __name__ == '__main__': unittest.main() diff --git a/tests/util/httpd.py b/tests/util/httpd.py new file mode 100644 index 0000000..96750f0 --- /dev/null +++ b/tests/util/httpd.py @@ -0,0 +1,71 @@ +import SocketServer +import BaseHTTPServer +import random + +from threading import Thread + + +class TestHandler(BaseHTTPServer.BaseHTTPRequestHandler): + DATA = "PySide Server" + + def do_GET(self): + self.send_head() + self.wfile.write(TestHandler.DATA) + + def do_HEAD(self): + self.send_head() + + def send_head(self): + self.send_response(200) + self.send_header("Content-type", "text/plain") + self.send_header("Content-Length", str(len(TestHandler.DATA))) + self.end_headers() + +class TestSecureHandler(BaseHTTPServer.BaseHTTPRequestHandler): + DATA = "PySide" + + def do_GET(self): + self.send_head() + self.wfile.write(TestHandler.DATA) + + def do_HEAD(self): + self.send_head() + + def send_head(self): + try: + handler = self.marshall_handler() + handler.do_request(self) + except: + self.send_response(401) + self.send_header("WWW-Authenticate", "Basic realm='Secure Area'") + self.send_header("Content-type", "text/plain") + self.send_header("Content-Length", str(len(TestHandler.DATA))) + self.end_headers() + + +class TestServer(Thread): + + def __init__(self, secure=False): + Thread.__init__(self) + + self._port = 8000 + random.randint(0, 100) + self.keep_running = True + server = SocketServer.TCPServer + + if secure: + handle = TestSecureHandler + else: + handle = TestHandler + + self.httpd = SocketServer.TCPServer(('' , self._port), handle) + + def port(self): + return self._port + + def run(self): + self.httpd.serve_forever() + + def shutdown(self): + self.httpd.shutdown() + self.join() + From 143946435835163d750b08982a906834a575fa64 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Fri, 18 Jun 2010 10:54:42 -0300 Subject: [PATCH 0044/1129] Small updates to the documentation. Removed the doc about building BoostPythonGenerator and modified a line about the generator used to create the bindings in the index.html file. --- doc/_templates/index.html | 2 +- doc/howto-build/setup-boostpython.rst | 51 --------------------------- 2 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 doc/howto-build/setup-boostpython.rst diff --git a/doc/_templates/index.html b/doc/_templates/index.html index e618231..bae2f7b 100644 --- a/doc/_templates/index.html +++ b/doc/_templates/index.html @@ -9,7 +9,7 @@ GUI package, allowing C++ developers to write their applications once and run them unmodified in different systems. PySide aims to provide Python developers access to the Qt libraries in the most natural way.

-

PySide is built using the BoostPythonGenerator.

+

PySide is built using the Shiboken binding generator.

Documentation

diff --git a/doc/howto-build/setup-boostpython.rst b/doc/howto-build/setup-boostpython.rst deleted file mode 100644 index a70840a..0000000 --- a/doc/howto-build/setup-boostpython.rst +++ /dev/null @@ -1,51 +0,0 @@ - -.. _boost-python-generator: - -********************** -Boost.Python Generator -********************** - -Overview -========================================= - -The **Boost::Python Generator** (A.K.A. :program:`boostpythongenerator`) is -the program that creates the Boost.Python bindings source files from Qt headers -and auxiliary files (typesystems, ``global.h`` and glue files). It depends on -:ref:`generator-runner` and :ref:`api-extractor` library. - - -Getting the sources -=================== - -* Download URL: http://www.pyside.org/downloads/ - -Build requirements -================== - -+ CMake >= 2.6.0 -+ Qt4.5 libraries and development headers >= 4.5.0 -+ :ref:`api-extractor` + development headers -+ :ref:`generator-runner` + development headers - -Building and installing -======================= - -To build and install just follow the generic cmake instructions in -section :ref:`cmake-primer`. - -Debian packaging -================ - -In order to compile this package in a debian environment, make sure the -following packages are installed: - -* debhelper (>= 5) -* cdbs -* cmake (>= 2.6.0) -* libqt4-dev (>= 4.5) -* libapiextractor-dev (>= 0.3.2) -* libgenrunner-dev (>= 0.3.2a1) - -And then you can build the package using:: - - $ dpkg-buildpackage -rfakeroot From e323cd90f7922ffa8d0121b87c3a00c6706e0dd0 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 21 Jun 2010 15:21:25 -0300 Subject: [PATCH 0045/1129] PySide now installs its type system files. The pyside.pc file now has a "typesystemdir" variable pointing to the directory where the type system files are installed. Example usage: pkg-config pyside --variable=typesystemdir Also set the "PYSIDE_TYPESYSTEMS" CMake variable on libpyside/PySideConfig.cmake.in to point to the same path of pkg-config's "typesystemdir". Reviewed by Hugo Parente Reviewed by Luciano Wolf --- PySide/CMakeLists.txt | 5 +++++ PySide/QtCore/CMakeLists.txt | 3 +++ PySide/QtDeclarative/CMakeLists.txt | 3 +++ PySide/QtGui/CMakeLists.txt | 7 +++++++ PySide/QtHelp/CMakeLists.txt | 3 ++- PySide/QtMaemo5/CMakeLists.txt | 3 ++- PySide/QtMultimedia/CMakeLists.txt | 3 +++ PySide/QtNetwork/CMakeLists.txt | 3 +++ PySide/QtOpenGL/CMakeLists.txt | 2 ++ PySide/QtScript/CMakeLists.txt | 3 +++ PySide/QtScriptTools/CMakeLists.txt | 2 ++ PySide/QtSql/CMakeLists.txt | 3 +++ PySide/QtSvg/CMakeLists.txt | 3 +++ PySide/QtTest/CMakeLists.txt | 3 +++ PySide/QtUiTools/CMakeLists.txt | 2 ++ PySide/QtWebKit/CMakeLists.txt | 3 +++ PySide/QtXml/CMakeLists.txt | 3 +++ PySide/QtXmlPatterns/CMakeLists.txt | 2 ++ PySide/phonon/CMakeLists.txt | 3 +++ libpyside/PySideConfig.cmake.in | 2 ++ libpyside/pyside.pc.in | 1 + 21 files changed, 60 insertions(+), 2 deletions(-) diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 3162cbb..b1b3286 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -97,3 +97,8 @@ HAS_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools) HAS_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia) HAS_QT_MODULE(QT_PHONON_FOUND phonon) HAS_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative) + +# install +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_templates.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtCore/CMakeLists.txt b/PySide/QtCore/CMakeLists.txt index 12a2f4a..408451f 100644 --- a/PySide/QtCore/CMakeLists.txt +++ b/PySide/QtCore/CMakeLists.txt @@ -157,3 +157,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtCore${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/${BINDING_NAME}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/pyside_qtcore_python.h DESTINATION include/PySide/QtCore/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_core.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtDeclarative/CMakeLists.txt b/PySide/QtDeclarative/CMakeLists.txt index 587e3b5..d61fbf9 100644 --- a/PySide/QtDeclarative/CMakeLists.txt +++ b/PySide/QtDeclarative/CMakeLists.txt @@ -56,4 +56,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtDeclarative${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/pyside_qtdeclarative_python.h DESTINATION include/PySide/QtDeclarative/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_declarative.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index e9f44d7..db0fd9e 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -494,3 +494,10 @@ add_dependencies(QtGui QtCore) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtGui${CMAKE_DEBUG_POSTFIX}.so DESTINATION "${SITE_PACKAGE}/PySide") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/pyside_qtgui_python.h DESTINATION include/PySide/QtGui/) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_common.xml + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_mac.xml + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_maemo.xml + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_x11.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtHelp/CMakeLists.txt b/PySide/QtHelp/CMakeLists.txt index 219dfc3..0cc48db 100644 --- a/PySide/QtHelp/CMakeLists.txt +++ b/PySide/QtHelp/CMakeLists.txt @@ -44,5 +44,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtHelp${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp/pyside_qthelp_python.h DESTINATION include/PySide/QtHelp/) - +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_help.xml + DESTINATION share/PySide/typesystems) diff --git a/PySide/QtMaemo5/CMakeLists.txt b/PySide/QtMaemo5/CMakeLists.txt index 9251cc3..4590e40 100644 --- a/PySide/QtMaemo5/CMakeLists.txt +++ b/PySide/QtMaemo5/CMakeLists.txt @@ -51,7 +51,8 @@ add_dependencies(QtMaemo5 QtGui) # install install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMaemo5${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/${BINDING_NAME}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMaemo5/pyside_qtmaemo5_python.h DESTINATION include/${BINDING_NAME}/QtMaemo5/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_maemo5.xml + DESTINATION share/PySide/typesystems) diff --git a/PySide/QtMultimedia/CMakeLists.txt b/PySide/QtMultimedia/CMakeLists.txt index cbf0b6f..05f63b5 100644 --- a/PySide/QtMultimedia/CMakeLists.txt +++ b/PySide/QtMultimedia/CMakeLists.txt @@ -49,3 +49,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMultimedia${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/pyside_qtmultimedia_python.h DESTINATION include/PySide/QtMultimedia/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_multimedia.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtNetwork/CMakeLists.txt b/PySide/QtNetwork/CMakeLists.txt index e66fa37..7c8d17e 100644 --- a/PySide/QtNetwork/CMakeLists.txt +++ b/PySide/QtNetwork/CMakeLists.txt @@ -125,3 +125,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtNetwork${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/pyside_qtnetwork_python.h DESTINATION include/PySide/QtNetwork/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_network.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtOpenGL/CMakeLists.txt b/PySide/QtOpenGL/CMakeLists.txt index 1d79e6c..5849c9a 100644 --- a/PySide/QtOpenGL/CMakeLists.txt +++ b/PySide/QtOpenGL/CMakeLists.txt @@ -59,4 +59,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtOpenGL${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL/pyside_qtopengl_python.h DESTINATION include/PySide/QtOpenGL/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_opengl.xml + DESTINATION share/PySide/typesystems) diff --git a/PySide/QtScript/CMakeLists.txt b/PySide/QtScript/CMakeLists.txt index 6419439..8b63447 100644 --- a/PySide/QtScript/CMakeLists.txt +++ b/PySide/QtScript/CMakeLists.txt @@ -51,4 +51,7 @@ add_dependencies(QtScript QtCore) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtScript${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/pyside_qtscript_python.h DESTINATION include/PySide/QtScript/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_script.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtScriptTools/CMakeLists.txt b/PySide/QtScriptTools/CMakeLists.txt index 1d53ff7..d937d66 100644 --- a/PySide/QtScriptTools/CMakeLists.txt +++ b/PySide/QtScriptTools/CMakeLists.txt @@ -37,4 +37,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtScriptTools${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools/pyside_qtscripttools_python.h DESTINATION include/PySide/QtScriptTools/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_scripttools.xml + DESTINATION share/PySide/typesystems) diff --git a/PySide/QtSql/CMakeLists.txt b/PySide/QtSql/CMakeLists.txt index 8040f01..1cbe713 100644 --- a/PySide/QtSql/CMakeLists.txt +++ b/PySide/QtSql/CMakeLists.txt @@ -49,4 +49,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtSql${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/pyside_qtsql_python.h DESTINATION include/PySide/QtSql/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sql.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtSvg/CMakeLists.txt b/PySide/QtSvg/CMakeLists.txt index 42129c7..631131a 100644 --- a/PySide/QtSvg/CMakeLists.txt +++ b/PySide/QtSvg/CMakeLists.txt @@ -61,3 +61,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtSvg${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/pyside_qtsvg_python.h DESTINATION include/PySide/QtSvg/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_svg.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtTest/CMakeLists.txt b/PySide/QtTest/CMakeLists.txt index e6e2953..2d392e4 100644 --- a/PySide/QtTest/CMakeLists.txt +++ b/PySide/QtTest/CMakeLists.txt @@ -49,3 +49,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtTest${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/pyside_qttest_python.h DESTINATION include/PySide/QtTest/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_test.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtUiTools/CMakeLists.txt b/PySide/QtUiTools/CMakeLists.txt index eaea414..5809c3f 100644 --- a/PySide/QtUiTools/CMakeLists.txt +++ b/PySide/QtUiTools/CMakeLists.txt @@ -36,4 +36,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtUiTools${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools/pyside_qtuitools_python.h DESTINATION include/PySide/QtUiTools/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_uitools.xml + DESTINATION share/PySide/typesystems) diff --git a/PySide/QtWebKit/CMakeLists.txt b/PySide/QtWebKit/CMakeLists.txt index 09f5bfa..7bdf6e0 100644 --- a/PySide/QtWebKit/CMakeLists.txt +++ b/PySide/QtWebKit/CMakeLists.txt @@ -79,3 +79,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtWebKit${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/pyside_qtwebkit_python.h DESTINATION include/PySide/QtWebKit/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_webkit.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtXml/CMakeLists.txt b/PySide/QtXml/CMakeLists.txt index 6ee39d7..e6b4e80 100644 --- a/PySide/QtXml/CMakeLists.txt +++ b/PySide/QtXml/CMakeLists.txt @@ -62,4 +62,7 @@ add_dependencies(QtXml QtCore) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXml${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/pyside_qtxml_python.h DESTINATION include/PySide/QtXml/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_xml.xml + DESTINATION share/PySide/typesystems) + diff --git a/PySide/QtXmlPatterns/CMakeLists.txt b/PySide/QtXmlPatterns/CMakeLists.txt index 73c6e1d..df67372 100644 --- a/PySide/QtXmlPatterns/CMakeLists.txt +++ b/PySide/QtXmlPatterns/CMakeLists.txt @@ -50,4 +50,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXmlPatterns${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns/pyside_qtxmlpatterns_python.h DESTINATION include/PySide/QtXmlPatterns/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_xmlpatterns.xml + DESTINATION share/PySide/typesystems) diff --git a/PySide/phonon/CMakeLists.txt b/PySide/phonon/CMakeLists.txt index 7392063..1b2f05f 100644 --- a/PySide/phonon/CMakeLists.txt +++ b/PySide/phonon/CMakeLists.txt @@ -71,3 +71,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/phonon${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/pyside_phonon_python.h DESTINATION include/PySide/phonon/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_phonon.xml + DESTINATION share/PySide/typesystems) + diff --git a/libpyside/PySideConfig.cmake.in b/libpyside/PySideConfig.cmake.in index f302364..1d9c9ae 100644 --- a/libpyside/PySideConfig.cmake.in +++ b/libpyside/PySideConfig.cmake.in @@ -1,5 +1,7 @@ # PYSIDE_INCLUDE_DIR - Directories to include to use PySide # PYSIDE_LIBRARIES - Files to link against to use PySide +# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide SET(PYSIDE_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PySide") SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside@CMAKE_SHARED_LIBRARY_SUFFIX@") +SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/shared/PySide/typesystems") diff --git a/libpyside/pyside.pc.in b/libpyside/pyside.pc.in index 61cb808..ca7a0a5 100644 --- a/libpyside/pyside.pc.in +++ b/libpyside/pyside.pc.in @@ -2,6 +2,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@ libdir=@LIB_INSTALL_DIR@ includedir=@CMAKE_INSTALL_PREFIX@/include/PySide +typesystemdir=@CMAKE_INSTALL_PREFIX@/share/PySide/typesystems Name: PySide Description: Support library for Python bindings of Qt-based libraries. From 928e0b2795244d18a87764effe3d2a94504ac272 Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Sun, 16 May 2010 14:42:38 +0200 Subject: [PATCH 0046/1129] Fix libpyside install. On Windows, if LIBRARY DESTINATION is given, ARCHIVE DESTINATION must also be given otherwise CMake fails with 'install Library TARGETS given no DESTINATION!' Reviewer: Marcelo Lira Luciano Wolf --- libpyside/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index 0597f16..463c013 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -46,7 +46,10 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideVersion.cmake.in" "${CMAKE_CUR install(FILES ${libpyside_HEADERS} DESTINATION include/${BINDING_NAME}) -install(TARGETS pyside LIBRARY DESTINATION ${LIB_INSTALL_DIR}) +install(TARGETS pyside EXPORT pyside + LIBRARY DESTINATION "${LIB_INSTALL_DIR}" + ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" + RUNTIME DESTINATION bin) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pyside.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig.cmake" DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide-${BINDING_API_VERSION}") From 54b69c3595cadfbfa5f65849d4dd106718920976 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Fri, 18 Jun 2010 19:37:21 -0300 Subject: [PATCH 0047/1129] Adding qInstallMsgHandler() method support. Reviewer: Marcelo Lira Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 32 +++++++++++++++ tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/qinstallmsghandler_test.py | 53 +++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/QtCore/qinstallmsghandler_test.py diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 8b1bab6..3376973 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -718,6 +718,38 @@ #include <pyside.h> + + // Define a global variable to handle qInstallMsgHandler callback + static PyObject* qtmsghandler = 0; + + void + msghandlercallback(QtMsgType type, const char* msg) + { + Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg)); + Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); + } + + + + if (%PYARG_1 == Py_None) { + qInstallMsgHandler(0); + %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; + qtmsghandler = 0; + } else if (!PyCallable_Check(%PYARG_1)) { + PyErr_SetString(PyExc_TypeError, "parameter must be callable"); + } else { + %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; + Py_INCREF(%PYARG_1); + qtmsghandler = %PYARG_1; + qInstallMsgHandler(msghandlercallback); + } + + if (%PYARG_0 == Py_None) + Py_INCREF(%PYARG_0); + + + + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 35fa7b9..b5f59d4 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -22,6 +22,7 @@ PYSIDE_TEST(qfileinfo_test.py) PYSIDE_TEST(qfile_test.py) PYSIDE_TEST(qflags_test.py) PYSIDE_TEST(qhandle_test.py) +PYSIDE_TEST(qinstallmsghandler_test.py) PYSIDE_TEST(qlinef_test.py) PYSIDE_TEST(qlocale_test.py) PYSIDE_TEST(qmetaobject_test.py) diff --git a/tests/QtCore/qinstallmsghandler_test.py b/tests/QtCore/qinstallmsghandler_test.py new file mode 100644 index 0000000..d76c6ce --- /dev/null +++ b/tests/QtCore/qinstallmsghandler_test.py @@ -0,0 +1,53 @@ + +'''Test cases for qInstallMsgHandler''' + +import unittest +import sys + +from PySide.QtCore import * + +param = [] + +def handler(msgt, msg): + global param + param = [msgt, msg] + +def handleruseless(msgt, msg): + pass + +class QInstallMsgHandlerTest(unittest.TestCase): + + def tearDown(self): + # Ensure that next test will have a clear environment + qInstallMsgHandler(None) + + def testNone(self): + ret = qInstallMsgHandler(None) + self.assertEqual(ret, None) + + def testRet(self): + ret = qInstallMsgHandler(None) + self.assertEqual(ret, None) + refcount = sys.getrefcount(handleruseless) + retNone = qInstallMsgHandler(handleruseless) + self.assertEqual(sys.getrefcount(handleruseless), refcount + 1) + rethandler = qInstallMsgHandler(None) + self.assertEqual(rethandler, handleruseless) + del rethandler + self.assertEqual(sys.getrefcount(handleruseless), refcount) + + def testHandler(self): + rethandler = qInstallMsgHandler(handler) + qDebug("Test Debug") + self.assertEqual(param[0], QtDebugMsg) + self.assertEqual(param[1], "Test Debug") + qWarning("Test Warning") + self.assertEqual(param[0], QtWarningMsg) + self.assertEqual(param[1], "Test Warning") + qCritical("Test Critical") + self.assertEqual(param[0], QtCriticalMsg) + self.assertEqual(param[1], "Test Critical") + +if __name__ == '__main__': + unittest.main() + From 86d0f6715ed282f7fecf789a85feb03d913ea7d9 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 21 Jun 2010 14:10:10 -0300 Subject: [PATCH 0048/1129] Fix bug: "Debug build fails to run the tests (doesn't work) [_Py_AddToAllObjects: Assertion (...) failed]" Reviewer: Marcelo Lira Luciano Wolf --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d0461bf..3d57095 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,16 @@ if (NOT SITE_PACKAGE) endif() endif() +# Detect if the python libs were compiled in debug mode +execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ + print sysconfig.get_config_var('Py_DEBUG')" + OUTPUT_VARIABLE PY_DEBUG + OUTPUT_STRIP_TRAILING_WHITESPACE) +if (PY_DEBUG) + add_definitions("-DPy_DEBUG") +endif() + set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) enable_testing() From 499d42a6f408ab64795b4c8a7ba507a682c7cb39 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 21 Jun 2010 19:37:30 -0300 Subject: [PATCH 0049/1129] Included qsinal.h in installed files. --- libpyside/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index 463c013..d775028 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -35,6 +35,7 @@ set(libpyside_HEADERS pysidemacros.h signalmanager.h pyside.h + qsignal.h ) # create pkg-config file From 09cb758d9ecfa21f4b8c5b73a43ce05ca6ee0492 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 22 Jun 2010 18:08:05 -0300 Subject: [PATCH 0050/1129] Fixed layout policy. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtGui/glue/qlayout_help_functions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h index 186e0ec..cea0b56 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.h @@ -22,8 +22,8 @@ inline void addLayoutOwnership(QLayout *layout, QLayout *other) if (!parent) return; - for (int i=0, i_max=layout->count(); i < i_max; i++) { - addLayoutOwnership(layout, layout->itemAt(i)); + for (int i=0, i_max=other->count(); i < i_max; i++) { + addLayoutOwnership(layout, other->itemAt(i)); } Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); From b1f7791a7257b0fb5a766cd1825fb32d52403bee Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 22 Jun 2010 18:08:25 -0300 Subject: [PATCH 0051/1129] Check for invalid signal or slot name. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtCore/glue/qobject_connect.cpp | 5 ++++- libpyside/signalmanager.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp index e9de411..535dd10 100644 --- a/PySide/QtCore/glue/qobject_connect.cpp +++ b/PySide/QtCore/glue/qobject_connect.cpp @@ -25,6 +25,9 @@ static bool getReceiver(PyObject *callback, QObject **receiver, PyObject **self) static bool qobjectConnect(QObject* source, const char* signal, QObject* receiver, const char* slot, Qt::ConnectionType type) { + if (!signal || !slot) + return false; + if (!PySide::checkSignal(signal)) return false; signal++; @@ -39,7 +42,7 @@ static bool qobjectConnect(QObject* source, const char* signal, QObject* receive static bool qobjectConnectCallback(QObject* source, const char* signal, PyObject* callback, Qt::ConnectionType type) { - if (!PySide::checkSignal(signal)) + if (!signal || !PySide::checkSignal(signal)) return false; signal++; diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index d44743c..1115d24 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -82,11 +82,14 @@ using namespace PySide; bool PySide::isSignal(const char* signal) { - return signal[0] == PYSIDE_SIGNAL; + return (signal && signal[0] == PYSIDE_SIGNAL); } bool PySide::checkSignal(const char* signal) { + if (!signal) + return false; + if (signal[0] != PYSIDE_SIGNAL) { PyErr_SetString(PyExc_TypeError, "Use the function PySide.QtCore.SIGNAL on signals"); return false; From 174a3c2760cae01eb2276f88d1610c425ec29c70 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 22 Jun 2010 18:12:56 -0300 Subject: [PATCH 0052/1129] Fixed typo in typesystem install path. Reviewer: Hugo Parente Lima , Luciano Wolf --- libpyside/PySideConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpyside/PySideConfig.cmake.in b/libpyside/PySideConfig.cmake.in index 1d9c9ae..6d618a5 100644 --- a/libpyside/PySideConfig.cmake.in +++ b/libpyside/PySideConfig.cmake.in @@ -4,4 +4,4 @@ SET(PYSIDE_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PySide") SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside@CMAKE_SHARED_LIBRARY_SUFFIX@") -SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/shared/PySide/typesystems") +SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide/typesystems") From 7373ecb1c067f1f1c0156e88d1ed799ef8b02a24 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 22 Jun 2010 18:34:55 -0300 Subject: [PATCH 0053/1129] use original name on activated function. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 7a6f2b0..bb59367 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3065,12 +3065,6 @@ - - - - - - @@ -4236,14 +4230,6 @@ - > - - - - - - - From d1ee9643270fcdad8ab7db9f812194be2e2c9d94 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 22 Jun 2010 18:54:31 -0300 Subject: [PATCH 0054/1129] Fixed http test. Reviewer: Hugo Parente Lima , Luciano Wolf --- tests/QtNetwork/http_test.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py index 5d40405..531316d 100644 --- a/tests/QtNetwork/http_test.py +++ b/tests/QtNetwork/http_test.py @@ -22,7 +22,8 @@ class HttpSignalsCase(UsesQApplication): def tearDown(self): self.httpd.shutdown() - del self.http + self.http = None + self.httpd = None super(HttpSignalsCase, self).tearDown() def callback(self, ident): @@ -32,7 +33,7 @@ class HttpSignalsCase(UsesQApplication): def testDefaultArgs(self): #QHttp signal requestStarted signal # @bug 114 - QObject.connect(self.http, SIGNAL('requestStarted(int)'), self.callback) + self.http.requestStarted.connect(self.callback) self.http.get(self.url.path()) self.app.exec_() From 9a662a134c6d437edbdc795c00588a249557a0c2 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 25 Jun 2010 17:03:04 -0300 Subject: [PATCH 0055/1129] Used default constructor for primitive types with complex name. Reviewer: Marcelo Lira Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 3376973..5b9ea30 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -108,26 +108,26 @@ - - + + - + - + - + - + - + - - + + - + From ee00f28629745a7b615a0ce6e8c723605e0e1f35 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Fri, 25 Jun 2010 17:47:09 -0300 Subject: [PATCH 0056/1129] Fix cmake files used by other projects to detect PySide. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Luciano Wolf --- CMakeLists.txt | 2 +- libpyside/CMakeLists.txt | 4 ++-- .../{PySideVersion.cmake.in => PySideConfigVersion.cmake.in} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename libpyside/{PySideVersion.cmake.in => PySideConfigVersion.cmake.in} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d57095..61a6116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ endif() find_package(PythonLibs REQUIRED) find_package(PythonInterp REQUIRED) -find_package(Shiboken REQUIRED) +find_package(Shiboken 0.3.3 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) set(BINDING_NAME PySide) diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index d775028..efbe1f2 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -43,7 +43,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pyside.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/pyside.pc" @ONLY) # create cmake-config files configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig.cmake" @ONLY) -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideVersion.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PySideVersion.cmake" @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideConfigVersion.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PySideConfigVersion.cmake" @ONLY) install(FILES ${libpyside_HEADERS} DESTINATION include/${BINDING_NAME}) @@ -54,5 +54,5 @@ install(TARGETS pyside EXPORT pyside install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pyside.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig.cmake" DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide-${BINDING_API_VERSION}") -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideVersion.cmake" +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideConfigVersion.cmake" DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide-${BINDING_API_VERSION}") diff --git a/libpyside/PySideVersion.cmake.in b/libpyside/PySideConfigVersion.cmake.in similarity index 100% rename from libpyside/PySideVersion.cmake.in rename to libpyside/PySideConfigVersion.cmake.in From b812f04d2481464d8a0c0e117bba9d9aaf727e8c Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 29 Jun 2010 10:04:15 -0300 Subject: [PATCH 0057/1129] Fix bug#256 - "PySide does not support signals with containers." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Marcelo Lira Renato Araújo --- libpyside/pysideconversions.h | 3 +++ tests/signals/CMakeLists.txt | 1 + tests/signals/list_signal_test.py | 35 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/signals/list_signal_test.py diff --git a/libpyside/pysideconversions.h b/libpyside/pysideconversions.h index 86f5003..32d5f34 100644 --- a/libpyside/pysideconversions.h +++ b/libpyside/pysideconversions.h @@ -67,6 +67,7 @@ struct QtDictConverter return true; } + static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } static inline PyObject* toPython(const QtDict& cppobj) { PyObject* result = PyDict_New(); @@ -133,6 +134,7 @@ struct QtMultiMapConverter return true; } + static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } static inline PyObject* toPython(const MultiMap& cppObj) { PyObject* result = PyDict_New(); @@ -194,6 +196,7 @@ struct QSequenceConverter } return true; } + static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } static PyObject* toPython(const T& cppobj) { PyObject* result = PyList_New((int) cppobj.size()); diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index a6d564f..e09be0e 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -30,3 +30,4 @@ PYSIDE_TEST(signal_with_primitive_type_test.py) PYSIDE_TEST(slot_reference_count_test.py) PYSIDE_TEST(static_metaobject_test.py) PYSIDE_TEST(upstream_segfault_test.py) +PYSIDE_TEST(list_signal_test.py) diff --git a/tests/signals/list_signal_test.py b/tests/signals/list_signal_test.py new file mode 100644 index 0000000..c65eb11 --- /dev/null +++ b/tests/signals/list_signal_test.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +import unittest + +from PySide.QtCore import * +from PySide.QtGui import * + +class ListConnectionTest(unittest.TestCase): + + def modifyScene(self): + self.scene.addLine(0, 0, 10, 10) + + def sceneChanged(self, rects): + # Qt isn't so cute and sends this signal with empty lists and null rects sometimes. + if len(rects) > 0 and not rects[0].isNull(): + self.rects = rects + QApplication.quit() + + def testConnection(self): + app = QApplication([]) + + self.scene = QGraphicsScene() + QTimer.singleShot(0, self.modifyScene) + self.scene.changed.connect(self.sceneChanged) + + app.exec_() + self.assertEquals(len(self.rects), 1) + self.assertEquals(self.rects[0].x(), 0) + self.assertEquals(self.rects[0].y(), 0) + self.assertEquals(self.rects[0].width(), 10) + self.assertEquals(self.rects[0].height(), 10) + +if __name__ == '__main__': + unittest.main() + From 27530522a8b494874549f11bcdd2a56e685870ba Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 29 Jun 2010 10:43:37 -0300 Subject: [PATCH 0058/1129] Fix qwidget_test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- tests/QtGui/CMakeLists.txt | 2 +- tests/QtGui/qwidget_test.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 5f50ea8..3c9c2c3 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -52,7 +52,7 @@ PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) -PYSIDE_TEST(qwidget_test.py TRUE) #Bug 237 +PYSIDE_TEST(qwidget_test.py) PYSIDE_TEST(reference_count_test.py) PYSIDE_TEST(standardpixmap_test.py) PYSIDE_TEST(timed_app_test.py) diff --git a/tests/QtGui/qwidget_test.py b/tests/QtGui/qwidget_test.py index a14311c..70271a0 100644 --- a/tests/QtGui/qwidget_test.py +++ b/tests/QtGui/qwidget_test.py @@ -11,10 +11,7 @@ class QWidgetInherit(QMainWindow): class QWidgetTest(UsesQApplication): def testInheritance(self): - newobj = QWidgetInherit() - widget = QWidget() - newobj.setCentralWidget(widget) - self.assertEqual(widget, newobj.centralWidget()) + self.assertRaises(TypeError, QWidgetInherit) class QWidgetVisible(UsesQApplication): From 4c6e35634c220a9bc64b33db41a80360a3bc6e18 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 29 Jun 2010 16:37:05 -0300 Subject: [PATCH 0059/1129] Created unit test to use signals in objects not created on python. Reviewer: Hugo Parente Lima Marcelo Lira --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/qdynamic_signal.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/QtGui/qdynamic_signal.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 3c9c2c3..02b7d43 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -18,6 +18,7 @@ PYSIDE_TEST(qbrush_test.py) PYSIDE_TEST(qcolor_test.py) PYSIDE_TEST(qaction_test.py) PYSIDE_TEST(qdatastream_gui_operators_test.py) +PYSIDE_TEST(qdynamic_signal.py) PYSIDE_TEST(qfontdialog_test.py) PYSIDE_TEST(qfontmetrics_test.py) PYSIDE_TEST(qgraphicsitem_isblocked_test.py) diff --git a/tests/QtGui/qdynamic_signal.py b/tests/QtGui/qdynamic_signal.py new file mode 100644 index 0000000..db3218e --- /dev/null +++ b/tests/QtGui/qdynamic_signal.py @@ -0,0 +1,27 @@ + +import unittest + +from PySide.QtGui import QInputDialog + +from helper import UsesQApplication + +class DynamicSignalTest(UsesQApplication): + + def cp(self, obj): + self._called = True + + def testQDialog(self): + dlg = QInputDialog() + dlg.setInputMode(QInputDialog.TextInput) + lst = dlg.children() + self.assert_(len(lst)) + obj = lst[0] + self._called = False + obj.destroyed.connect(self.cb) + obj = None + del dlg + self.assert_(self._called) + + +if __name__ == '__main__': + unittest.main() From 9ee7d00d11693fff3cebf6db0d3d5b18ed8666fb Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 29 Jun 2010 17:55:23 -0300 Subject: [PATCH 0060/1129] Fix reference leak in PySide::signalUpdateSource. --- libpyside/qsignal.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index 43c02f1..aa211a7 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -228,16 +228,15 @@ PyObject* signal_instance_get_item(PyObject* self, PyObject* key) void signalUpdateSource(PyObject* source) { - PyObject* attrs = PyObject_Dir(source); - for(int i = 0, i_max = PyList_Size(attrs); i < i_max; i++) { - PyObject *attrName = PyList_GET_ITEM(attrs, i); - PyObject *attr = PyObject_GetAttr(source, attrName); + Shiboken::AutoDecRef attrs(PyObject_Dir(source)); + for(int i = 0, i_max = PyList_GET_SIZE(attrs.object()); i < i_max; i++) { + PyObject *attrName = PyList_GET_ITEM(attrs.object(), i); + Shiboken::AutoDecRef attr(PyObject_GetAttr(source, attrName)); if (attr->ob_type == &Signal_Type) { Shiboken::AutoDecRef signalInstance(reinterpret_cast(PyObject_New(SignalInstanceData, &SignalInstance_Type))); - signal_instance_initialize(signalInstance, attrName, reinterpret_cast(attr), source, 0); + signal_instance_initialize(signalInstance, attrName, reinterpret_cast(attr.object()), source, 0); PyObject_SetAttr(source, attrName, signalInstance); } - Py_DECREF(attr); } } From c5b700a311f3558d1d33c2894dc3ba2583bd6c46 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 29 Jun 2010 17:55:59 -0300 Subject: [PATCH 0061/1129] Fix typo in tests/QtGui/qdynamic_signal.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- tests/QtGui/qdynamic_signal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/QtGui/qdynamic_signal.py b/tests/QtGui/qdynamic_signal.py index db3218e..d44ee79 100644 --- a/tests/QtGui/qdynamic_signal.py +++ b/tests/QtGui/qdynamic_signal.py @@ -7,7 +7,7 @@ from helper import UsesQApplication class DynamicSignalTest(UsesQApplication): - def cp(self, obj): + def cb(self, obj): self._called = True def testQDialog(self): From bc4aa5ca947be692a6d016b349b1e2959a9bedf2 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 2 Jul 2010 15:56:01 -0300 Subject: [PATCH 0062/1129] Created QListWidget test. Reviewer: Hugo Parente Lima , Luciano Wolf --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/qlistwidgetitem_test.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 02b7d43..cac4fc5 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -30,6 +30,7 @@ PYSIDE_TEST(qitemselection_test.py) PYSIDE_TEST(qlayout_ref_test.py) PYSIDE_TEST(qlayout_test.py) PYSIDE_TEST(qlcdnumber_test.py) +PYSIDE_TEST(qlistwidg_test.py) PYSIDE_TEST(qlistwidgetitem_test.py) PYSIDE_TEST(qmainwindow_test.py) PYSIDE_TEST(qmatrix_test.py) diff --git a/tests/QtGui/qlistwidgetitem_test.py b/tests/QtGui/qlistwidgetitem_test.py index 8f96c51..159f38c 100644 --- a/tests/QtGui/qlistwidgetitem_test.py +++ b/tests/QtGui/qlistwidgetitem_test.py @@ -21,5 +21,6 @@ class QListWidgetItemConstructor(UsesQApplication): item = self.widgetList.item(0) self.assertEqual(item.listWidget(), self.widgetList) + if __name__ == '__main__': unittest.main() From 72235a6530831a13c940839c53e873740fad71b7 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 5 Jul 2010 14:18:43 -0300 Subject: [PATCH 0063/1129] Use original name on QVariant type lookup function. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtCore/qvariant_conversions.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index 076ed7f..613e523 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -45,21 +45,14 @@ struct Converter return QVariant::fromValue(pyObj); } else { // a class supported by QVariant? - const char* typeName = pyObj->ob_type->tp_name; - // check if the name starts with PySide. - if (!strncmp("PySide.", typeName, 7)) { - // get the type name - const char* lastDot = typeName; - for (int i = 8; typeName[i]; ++i) { - if (typeName[i] == '.') - lastDot = &typeName[i]; - } - lastDot++; - uint typeCode = QMetaType::type(lastDot); + if (Shiboken::isShibokenType(pyObj)) { + Shiboken::SbkBaseWrapperType *objType = reinterpret_cast(pyObj->ob_type); + const char* typeName = objType->original_name; + uint typeCode = QMetaType::type(typeName); if (!typeCode) {// Try with star at end, for QObject*, QWidget* and QAbstractKinectScroller* - QString typeName(lastDot); - typeName += '*'; - typeCode = QMetaType::type(typeName.toAscii()); + QString stypeName(typeName); + stypeName += '*'; + typeCode = QMetaType::type(stypeName.toAscii()); } if (typeCode) return QVariant(typeCode, reinterpret_cast(pyObj)->cptr[0]); @@ -69,7 +62,11 @@ struct Converter } } - static PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast(cppObj)); } + static PyObject* toPython(void* cppObj) + { + return toPython(*reinterpret_cast(cppObj)); + } + static PyObject* toPython(const QVariant& cppObj) { if (cppObj.isValid()) { From e64209b4d30253e11a22a5f2917953833880ba12 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 5 Jul 2010 14:19:28 -0300 Subject: [PATCH 0064/1129] Add unit test to QListWidget. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtTest/CMakeLists.txt | 1 + tests/QtGui/CMakeLists.txt | 2 +- tests/QtGui/qlistwidget_test.py | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/QtGui/qlistwidget_test.py diff --git a/PySide/QtTest/CMakeLists.txt b/PySide/QtTest/CMakeLists.txt index 2d392e4..b447f79 100644 --- a/PySide/QtTest/CMakeLists.txt +++ b/PySide/QtTest/CMakeLists.txt @@ -36,6 +36,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} add_library(QtTest MODULE ${QtTest_SRC}) set_property(TARGET QtTest PROPERTY PREFIX "") target_link_libraries(QtTest + pyside ${PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTTEST_LIBRARY} diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index cac4fc5..b875913 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -30,7 +30,7 @@ PYSIDE_TEST(qitemselection_test.py) PYSIDE_TEST(qlayout_ref_test.py) PYSIDE_TEST(qlayout_test.py) PYSIDE_TEST(qlcdnumber_test.py) -PYSIDE_TEST(qlistwidg_test.py) +PYSIDE_TEST(qlistwidget_test.py) PYSIDE_TEST(qlistwidgetitem_test.py) PYSIDE_TEST(qmainwindow_test.py) PYSIDE_TEST(qmatrix_test.py) diff --git a/tests/QtGui/qlistwidget_test.py b/tests/QtGui/qlistwidget_test.py new file mode 100644 index 0000000..b473c61 --- /dev/null +++ b/tests/QtGui/qlistwidget_test.py @@ -0,0 +1,46 @@ + +import unittest + +import sys +from PySide import QtGui, QtCore +from helper import UsesQApplication + +class QListWidgetTest(UsesQApplication): + + def populateList(self, lst): + o = QtCore.QObject() + o.setObjectName("obj") + + item = QtGui.QListWidgetItem("item0") + item.setData(QtCore.Qt.UserRole, o) + #item._data = o + self.assert_(sys.getrefcount(o), 3) + self.assert_(sys.getrefcount(item), 2) + lst.addItem(item) + self.assert_(sys.getrefcount(item), 3) + + def checkCurrentItem(self, lst): + item = lst.currentItem() + self.assert_(sys.getrefcount(item), 3) + + def checkItemData(self, lst): + item = lst.currentItem() + o = item.data(QtCore.Qt.UserRole) + self.assert_(sys.getrefcount(o), 4) + self.assertEqual(o, item._data) + self.assert_(sys.getrefcount(o), 2) + + def testConstructorWithParent(self): + lst = QtGui.QListWidget() + self.populateList(lst) + self.checkCurrentItem(lst) + i = lst.item(0) + self.assert_(sys.getrefcount(i), 3) + + del lst + self.assert_(sys.getrefcount(i), 2) + del i + + +if __name__ == '__main__': + unittest.main() From 82d1d827557f7f9aadbc4fe1f526ce2162f03621 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 5 Jul 2010 14:22:08 -0300 Subject: [PATCH 0065/1129] Implemented copy constructor to PyObjectWrapper. Reviewer: Hugo Parente Lima , Luciano Wolf --- libpyside/signalmanager.cpp | 43 +++++++++++++++++++++++++++++++++++-- libpyside/signalmanager.h | 8 ++++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 1115d24..f173400 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -54,6 +54,39 @@ #define PYTHON_TYPE "PyObject" +namespace PySide { + +PyObjectWrapper::PyObjectWrapper() + :m_me(Py_None) +{ + Py_INCREF(m_me); +} + +PyObjectWrapper::PyObjectWrapper(PyObject* me) + : m_me(me) +{ + Py_INCREF(m_me); +} + +PyObjectWrapper::PyObjectWrapper(const PyObjectWrapper &other) + : m_me(other.m_me) +{ + Py_INCREF(m_me); +} + +PyObjectWrapper::~PyObjectWrapper() +{ + Py_DECREF(m_me); +} + + +PyObjectWrapper::operator PyObject*() const +{ + return m_me; +} + +}; + namespace Shiboken { template<> @@ -71,6 +104,7 @@ struct Converter static PyObject* toPython(const PySide::PyObjectWrapper& obj) { + Py_INCREF(obj); return obj; } }; @@ -335,14 +369,18 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, Shiboken::GilState gil; QList paramTypes = method.parameterTypes(); PyObject* self = Shiboken::BindingManager::instance().retrieveWrapper(object); - Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count())); + PyObject* preparedArgs = NULL; + Py_ssize_t args_size = paramTypes.count(); + + if (args_size) + preparedArgs = PyTuple_New(args_size); for (int i = 0, max = paramTypes.count(); i < max; ++i) { void* data = args[i+1]; const char* dataType = paramTypes[i].constData(); PyObject* arg = Shiboken::TypeResolver::get(dataType)->toPython(data); - PyTuple_SET_ITEM(preparedArgs.object(), i, arg); + PyTuple_SET_ITEM(preparedArgs, i, arg); } QString methodName = method.signature(); @@ -358,6 +396,7 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, } else { qWarning() << "Dynamic slot" << methodName << "not found!"; } + Py_XDECREF(preparedArgs); } return -1; } diff --git a/libpyside/signalmanager.h b/libpyside/signalmanager.h index 70d7f08..72acd1d 100644 --- a/libpyside/signalmanager.h +++ b/libpyside/signalmanager.h @@ -50,9 +50,11 @@ namespace PySide class PYSIDE_API PyObjectWrapper { public: - PyObjectWrapper(PyObject* me) : m_me(me) { Py_INCREF(m_me); } - PyObjectWrapper() : m_me(Py_None) { Py_INCREF(m_me); } - operator PyObject*() const { return m_me; } + PyObjectWrapper(); + PyObjectWrapper(PyObject* me); + PyObjectWrapper(const PyObjectWrapper &other); + ~PyObjectWrapper(); + operator PyObject*() const; private: PyObject* m_me; }; From 2963909063e434936ba095ba9532782e7e3fd518 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 5 Jul 2010 14:23:09 -0300 Subject: [PATCH 0066/1129] Remove use of deprecated types. Reviewer: Hugo Parente Lima , Luciano Wolf --- tests/QtDeclarative/qdeclarativeview_test.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/QtDeclarative/qdeclarativeview_test.py b/tests/QtDeclarative/qdeclarativeview_test.py index 8101c5f..7a2b657 100644 --- a/tests/QtDeclarative/qdeclarativeview_test.py +++ b/tests/QtDeclarative/qdeclarativeview_test.py @@ -2,8 +2,7 @@ import unittest -from PySide.QtCore import QUrl, QStringList, QVariant -from PySide.QtGui import QPushButton +from PySide.QtCore import QUrl from PySide.QtDeclarative import QDeclarativeView from helper import adjust_filename, TimedQApplication @@ -14,7 +13,7 @@ class TestQDeclarativeView(TimedQApplication): def testQDeclarativeViewList(self): view = QDeclarativeView() - dataList = QStringList(["Item 1", "Item 2", "Item 3", "Item 4"]) + dataList = ["Item 1", "Item 2", "Item 3", "Item 4"] ctxt = view.rootContext() ctxt.setContextProperty("myModel", dataList) From 01df78dfd8a2f0b6eac8ed4fae2faf1a6592e0c9 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 5 Jul 2010 10:14:04 -0300 Subject: [PATCH 0067/1129] Remove the removal of isSortignEnabled from QtGui typesystem. --- PySide/QtGui/typesystem_gui_common.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index bb59367..349e078 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -2926,8 +2926,6 @@ - - @@ -3886,8 +3884,6 @@ - - From 56560943dfc2de0d1df5d2058bcf55ea3c9400ee Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 6 Jul 2010 10:49:53 -0300 Subject: [PATCH 0068/1129] Typesystem cleanup. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 62 ------------- PySide/QtGui/typesystem_gui_common.xml | 116 ++++-------------------- PySide/QtNetwork/typesystem_network.xml | 47 ++-------- PySide/QtOpenGL/typesystem_opengl.xml | 6 +- PySide/QtSql/typesystem_sql.xml | 15 +-- PySide/QtXml/typesystem_xml.xml | 29 +----- 6 files changed, 37 insertions(+), 238 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 5b9ea30..5fe62ed 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -173,32 +173,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -221,12 +195,10 @@ - - @@ -446,40 +418,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -507,9 +449,6 @@ - - - @@ -1328,7 +1267,6 @@ - diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 349e078..36493e3 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -102,7 +102,6 @@ - @@ -428,7 +427,6 @@ - @@ -447,7 +445,6 @@ - @@ -457,61 +454,36 @@ - - - + - - - - - - + + - - - + - - - - - - + + - - - + - - - + - - - - - - - - - - - - + + + + - @@ -519,12 +491,8 @@ - - - - - - + + @@ -543,11 +511,8 @@ - - - + - @@ -558,8 +523,6 @@ - - @@ -569,7 +532,6 @@ - @@ -582,7 +544,6 @@ - @@ -595,9 +556,7 @@ - - - + @@ -608,7 +567,6 @@ - @@ -633,7 +591,6 @@ - @@ -651,12 +608,10 @@ - - @@ -692,7 +647,6 @@ - @@ -717,7 +671,6 @@ - @@ -763,7 +716,6 @@ - @@ -777,9 +729,7 @@ - - - + @@ -795,7 +745,6 @@ - @@ -806,7 +755,6 @@ - @@ -822,7 +770,6 @@ - @@ -850,7 +797,6 @@ - @@ -861,10 +807,8 @@ - - @@ -874,8 +818,6 @@ - - @@ -1141,9 +1083,6 @@ } - - - @@ -1250,14 +1189,10 @@ - - - - - + @@ -1567,8 +1502,6 @@ - - @@ -1581,10 +1514,7 @@ - - - - + @@ -2059,7 +1989,6 @@ - @@ -2071,7 +2000,6 @@ - @@ -2987,7 +2915,6 @@ - @@ -3008,7 +2935,6 @@ - @@ -3036,7 +2962,6 @@ - @@ -3048,7 +2973,6 @@ - @@ -3090,7 +3014,6 @@ - @@ -3167,7 +3090,6 @@ - diff --git a/PySide/QtNetwork/typesystem_network.xml b/PySide/QtNetwork/typesystem_network.xml index 596aa2c..9a56b74 100644 --- a/PySide/QtNetwork/typesystem_network.xml +++ b/PySide/QtNetwork/typesystem_network.xml @@ -137,8 +137,6 @@ - - @@ -177,61 +175,36 @@ - - - - - - + - - - + - - - + - - - + - - - + - - - + - - - - - - + + - - - + - - - - - + diff --git a/PySide/QtOpenGL/typesystem_opengl.xml b/PySide/QtOpenGL/typesystem_opengl.xml index c2f3ba3..202b115 100644 --- a/PySide/QtOpenGL/typesystem_opengl.xml +++ b/PySide/QtOpenGL/typesystem_opengl.xml @@ -18,16 +18,12 @@ - - - - - + diff --git a/PySide/QtSql/typesystem_sql.xml b/PySide/QtSql/typesystem_sql.xml index 31cc8d3..7c15c69 100644 --- a/PySide/QtSql/typesystem_sql.xml +++ b/PySide/QtSql/typesystem_sql.xml @@ -21,7 +21,6 @@ - @@ -44,7 +43,6 @@ - @@ -59,24 +57,17 @@ - - - - + - - - + - - - + diff --git a/PySide/QtXml/typesystem_xml.xml b/PySide/QtXml/typesystem_xml.xml index 5c0811e..40b3879 100644 --- a/PySide/QtXml/typesystem_xml.xml +++ b/PySide/QtXml/typesystem_xml.xml @@ -16,23 +16,19 @@ --> - - + - - - @@ -46,7 +42,6 @@ - @@ -189,55 +184,41 @@ - - - - - - - + - - - + - - - - + - - - @@ -253,8 +234,6 @@ - From 154831efcf8d07932389ef8149c397357a0939b4 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 6 Jul 2010 18:45:10 -0300 Subject: [PATCH 0069/1129] Fix typo. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtXml/typesystem_xml.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/QtXml/typesystem_xml.xml b/PySide/QtXml/typesystem_xml.xml index 40b3879..e31f808 100644 --- a/PySide/QtXml/typesystem_xml.xml +++ b/PySide/QtXml/typesystem_xml.xml @@ -16,7 +16,7 @@ --> - + From c737f90c1ddbe19cbbe93cb3915e14df59f97444 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Wed, 7 Jul 2010 13:52:55 -0300 Subject: [PATCH 0070/1129] Fix qApp macro implementation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Hugo Lima --- PySide/QtGui/glue/qapplication_init.cpp | 8 ++++---- tests/QtGui/qapp_test.py | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp index 112b8e0..5c87af3 100644 --- a/PySide/QtGui/glue/qapplication_init.cpp +++ b/PySide/QtGui/glue/qapplication_init.cpp @@ -41,11 +41,11 @@ int SbkQApplication_Init(PyObject* self, PyObject* args, PyObject*) // Verify if qApp is in main module const char QAPP_MACRO[] = "qApp"; - PyObject* localsDict = PyEval_GetLocals(); - if (localsDict) { - PyObject* qAppObj = PyDict_GetItemString(localsDict, QAPP_MACRO); + PyObject* globalsDict = PyEval_GetGlobals(); + if (globalsDict) { + PyObject* qAppObj = PyDict_GetItemString(globalsDict, QAPP_MACRO); if (qAppObj) - PyDict_SetItemString(localsDict, QAPP_MACRO, self); + PyDict_SetItemString(globalsDict, QAPP_MACRO, self); } PyObject_SetAttrString(moduleQtGui, QAPP_MACRO, self); diff --git a/tests/QtGui/qapp_test.py b/tests/QtGui/qapp_test.py index c371492..fd1d60f 100644 --- a/tests/QtGui/qapp_test.py +++ b/tests/QtGui/qapp_test.py @@ -3,15 +3,17 @@ import unittest -from PySide import QtGui +from PySide.QtGui import * class QAppPresence(unittest.TestCase): def testQApp(self): #QtGui.qApp variable is instance of QApplication - self.assert_(isinstance(QtGui.qApp, QtGui.QApplication)) + self.assert_(isinstance(qApp, QApplication)) +def main(): + app = QApplication([]) + unittest.main() if __name__ == '__main__': - app = QtGui.QApplication([]) - unittest.main() + main() From 83db5730319cc258e683a12567ba9362dbd07d45 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 5 Jul 2010 18:08:25 -0300 Subject: [PATCH 0071/1129] Use original name in type discovery during signal/slot. Reviewer: Hugo Parente Lima , Luciano Wolf --- libpyside/qsignal.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index aa211a7..b19c565 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -243,14 +243,20 @@ void signalUpdateSource(PyObject* source) char* signal_get_type_name(PyObject* type) { if (PyType_Check(type)) { - //tp_name return the full name - Shiboken::AutoDecRef typeName(PyObject_GetAttrString(type, "__name__")); - char *aux = strdup(PyString_AS_STRING(typeName.object())); - if (Shiboken::TypeResolver::getType(aux) == Shiboken::TypeResolver::ObjectType) { - aux = reinterpret_cast(realloc(aux, strlen(aux) + 1)); - aux = strcat(aux, "*"); + char *typeName = NULL; + if (type->ob_type == &Shiboken::SbkBaseWrapperType_Type) { + Shiboken::SbkBaseWrapperType *objType = reinterpret_cast(type); + typeName = strdup(objType->original_name); + } else { + //tp_name return the full name + Shiboken::AutoDecRef otypeName(PyObject_GetAttrString(type, "__name__")); + typeName = strdup(PyString_AS_STRING(otypeName.object())); } - return aux; + if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ObjectType) { + typeName = reinterpret_cast(realloc(typeName, strlen(typeName) + 1)); + typeName = strcat(typeName, "*"); + } + return typeName; } else if (PyString_Check(type)) { return strdup(PyString_AS_STRING(type)); } From 693ae6d6c4073a483524af48e7a1a0ad1fba1131 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 8 Jul 2010 10:47:24 -0300 Subject: [PATCH 0072/1129] Modify multiple connections test to avoid use more then 50 slots supported by PySide. Reviewer: Hugo Parente Lima , Luciano Wolf --- tests/signals/multiple_connections_gui_test.py | 16 +++++----------- tests/signals/multiple_connections_test.py | 17 ++++------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/tests/signals/multiple_connections_gui_test.py b/tests/signals/multiple_connections_gui_test.py index 72feac0..3bff7c3 100644 --- a/tests/signals/multiple_connections_gui_test.py +++ b/tests/signals/multiple_connections_gui_test.py @@ -12,11 +12,6 @@ except ImportError: from helper import BasicPySlotCase, UsesQApplication -def random_gen(count=100, largest=99, lowest=0): - for i in range(count): - yield random.randint(lowest, largest) - - class MultipleSignalConnections(unittest.TestCase): '''Base class for multiple signal connection testing''' @@ -55,12 +50,11 @@ if hasQtGui: def testSpinBoxValueChanged(self): """Multiple connections to QSpinBox.valueChanged(int)""" - for test in random_gen(10): - sender = QSpinBox() - #FIXME if number of receivers if higher than 50, segfaults - receivers = [BasicPySlotCase() for x in range(10)] - self.run_many(sender, 'valueChanged(int)', sender.setValue, - receivers, (test,)) + sender = QSpinBox() + #FIXME if number of receivers if higher than 50, segfaults + receivers = [BasicPySlotCase() for x in range(10)] + self.run_many(sender, 'valueChanged(int)', sender.setValue, + receivers, (1,)) if __name__ == '__main__': unittest.main() diff --git a/tests/signals/multiple_connections_test.py b/tests/signals/multiple_connections_test.py index 5daeaab..57ea898 100644 --- a/tests/signals/multiple_connections_test.py +++ b/tests/signals/multiple_connections_test.py @@ -1,7 +1,6 @@ import sys import unittest -import random from functools import partial from PySide.QtCore import QObject, SIGNAL, QProcess @@ -9,11 +8,6 @@ from PySide.QtCore import QObject, SIGNAL, QProcess from helper import BasicPySlotCase, UsesQCoreApplication -def random_gen(count=50, largest=49, lowest=0): - for i in range(count): - yield random.randint(lowest, largest) - - class MultipleSignalConnections(unittest.TestCase): '''Base class for multiple signal connection testing''' @@ -28,10 +22,9 @@ class MultipleSignalConnections(unittest.TestCase): if args is None: args = tuple() - for rec in receivers: rec.setUp() - QObject.connect(sender, SIGNAL(signal), rec.cb) + self.assert_(QObject.connect(sender, SIGNAL(signal), rec.cb)) rec.args = tuple(args) emitter(*args) @@ -49,11 +42,9 @@ class PythonMultipleSlots(UsesQCoreApplication, MultipleSignalConnections): class Dummy(QObject): pass - for test in random_gen(20): - sender = Dummy() - receivers = [BasicPySlotCase() for x in range(10)] - self.run_many(sender, 'foobar', partial(sender.emit, - SIGNAL('foobar')), receivers, (test, )) + sender = Dummy() + receivers = [BasicPySlotCase() for x in range(10)] + self.run_many(sender, 'foobar', partial(sender.emit,SIGNAL('foobar')), receivers, (0, )) class QProcessMultipleSlots(UsesQCoreApplication, MultipleSignalConnections): From 1c4ee915c07daae9919e890072593b51e54c9aec Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 6 Jul 2010 18:44:00 -0300 Subject: [PATCH 0073/1129] Implemented support to properties on QMetaObject. Reviewer: Hugo Parente Lima , Luciano Wolf --- libpyside/CMakeLists.txt | 2 + libpyside/dynamicqmetaobject.cpp | 242 ++++++++++++++++++++--- libpyside/dynamicqmetaobject.h | 21 ++ libpyside/pyside.cpp | 3 + libpyside/qproperty.cpp | 318 +++++++++++++++++++++++++++++++ libpyside/qproperty.h | 187 ++++++++++++++++++ libpyside/qsignal.cpp | 5 +- libpyside/signalmanager.cpp | 83 +++++++- libpyside/signalmanager.h | 2 + tests/QtScript/CMakeLists.txt | 1 + tests/QtScript/property_test.py | 62 ++++++ 11 files changed, 893 insertions(+), 33 deletions(-) create mode 100644 libpyside/qproperty.cpp create mode 100644 libpyside/qproperty.h create mode 100644 tests/QtScript/property_test.py diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index efbe1f2..57ecb80 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -6,6 +6,7 @@ signalmanager.cpp globalreceiver.cpp qsignal.cpp qslot.cpp +qproperty.cpp pyside.cpp ) @@ -36,6 +37,7 @@ set(libpyside_HEADERS signalmanager.h pyside.h qsignal.h + qproperty.h ) # create pkg-config file diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp index 562f2d4..8f97b56 100644 --- a/libpyside/dynamicqmetaobject.cpp +++ b/libpyside/dynamicqmetaobject.cpp @@ -43,11 +43,36 @@ #include #include "qsignal.h" +#include "qproperty.h" #define MAX_SIGNALS_COUNT 50 +#define MAX_SLOTS_COUNT 50 using namespace PySide; +enum PropertyFlags { + Invalid = 0x00000000, + Readable = 0x00000001, + Writable = 0x00000002, + Resettable = 0x00000004, + EnumOrFlag = 0x00000008, + StdCppSet = 0x00000100, +// Override = 0x00000200, + Constant = 0x00000400, + Final = 0x00000800, + Designable = 0x00001000, + ResolveDesignable = 0x00002000, + Scriptable = 0x00004000, + ResolveScriptable = 0x00008000, + Stored = 0x00010000, + ResolveStored = 0x00020000, + Editable = 0x00040000, + ResolveEditable = 0x00080000, + User = 0x00100000, + ResolveUser = 0x00200000, + Notify = 0x00400000 +}; + static int registerString(const QByteArray& s, QList* strings) { int idx = 0; @@ -61,6 +86,89 @@ static int registerString(const QByteArray& s, QList* strings) return idx; } +static int qvariant_nameToType(const char* name) +{ + if (!name) + return 0; + + if (strcmp(name, "QVariant") == 0) + return 0xffffffff; + if (strcmp(name, "QCString") == 0) + return QMetaType::QByteArray; + if (strcmp(name, "Q_LLONG") == 0) + return QMetaType::LongLong; + if (strcmp(name, "Q_ULLONG") == 0) + return QMetaType::ULongLong; + if (strcmp(name, "QIconSet") == 0) + return QMetaType::QIcon; + + uint tp = QMetaType::type(name); + return tp < QMetaType::User ? tp : 0; +} + +/* + Returns true if the type is a QVariant types. +*/ +static bool isVariantType(const char* type) +{ + return qvariant_nameToType(type) != 0; +} + +/*! + Returns true if the type is qreal. +*/ +static bool isQRealType(const char *type) +{ + return strcmp(type, "qreal") == 0; +} + +uint PropertyData::flags() const +{ + const char* typeName = type().data(); + uint flags = Invalid; + if (!isVariantType(typeName)) + flags |= EnumOrFlag; + else if (!isQRealType(typeName)) + flags |= qvariant_nameToType(typeName) << 24; + + if (qproperty_is_readble(m_data)) + flags |= Readable; + + if (qproperty_is_writable(m_data)) + flags |= Writable; + + if (qproperty_has_reset(m_data)) + flags |= Resettable; + + if (!qproperty_is_designable(m_data)) + flags |= ResolveDesignable; + else + flags |= Designable; + + if (!qproperty_is_scriptable(m_data)) + flags |= ResolveScriptable; + else + flags |= Scriptable; + + if (!qproperty_is_stored(m_data)) + flags |= ResolveStored; + else + flags |= Stored; + + if (!qproperty_is_user(m_data)) + flags |= ResolveUser; + else + flags |= User; + + if (qproperty_is_constant(m_data)) + flags |= Constant; + + if (qproperty_is_final(m_data)) + flags |= Final; + + return flags; +} + MethodData::MethodData(const char* signature, const char* type) { m_signature = QSharedPointer(new QByteArray(signature)); @@ -107,6 +215,39 @@ bool MethodData::isValid() const return m_signature->size(); } + +PropertyData::PropertyData(const char* name, PyObject* data) + : m_name(name), m_data(data) +{ +} + +QByteArray PropertyData::type() const +{ + return QByteArray(qproperty_get_type(m_data)); +} + + +bool PropertyData::isValid() const +{ + return !m_name.isEmpty(); +} + +QByteArray PropertyData::name() const +{ + return m_name; +} + +bool PropertyData::operator==(const PropertyData& other) const +{ + return m_data == other.m_data; +} + +bool PropertyData::operator==(const char* name) const +{ + return m_name == QString(name); +} + + DynamicQMetaObject::DynamicQMetaObject(const char* className, const QMetaObject* metaObject) { d.superdata = metaObject; @@ -153,6 +294,10 @@ void DynamicQMetaObject::addSlot(const char* slot, const char* type) if (i != m_slots.end()) return; + if (m_slots.size() >= MAX_SLOTS_COUNT) { + qWarning() << "Fail to add dynamic slot to QObject. PySide support at most" << MAX_SLOTS_COUNT << "dynamic slots."; + return; + } //search for a empty space MethodData blank; @@ -177,6 +322,24 @@ void DynamicQMetaObject::removeSlot(uint index) } } +void DynamicQMetaObject::addProperty(const char* property, PyObject* data) +{ + QLinkedList::iterator i = qFind(m_properties.begin(), m_properties.end(), property); + if (i != m_properties.end()) + return; + + //search for a empty space + PropertyData blank; + i = qFind(m_properties.begin(), m_properties.end(), blank); + if (i != m_properties.end()) { + *i = PropertyData(property, data); + } else { + m_properties << PropertyData(property, data); + } + updateMetaObject(); +} + + DynamicQMetaObject* DynamicQMetaObject::createBasedOn(PyObject* pyObj, PyTypeObject* type, const QMetaObject* base) { PyObject* key; @@ -189,6 +352,11 @@ DynamicQMetaObject* DynamicQMetaObject::createBasedOn(PyObject* pyObj, PyTypeObj while (PyDict_Next(type->tp_dict, &pos, &key, &value)) { + //Register properties + if (value->ob_type == &QProperty_Type) { + mo->addProperty(PyString_AsString(key), value); + } + //Register signals if (value->ob_type == &Signal_Type) { PyObject *attr = PyObject_GetAttr(pyObj, key); @@ -234,6 +402,35 @@ void DynamicQMetaObject::removeSignal(uint index) } } +void DynamicQMetaObject::writeMethodsData(QLinkedList& methods, + unsigned int **data, + QList *strings, + int *prtIndex, + int max_count, + int null_index, + int flags) +{ + int index = *prtIndex; + + QLinkedList::iterator iMethod = methods.begin(); + for(int i=0; i < max_count; i++) { + QByteArray mType; + if (iMethod != methods.end() && ((*iMethod).signature().size() > 0) ) { + (*data)[index++] = registerString((*iMethod).signature(), strings); // func name + mType = (*iMethod).type(); + iMethod++; + } else { + (*data)[index++] = null_index; // func name + } + (*data)[index++] = null_index; // arguments + (*data)[index++] = (mType.size() > 0 ? registerString(mType, strings) : null_index); // normalized type + (*data)[index++] = null_index; // tags + (*data)[index++] = flags; + } + + *prtIndex = index; +} + void DynamicQMetaObject::updateMetaObject() { // these values are from moc source code, generator.cpp:66 @@ -251,22 +448,23 @@ void DynamicQMetaObject::updateMetaObject() }; uint n_signals = MAX_SIGNALS_COUNT; - uint n_methods = n_signals + m_slots.count(); + uint n_methods = n_signals + MAX_SLOTS_COUNT; + uint n_properties = m_properties.size(); int header[] = {5, // revision 0, // class name index in m_metadata 0, 0, // classinfo and classinfo index, not used by us n_methods, 0, // method count and method list index - 0, 0, // prop count and prop indexes + n_properties, 0, // prop count and prop indexes 0, 0, // enum count and enum index 0, 0, // constructors - MAX_SIGNALS_COUNT}; + n_signals}; const int HEADER_LENGHT = sizeof(header)/sizeof(int); header[5] = HEADER_LENGHT; // header size + 5 indexes per method + an ending zero delete[] d.data; unsigned int* data; - data = new unsigned int[HEADER_LENGHT + n_methods*5 + 1]; + data = new unsigned int[HEADER_LENGHT + n_methods*5 + n_properties*3 + 1]; std::memcpy(data, header, sizeof(header)); QList strings; @@ -275,35 +473,25 @@ void DynamicQMetaObject::updateMetaObject() int index = HEADER_LENGHT; //write signals - QLinkedList::iterator iSignal = m_signals.begin(); - for(int i=0; i < MAX_SIGNALS_COUNT; i++) { - QByteArray sigType; - if (iSignal != m_signals.end() && ((*iSignal).signature().size() > 0) ) { - data[index++] = registerString((*iSignal).signature(), &strings); // func name - sigType = (*iSignal).type(); - iSignal++; - } else { - data[index++] = NULL_INDEX; // func name - } - data[index++] = NULL_INDEX; // arguments - data[index++] = (sigType.size() > 0 ? registerString(sigType, &strings) : NULL_INDEX); // normalized type - data[index++] = NULL_INDEX; // tags - data[index++] = AccessPublic | MethodSignal; // flags - } - + writeMethodsData(m_signals, &data, &strings, &index, MAX_SIGNALS_COUNT, NULL_INDEX, AccessPublic | MethodSignal); //write slots - foreach(MethodData slot, m_slots) { - if (slot.isValid()) - data[index++] = registerString(slot.signature(), &strings); // func name + writeMethodsData(m_slots, &data, &strings, &index, MAX_SLOTS_COUNT, NULL_INDEX, AccessPublic | MethodSlot); + + if (m_properties.size()) + data[7] = index; + + //write properties + foreach(PropertyData pp, m_properties) { + if (pp.isValid()) + data[index++] = registerString(pp.name(), &strings); // name else data[index++] = NULL_INDEX; - data[index++] = NULL_INDEX; // arguments - data[index++] = (slot.isValid() ? registerString(slot.type(), &strings) : NULL_INDEX); // normalized type - data[index++] = NULL_INDEX; // tags - data[index++] = AccessPublic | MethodSlot; // flags + data[index++] = (pp.isValid() ? registerString(pp.type(), &strings) : NULL_INDEX); // normalized type + data[index++] = pp.flags(); //pp.flags(); //TODO: flags } + data[index++] = 0; // the end // create the m_metadata string diff --git a/libpyside/dynamicqmetaobject.h b/libpyside/dynamicqmetaobject.h index 69027f2..23a69c9 100644 --- a/libpyside/dynamicqmetaobject.h +++ b/libpyside/dynamicqmetaobject.h @@ -66,6 +66,23 @@ private: QSharedPointer m_type; }; +class PropertyData +{ +public: + PropertyData(){} + PropertyData(const char*name, PyObject *data); + QByteArray name() const; + QByteArray type() const; + uint flags() const; + bool isValid() const; + bool operator==(const PropertyData& other) const; + bool operator==(const char* name) const; + +private: + QByteArray m_name; + PyObject* m_data; +}; + class PYSIDE_API DynamicQMetaObject : public QMetaObject { public: @@ -74,9 +91,11 @@ public: void addSignal(const char* signal, const char* type=0); void addSlot(const char* slot, const char* type=0); + void addProperty(const char* property, PyObject* data); void removeSignal(uint idex); void removeSlot(uint index); + void removeProperty(uint index); //Retrieve Python metadata to create QMetaObject (class name, signals, slot) static DynamicQMetaObject* createBasedOn(PyObject* obj, PyTypeObject* type, const QMetaObject* base); @@ -84,9 +103,11 @@ public: private: QLinkedList m_signals; QLinkedList m_slots; + QLinkedList m_properties; QByteArray m_className; void updateMetaObject(); + void writeMethodsData(QLinkedList& methods, unsigned int **data, QList *strings, int *index, int max_count, int null_index, int flags); }; PYSIDE_API inline void deleteDynamicQMetaObject(void* data) diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp index 93271c8..744dfee 100644 --- a/libpyside/pyside.cpp +++ b/libpyside/pyside.cpp @@ -35,9 +35,11 @@ #include "pyside.h" #include "signalmanager.h" +#include "qproperty.h" extern "C" void init_signal(PyObject* module); extern "C" void init_slot(PyObject* module); +extern "C" void init_qproperty(PyObject* module); namespace PySide { @@ -46,6 +48,7 @@ void init(PyObject *module) { init_signal(module); init_slot(module); + init_qproperty(module); // Init signal manager, so it will register some meta types used by QVariant. SignalManager::instance(); } diff --git a/libpyside/qproperty.cpp b/libpyside/qproperty.cpp new file mode 100644 index 0000000..781c8cf --- /dev/null +++ b/libpyside/qproperty.cpp @@ -0,0 +1,318 @@ +/* + * This file is part of the Shiboken Python Bindings Generator project. + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. Please + * review the following information to ensure the GNU Lesser General + * Public License version 2.1 requirements will be met: + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + * + * As a special exception to the GNU Lesser General Public License + * version 2.1, the object code form of a "work that uses the Library" + * may incorporate material from a header file that is part of the + * Library. You may distribute such object code under terms of your + * choice, provided that the incorporated material (i) does not exceed + * more than 5% of the total size of the Library; and (ii) is limited to + * numerical parameters, data structure layouts, accessors, macros, + * inline functions and templates. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include +#include +#include + +#include "qproperty.h" + + +#define QPROPERTY_CLASS_NAME "QProperty" + +namespace PySide +{ + +extern "C" +{ + +typedef struct { + PyObject_HEAD + char* typeName; + PyObject* type; + PyObject* fget; + PyObject* fset; + PyObject* freset; + PyObject* fdel; + char* doc; + bool designable; + bool scriptable; + bool stored; + bool user; + bool constant; + bool final; +} QPropertyData; + +static int qproperty_init(PyObject*, PyObject*, PyObject*); +static void qproperty_free(void*); + +//aux +static char* translate_type_name(PyObject*); + +PyTypeObject QProperty_Type = { + PyObject_HEAD_INIT(0) + 0, /*ob_size*/ + QPROPERTY_CLASS_NAME, /*tp_name*/ + sizeof(QPropertyData), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + 0, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc */ + 0, /*tp_traverse */ + 0, /*tp_clear */ + 0, /*tp_richcompare */ + 0, /*tp_weaklistoffset */ + 0, /*tp_iter */ + 0, /*tp_iternext */ + 0, /*tp_methods */ + 0, /*tp_members */ + 0, /*tp_getset */ + 0, /*tp_base */ + 0, /*tp_dict */ + 0, /*tp_descr_get */ + 0, /*tp_descr_set */ + 0, /*tp_dictoffset */ + (initproc)qproperty_init, /*tp_init */ + 0, /*tp_alloc */ + PyType_GenericNew, /*tp_new */ + qproperty_free, /*tp_free */ + 0, /*tp_is_gc */ + 0, /*tp_bases */ + 0, /*tp_mro */ + 0, /*tp_cache */ + 0, /*tp_subclasses */ + 0, /*tp_weaklist */ + 0, /*tp_del */ +}; + +void init_qproperty(PyObject* module) +{ + if (PyType_Ready(&QProperty_Type) < 0) + return; + + Py_INCREF(&QProperty_Type); + PyModule_AddObject(module, QPROPERTY_CLASS_NAME, ((PyObject*)&QProperty_Type)); +} + +} // extern "C" + +int qproperty_init(PyObject* self, PyObject* args, PyObject* kwds) +{ + PyObject* type = 0; + QPropertyData *data = reinterpret_cast(self); + data->designable = true; + data->scriptable = true; + data->stored = true; + + static const char *kwlist[] = {"fget", "fset", "freset", "fdel", "doc", + "designable", "scriptable", "stored", "user", + "constant", "final", 0}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, + "O|OOOOsbbbbbb:QtCore.QProperty", (char**) kwlist, + &type, &data->fget, &data->fset, &data->freset, + &data->fdel, &data->doc, &data->designable, + &data->scriptable, &data->stored, &data->user, + &data->constant, &data->final)) + return 0; + + if (!data->fset && data->fget) + data->constant = true; + + data->typeName = translate_type_name(type); + return 1; +} + +void qproperty_free(void *self) +{ + PyObject *pySelf = reinterpret_cast(self); + QPropertyData *data = reinterpret_cast(self); + + free(data->typeName); + free(data->doc); + + pySelf->ob_type->tp_base->tp_free(self); +} + +bool isQPropertyType(PyObject* pyObj) +{ + if (pyObj) { + return pyObj->ob_type == &QProperty_Type; + } + return false; +} + +int qproperty_set(PyObject* self, PyObject* source, PyObject* value) +{ + QPropertyData *data = reinterpret_cast(self); + if (data->fset) { + Shiboken::AutoDecRef args(PyTuple_New(2)); + PyTuple_SET_ITEM(args, 0, source); + PyTuple_SET_ITEM(args, 1, value); + Py_INCREF(source); + Py_INCREF(value); + Shiboken::AutoDecRef result(PyObject_CallObject(data->fset, args)); + return (result.isNull() ? -1 : 0); + } + return -1; +} + +PyObject* qproperty_get(PyObject* self, PyObject* source) +{ + QPropertyData *data = reinterpret_cast(self); + if (data->fget) { + Shiboken::AutoDecRef args(PyTuple_New(1)); + Py_INCREF(source); + PyTuple_SET_ITEM(args, 0, source); + PyObject *ret = PyObject_CallObject(data->fget, args); + if (!ret) { + PyErr_Print(); + } + return ret; + } + return 0; +} + +int qproperty_reset(PyObject* self, PyObject* source) +{ + QPropertyData *data = reinterpret_cast(self); + if (data->freset) { + Shiboken::AutoDecRef args(PyTuple_New(1)); + Py_INCREF(source); + PyTuple_SET_ITEM(args, 0, source); + Shiboken::AutoDecRef result(PyObject_CallObject(data->freset, args)); + return (result.isNull() ? -1 : 0); + } + return -1; +} + + +const char* qproperty_get_type(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->typeName; +} + +PyObject* qproperty_get_object(PyObject* source, PyObject* name) +{ + if (PyObject_HasAttr(source, name)) { + PyObject* attr = PyObject_GenericGetAttr(source, name); + if (isQPropertyType(attr)) + return attr; + Py_DECREF(attr); + } + return 0; +} + +char* translate_type_name(PyObject* type) +{ + if (PyType_Check(type)) { + char *typeName = NULL; + if (type->ob_type == &Shiboken::SbkBaseWrapperType_Type) { + Shiboken::SbkBaseWrapperType *objType = reinterpret_cast(type); + typeName = strdup(objType->original_name); + } else { + //tp_name return the full name + Shiboken::AutoDecRef otypeName(PyObject_GetAttrString(type, "__name__")); + typeName = strdup(PyString_AS_STRING(otypeName.object())); + } + if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ObjectType) { + typeName = reinterpret_cast(realloc(typeName, strlen(typeName) + 1)); + typeName = strcat(typeName, "*"); + } + return typeName; + } else if (PyString_Check(type)) { + return strdup(PyString_AS_STRING(type)); + } + return 0; +} + +bool qproperty_is_readble(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return (data->fget != 0); +} + +bool qproperty_is_writable(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return (data->fset != 0); +} + +bool qproperty_has_reset(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return (data->freset != 0); +} + +bool qproperty_is_designable(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->designable; +} + +bool qproperty_is_scriptable(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->scriptable; +} + +bool qproperty_is_stored(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->stored; +} + +bool qproperty_is_user(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->user; +} + +bool qproperty_is_constant(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->constant; +} + +bool qproperty_is_final(PyObject* self) +{ + QPropertyData *data = reinterpret_cast(self); + return data->final; +} + +} //namespace PySide diff --git a/libpyside/qproperty.h b/libpyside/qproperty.h new file mode 100644 index 0000000..7e0e1bc --- /dev/null +++ b/libpyside/qproperty.h @@ -0,0 +1,187 @@ +/* + * This file is part of the Shiboken Python Bindings Generator project. + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. Please + * review the following information to ensure the GNU Lesser General + * Public License version 2.1 requirements will be met: + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + * + * As a special exception to the GNU Lesser General Public License + * version 2.1, the object code form of a "work that uses the Library" + * may incorporate material from a header file that is part of the + * Library. You may distribute such object code under terms of your + * choice, provided that the incorporated material (i) does not exceed + * more than 5% of the total size of the Library; and (ii) is limited to + * numerical parameters, data structure layouts, accessors, macros, + * inline functions and templates. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef PYSIDE_PROPERTY_H +#define PYSIDE_PROPERTY_H + +#include +#include +#include + +namespace PySide +{ + +extern "C" +{ + PyAPI_DATA(PyTypeObject) QProperty_Type; +}; //extern "C" + +PYSIDE_API bool isQPropertyType(PyObject* pyObj); + +/** + * This function call set property function and pass value as arg + * This function does not check the property object type + * + * @param self The property object + * @param source The QObject witch has the property + * @param value The value to set in property + * @return Return 0 if ok or -1 if this function fail + **/ +PYSIDE_API int qproperty_set(PyObject* self, PyObject* source, PyObject* value); + +/** + * This function call get property function + * This function does not check the property object type + * + * @param self The property object + * @param source The QObject witch has the property + * @return Return the result of property get function or 0 if this fail + **/ +PYSIDE_API PyObject* qproperty_get(PyObject* self, PyObject* source); + +/** + * This function call reset property function + * This function does not check the property object type + * + * @param self The property object + * @param source The QObject witch has the property + * @return Return 0 if ok or -1 if this function fail + **/ +PYSIDE_API int qproperty_reset(PyObject* self, PyObject* source); + + +/** + * This function return the property type + * This function does not check the property object type + * + * @param self The property object + * @return Return the property type name + **/ +PYSIDE_API const char* qproperty_get_type(PyObject* self); + +/** + * This function search in the source object for desired property + * + * @param source The QObject object + * @param name The property name + * @return Return a new reference to property object + **/ +PYSIDE_API PyObject* qproperty_get_object(PyObject* source, PyObject* name); + + +/** + * This function check if property has read function + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_readble(PyObject* self); + +/** + * This function check if property has write function + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_writable(PyObject* self); + +/** + * This function check if property has reset function + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_has_reset(PyObject* self); + +/** + * This function check if property has the flag DESIGNABLE setted + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_designable(PyObject* self); + +/** + * This function check if property has the flag SCRIPTABLE setted + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_scriptable(PyObject* self); + +/** + * This function check if property has the flag STORED setted + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_stored(PyObject* self); + +/** + * This function check if property has the flag USER setted + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_user(PyObject* self); + +/** + * This function check if property has the flag CONSTANT setted + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_constant(PyObject* self); + +/** + * This function check if property has the flag FINAL setted + * This function does not check the property object type + * + * @param self The property object + * @return Return a boolean value + **/ +PYSIDE_API bool qproperty_is_final(PyObject* self); + + +} //namespace PySide + +#endif diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index b19c565..dff9cc1 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -229,10 +229,11 @@ PyObject* signal_instance_get_item(PyObject* self, PyObject* key) void signalUpdateSource(PyObject* source) { Shiboken::AutoDecRef attrs(PyObject_Dir(source)); + for(int i = 0, i_max = PyList_GET_SIZE(attrs.object()); i < i_max; i++) { PyObject *attrName = PyList_GET_ITEM(attrs.object(), i); - Shiboken::AutoDecRef attr(PyObject_GetAttr(source, attrName)); - if (attr->ob_type == &Signal_Type) { + Shiboken::AutoDecRef attr(PyObject_GetAttr((PyObject*)source->ob_type, attrName)); + if (!attr.isNull() && (attr->ob_type == &Signal_Type)) { Shiboken::AutoDecRef signalInstance(reinterpret_cast(PyObject_New(SignalInstanceData, &SignalInstance_Type))); signal_instance_initialize(signalInstance, attrName, reinterpret_cast(attr.object()), source, 0); PyObject_SetAttr(source, attrName, signalInstance); diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index f173400..de0de7d 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -33,6 +33,7 @@ */ #include "signalmanager.h" +#include "qproperty.h" #include #include @@ -351,14 +352,87 @@ bool SignalManager::emitSignal(QObject* source, const char* signal, PyObject* ar return false; } -int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args) +int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args) { const QMetaObject* metaObject = object->metaObject(); - // only meta method invocation is supported right now. + PyObject* pp = 0; + PyObject* pp_name = 0; + QMetaProperty mp; + Shiboken::TypeResolver* typeResolver = 0; + PyObject* pySelf = Shiboken::BindingManager::instance().retrieveWrapper(object); + if (call != QMetaObject::InvokeMetaMethod) { - qWarning("Only meta method invocation is supported right now by PySide."); - return id - metaObject->methodCount(); + mp = metaObject->property(id); + if (!mp.isValid()) + return id - metaObject->methodCount(); + + pp_name = PyString_FromString(mp.name()); + pp = qproperty_get_object(pySelf, pp_name); + if (!pp) { + qWarning("Invalid property."); + Py_XDECREF(pp_name); + return id - metaObject->methodCount(); + } + printf("access to property: %s-%s\n", mp.name(), mp.typeName()); + typeResolver = Shiboken::TypeResolver::get(mp.typeName()); } + + switch(call) { +#ifndef QT_NO_PROPERTIES + case QMetaObject::ReadProperty: + { + PyObject* value = qproperty_get(pp, pySelf); + if (value) { + void *data = typeResolver->toCpp(value); + if (Shiboken::TypeResolver::getType(mp.typeName()) == Shiboken::TypeResolver::ObjectType) + args[0] = &data; + else + args[0] = data; + + Py_DECREF(value); + } + break; + } + + case QMetaObject::WriteProperty: + { + Shiboken::AutoDecRef value(typeResolver->toPython(args[0])); + qproperty_set(pp, pySelf, value); + break; + } + + case QMetaObject::ResetProperty: + qproperty_reset(pp, pp_name); + break; + + case QMetaObject::QueryPropertyDesignable: + case QMetaObject::QueryPropertyScriptable: + case QMetaObject::QueryPropertyStored: + case QMetaObject::QueryPropertyEditable: + case QMetaObject::QueryPropertyUser: + break; +#endif + case QMetaObject::InvokeMetaMethod: + id = call_method(object, id, args); + break; + + default: + qWarning("Unsupported meta invocation type."); + } + + if (call == QMetaObject::InvokeMetaMethod) + id = id - metaObject->methodCount(); + else + id = id - metaObject->propertyCount(); + + Py_XDECREF(pp); + Py_XDECREF(pp_name); + return id; +} + +int SignalManager::call_method(QObject* object, int id, void** args) +{ + const QMetaObject* metaObject = object->metaObject(); QMetaMethod method = metaObject->method(id); if (method.methodType() == QMetaMethod::Signal) { @@ -403,6 +477,7 @@ int PySide::SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, bool SignalManager::registerMetaMethod(QObject* source, const char* signature, QMetaMethod::MethodType type) { + Q_ASSERT(source); const QMetaObject* metaObject = source->metaObject(); int methodIndex = metaObject->indexOfMethod(signature); // Create the dynamic signal is needed diff --git a/libpyside/signalmanager.h b/libpyside/signalmanager.h index 72acd1d..08160a5 100644 --- a/libpyside/signalmanager.h +++ b/libpyside/signalmanager.h @@ -94,6 +94,8 @@ private: // disable copy SignalManager(const SignalManager&); SignalManager operator=(const SignalManager&); + + static int call_method(QObject* object, int id, void** args); }; } diff --git a/tests/QtScript/CMakeLists.txt b/tests/QtScript/CMakeLists.txt index e496591..41fc2c4 100644 --- a/tests/QtScript/CMakeLists.txt +++ b/tests/QtScript/CMakeLists.txt @@ -1,2 +1,3 @@ PYSIDE_TEST(base_test.py) PYSIDE_TEST(engine_test.py) +PYSIDE_TEST(property_test.py) diff --git a/tests/QtScript/property_test.py b/tests/QtScript/property_test.py new file mode 100644 index 0000000..6d20416 --- /dev/null +++ b/tests/QtScript/property_test.py @@ -0,0 +1,62 @@ +import unittest + +from PySide.QtCore import QObject, QProperty, QCoreApplication +from PySide.QtScript import QScriptEngine + +class MyObject(QObject): + def __init__(self, parent = None): + QObject.__init__(self, parent) + self._p = 100 + + def setX(self, value): + self._p = value + + def getX(self): + return self._p + + def resetX(self): + self._p = 100 + + def delX(self): + self._p = 0 + + x = QProperty(int, getX, setX, resetX, delX) + + +class QPropertyTest(unittest.TestCase): + + def testSimple(self): + o = MyObject() + self.assertEqual(o.x, 100) + o.x = 42 + self.assertEqual(o.x, 42) + + def testHasProperty(self): + o = MyObject() + o.setProperty("x", 10) + self.assertEqual(o.x, 10) + self.assertEqual(o.property("x"), 10) + + def testMetaProperty(self): + o = MyObject() + m = o.metaObject() + found = False + for i in range(m.propertyCount()): + mp = m.property(i) + if mp.name() == "x": + found = True + break + self.assert_(found) + + def testScriptQProperty(self): + qapp = QCoreApplication([]) + myEngine = QScriptEngine() + obj = MyObject() + scriptObj = myEngine.newQObject(obj) + myEngine.globalObject().setProperty("obj", scriptObj) + myEngine.evaluate("obj.x = 42") + self.assertEqual(scriptObj.property("x").toInt32(), 42) + self.assertEqual(obj.property("x"), 42) + +if __name__ == '__main__': + unittest.main() From 7431ae12a45baffd2a365f9382ffaa8adeb66957 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 8 Jul 2010 10:49:50 -0300 Subject: [PATCH 0074/1129] Exported flags on enum in script typesystem. Reviewer: Hugo Parente Lima , Luciano Wolf --- PySide/QtScript/typesystem_script.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/QtScript/typesystem_script.xml b/PySide/QtScript/typesystem_script.xml index 81ba5b3..822b3d5 100644 --- a/PySide/QtScript/typesystem_script.xml +++ b/PySide/QtScript/typesystem_script.xml @@ -8,8 +8,8 @@ - - + + From f1bbc25546b688e8a0766212a24f2d1eacc826c7 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 8 Jul 2010 13:52:29 -0300 Subject: [PATCH 0075/1129] Created QProperty documentation. Reviewer: Hugo Parente Lima , Luciano Wolf --- doc/_templates/index.html | 11 ++++++---- doc/property.rst | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 doc/property.rst diff --git a/doc/_templates/index.html b/doc/_templates/index.html index bae2f7b..d0bc1a6 100644 --- a/doc/_templates/index.html +++ b/doc/_templates/index.html @@ -16,17 +16,20 @@
+ - - + + +
diff --git a/doc/property.rst b/doc/property.rst new file mode 100644 index 0000000..0b9b35c --- /dev/null +++ b/doc/property.rst @@ -0,0 +1,44 @@ +Use of QPropery in PySide +************************* + +PySide implements the function 'QProperty' which allows to declare properties compatible with QMetaProperties. + + +Using PySide.QProperty() +------------------------ + +The QProperty works like Q_PROPERTY macro, and uses the same arguments. + +QProperty(getFunction, [setFunction], [resetFunction], [Designable], [Scriptable], [Stored], [User]) + + +The example below uses QProperty function to export a property in QMetaObject data. + +:: + + ... + clas MyObject(QObject): + def getX(self): + ... + + def setX(self, value): + ... + + def resetX(self): + ... + + X = QProperty(getX, setX, resetX, True, True, True, True) + + ... + + +The exported property works like native python property on python side. See the example below. + +:: + + ... + o = MyObject() + o.X = 10 + print o.X + ... + From 4090ef81efcada5bd6f882e1c91cd3a699c9c034 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 9 Jul 2010 10:31:37 -0300 Subject: [PATCH 0076/1129] Restore missing function on QStandardItemModel. Created unit test. Fixes bug: #257. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 63 ++++++++++++++++++++++---- tests/QtGui/qstandarditemmodel_test.py | 41 ++++++++++++++++- 2 files changed, 92 insertions(+), 12 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 36493e3..7308f00 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3617,7 +3617,6 @@
- @@ -3703,15 +3702,59 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for(int r=0, r_max = %CPPSELF.rowCount(); r < r_max; r++) { + QList<QStandardItem *> ri = %CPPSELF.takeRow(0); + + PyObject *pyResult = %CONVERTTOPYTHON[QList<QStandardItem * >](ri); + Shiboken::setParent(Py_None, pyResult); + Py_XDECREF(pyResult); + } + + diff --git a/tests/QtGui/qstandarditemmodel_test.py b/tests/QtGui/qstandarditemmodel_test.py index d83d856..6ab86dd 100644 --- a/tests/QtGui/qstandarditemmodel_test.py +++ b/tests/QtGui/qstandarditemmodel_test.py @@ -1,7 +1,7 @@ import unittest +import sys -from PySide.QtGui import * -from PySide.QtCore import * +from PySide.QtGui import QStandardItemModel, QWidget, QStandardItem from helper import UsesQApplication @@ -21,6 +21,43 @@ class QStandardItemModelTest(UsesQApplication): # bug #227 self.model.insertRow(0) + +class QStandardItemModelRef(UsesQApplication): + def testRefCount(self): + model = QStandardItemModel(5, 5) + items = [] + for r in range(5): + row = [] + for c in range(5): + row.append(QStandardItem("%d,%d" % (r,c)) ) + self.assertEqual(sys.getrefcount(row[c]), 2) + + model.insertRow(r, row) + + for c in range(5): + ref_after = sys.getrefcount(row[c]) + # check if the ref count was incremented after insertRow + self.assertEqual(ref_after, 3) + + items.append(row) + row = None + + for r in range(3): + my_row = model.takeRow(0) + my_row = None + for c in range(5): + # only rest 1 reference + self.assertEqual(sys.getrefcount(items[r][c]), 2) + + my_i = model.item(0,0) + # ref(my_i) + parent_ref + items list ref + self.assertEqual(sys.getrefcount(my_i), 4) + + model.clear() + # ref(my_i) + self.assertEqual(sys.getrefcount(my_i), 3) + + if __name__ == '__main__': unittest.main() From e50766012453a22e1f4ee37a1112bd8b03b97124 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 9 Jul 2010 10:33:09 -0300 Subject: [PATCH 0077/1129] Fixed memory leak on state machine classes. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 5fe62ed..56c4f89 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2191,22 +2191,24 @@ - + - - - // The normal here would be to use the 'reference-count' tag but this - // method is strongly tied to 'setTargetState' since both affect the same - // internal value in QAbstractTransition. - Shiboken::keepReference(reinterpret_cast<SbkBaseWrapper*>(%PYSELF), "setTargetState(QAbstractState*)1", %PYARG_1); - + + + + + + + + + + + + - From 1a5de6c46c0a7e74cd9d8d6460a1f2f125a86339 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 8 Jul 2010 17:06:14 -0300 Subject: [PATCH 0078/1129] Add a default value and argument name to QUiLoader::file(str, QWidget) Reviewer: Luciano Wolf Marcelo Lira --- PySide/QtUiTools/typesystem_uitools.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PySide/QtUiTools/typesystem_uitools.xml b/PySide/QtUiTools/typesystem_uitools.xml index c155bff..664fbdf 100644 --- a/PySide/QtUiTools/typesystem_uitools.xml +++ b/PySide/QtUiTools/typesystem_uitools.xml @@ -36,6 +36,10 @@ + + + + From d351f6a015b7b1a7a6d89651f149d78ecd7f13d0 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Fri, 9 Jul 2010 15:22:53 -0300 Subject: [PATCH 0079/1129] Fix build on python2.5. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doing the merge request for Hugo as he went on vacation today :) Reviewer: Renato Araújo Luciano Wolf --- libpyside/signalmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index de0de7d..7482f01 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -105,7 +105,7 @@ struct Converter static PyObject* toPython(const PySide::PyObjectWrapper& obj) { - Py_INCREF(obj); + Py_INCREF((PyObject*)obj); return obj; } }; From 975edd5647f7fcebe9381ccf7d0524c736b1d069 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 9 Jul 2010 15:33:39 -0300 Subject: [PATCH 0080/1129] Fixed test ref count mistake. --- tests/QtCore/qabstracttransition_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/QtCore/qabstracttransition_test.py b/tests/QtCore/qabstracttransition_test.py index 4ba6d83..fa1e355 100644 --- a/tests/QtCore/qabstracttransition_test.py +++ b/tests/QtCore/qabstracttransition_test.py @@ -89,8 +89,8 @@ class QAbstractTransitionTest(unittest.TestCase): del states del transition - self.assertEqual(getrefcount(state1), refcount1) - self.assertEqual(getrefcount(state2), refcount2) + self.assertEqual(getrefcount(state1), refcount1 - 1) + self.assertEqual(getrefcount(state2), refcount2 - 1) def testRefCountOfTargetStatesAfterSingleTargetState(self): transition = QEventTransition() @@ -119,8 +119,8 @@ class QAbstractTransitionTest(unittest.TestCase): del states del transition - self.assertEqual(getrefcount(state1), refcount1) - self.assertEqual(getrefcount(state2), refcount2) + self.assertEqual(getrefcount(state1), refcount1 - 1) + self.assertEqual(getrefcount(state2), refcount2 - 1) def testRefCountOfTargetStatesBeforeSingleTargetState(self): transition = QEventTransition() @@ -147,8 +147,8 @@ class QAbstractTransitionTest(unittest.TestCase): del states - self.assertEqual(getrefcount(state1), refcount1) - self.assertEqual(getrefcount(state2), refcount2) + self.assertEqual(getrefcount(state1), refcount1 - 1) + self.assertEqual(getrefcount(state2), refcount2 - 1) if __name__ == '__main__': unittest.main() From 5cc46f2f1342e085897eefd06eda453e2f28b5bc Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 9 Jul 2010 18:27:39 -0300 Subject: [PATCH 0081/1129] Fixed layout reference control on layouts. Reviewer: Luciano Wolf --- PySide/QtGui/glue/qlayout_help_functions.h | 28 ++++++++++++++----- PySide/QtGui/glue/qwidget_glue.h | 10 +++++++ tests/QtGui/qlayout_ref_test.py | 2 +- tests/QtGui/qlayout_test.py | 31 +++++++++++++++++++--- 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h index cea0b56..9e07ff5 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.h @@ -3,24 +3,40 @@ void addLayoutOwnership(QLayout *layout, QLayoutItem *item); +inline QString retrieveObjectName(PyObject *obj) +{ + Shiboken::AutoDecRef objName(PyObject_Str(obj)); + return QString(PyString_AsString(objName)); +} + inline void addLayoutOwnership(QLayout *layout, QWidget *widget) { //transfer ownership to parent widget QWidget *parent = layout->parentWidget(); - if (!parent) - return; - Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); - Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(widget)); - Shiboken::setParent(pyParent, pyChild); + if (!parent) { + //keep the reference while the layout is orphan + Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); + Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(widget)); + Shiboken::keepReference(reinterpret_cast(pyParent.object()), qPrintable(retrieveObjectName(pyParent)), pyChild, true); + } else { + Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); + Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(widget)); + Shiboken::setParent(pyParent, pyChild); + } } inline void addLayoutOwnership(QLayout *layout, QLayout *other) { //transfer all children widgetes from other to layout parent widget QWidget *parent = layout->parentWidget(); - if (!parent) + if (!parent) { + //keep the reference while the layout is orphan + Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); + Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(other)); + Shiboken::keepReference(reinterpret_cast(pyParent.object()), qPrintable(retrieveObjectName(pyParent)), pyChild, true); return; + } for (int i=0, i_max=other->count(); i < i_max; i++) { addLayoutOwnership(layout, other->itemAt(i)); diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h index a6cd3b7..9488522 100644 --- a/PySide/QtGui/glue/qwidget_glue.h +++ b/PySide/QtGui/glue/qwidget_glue.h @@ -1,3 +1,10 @@ +static QString retrieveObjectName(PyObject *obj) +{ + Shiboken::AutoDecRef objName(PyObject_Str(obj)); + return QString(PyString_AsString(objName)); +} + + /** * Tranfer objects ownership from layout to widget **/ @@ -26,6 +33,9 @@ qwidgetReparentLayout(QWidget *parent, QLayout *layout) Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(layout)); Shiboken::setParent(pyParent, pyChild); + + //remove previous references + Shiboken::keepReference(reinterpret_cast(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None); } static inline void diff --git a/tests/QtGui/qlayout_ref_test.py b/tests/QtGui/qlayout_ref_test.py index a634271..27c599c 100644 --- a/tests/QtGui/qlayout_ref_test.py +++ b/tests/QtGui/qlayout_ref_test.py @@ -46,7 +46,7 @@ class SaveReference(UsesQApplication): l = QHBoxLayout() self.assertEqual(getrefcount(self.widget1), 2) l.addWidget(self.widget1) - self.assertEqual(getrefcount(self.widget1), 2) + self.assertEqual(getrefcount(self.widget1), 3) w = QWidget() w.setLayout(l) diff --git a/tests/QtGui/qlayout_test.py b/tests/QtGui/qlayout_test.py index ae773bb..88c37aa 100644 --- a/tests/QtGui/qlayout_test.py +++ b/tests/QtGui/qlayout_test.py @@ -2,7 +2,7 @@ import unittest import sys from helper import UsesQApplication -from PySide.QtGui import QLayout, QWidget, QPushButton, QWidgetItem +from PySide.QtGui import QLayout, QWidget, QPushButton, QWidgetItem, QHBoxLayout class MyLayout(QLayout): def __init__(self, parent=None): @@ -29,24 +29,47 @@ class MyLayout(QLayout): -#Test if a layout implemented in python, the QWidget.setLayout works -#fine because this implement som layout functions used in glue code of +#Test if a layout implemented in python, the QWidget.setLayout works +#fine because this implement som layout functions used in glue code of #QWidget, then in c++ when call a virtual function this need call the QLayout #function implemented in python class QLayoutTest(UsesQApplication): - def testOwnershipTransfer(self): b = QPushButton("teste") l = MyLayout() + l.addWidget(b) self.assertEqual(sys.getrefcount(b), 2) w = QWidget() + + #transfer ref w.setLayout(l) self.assertEqual(sys.getrefcount(b), 3) + + def testReferenceTransfer(self): + b = QPushButton("teste") + l = QHBoxLayout() + + # keep ref + l.addWidget(b) + self.assertEqual(sys.getrefcount(b), 3) + + w = QWidget() + + # transfer ref + w.setLayout(l) + + self.assertEqual(sys.getrefcount(b), 3) + + # release ref + del w + + self.assertEqual(sys.getrefcount(b), 2) + if __name__ == '__main__': unittest.main() From be1073e7728e31281a607313007e817d5e9db2af Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Fri, 9 Jul 2010 18:19:26 -0300 Subject: [PATCH 0082/1129] Fix warning on QString* parameter inside QtWebKit. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtWebKit/typesystem_webkit.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml index a08b183..845eeb4 100644 --- a/PySide/QtWebKit/typesystem_webkit.xml +++ b/PySide/QtWebKit/typesystem_webkit.xml @@ -51,9 +51,13 @@ + + + - %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4); - %PYARG_0 = Shiboken::makeTuple(retval_, %4); + QString str; + %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, &str); + %PYARG_0 = Shiboken::makeTuple(retval_, str); From bac154b896b39c1e817742ce2213da3e0d346977 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 12 Jul 2010 18:45:19 -0300 Subject: [PATCH 0083/1129] Create support to QVariantList and QVariantMap. Fixes bug: #263 Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/qvariant_conversions.h | 63 +++++++++++++++++++++++ PySide/QtCore/qvariant_type_conversions.h | 32 +++++++++++- PySide/QtCore/typesystem_core.xml | 2 + 3 files changed, 96 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index 613e523..9178aa8 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -40,6 +40,10 @@ struct Converter } else if (Shiboken::isShibokenEnum(pyObj)) { // QVariant(enum) return QVariant(Converter::toCpp(pyObj)); + } else if (PyDict_Check(pyObj)) { + return convertToVariantMap(pyObj); + } else if (PySequence_Check(pyObj)) { + return convertToVariantList(pyObj); } else if (!isShibokenType(pyObj) || isUserType(pyObj)) { // QVariant(User class) return QVariant::fromValue(pyObj); @@ -70,11 +74,70 @@ struct Converter static PyObject* toPython(const QVariant& cppObj) { if (cppObj.isValid()) { + if (qstrcmp(cppObj.typeName(), "QVariantList") == 0) + return Converter >::toPython(cppObj.value()); + + if (qstrcmp(cppObj.typeName(), "QStringList") == 0) + return Converter >::toPython(cppObj.value()); + + if (qstrcmp(cppObj.typeName(), "QVariantMap") == 0) + return Converter >::toPython(cppObj.value()); + Shiboken::TypeResolver* tr = Shiboken::TypeResolver::get(cppObj.typeName()); if (tr) return tr->toPython(const_cast(cppObj.data())); } Py_RETURN_NONE; } + + static QVariant convertToVariantMap(PyObject* map) + { + PyObject *key, *value; + Py_ssize_t pos = 0; + AutoDecRef keys(PyDict_Keys(map)); + bool keysIsString = isStringList(keys); + if (keysIsString) { + QMap ret; + while (PyDict_Next(map, &pos, &key, &value)) + ret.insert(Converter::toCpp(key), toCpp(value)); + return QVariant(ret); + } else { + return toCpp(map); + } + } + + static bool isStringList(PyObject *list) + { + bool allString = true; + AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i=0; i < size; i++) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + if (!Converter::checkType(item)) { + allString = false; + break; + } + } + return allString; + } + + static QVariant convertToVariantList(PyObject* list) + { + bool allString = isStringList(list); + if (allString) { + QStringList lst = Converter >::toCpp(list); + return QVariant(lst); + } else { + QList lst; + AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i=0; i < size; i++) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + lst.append(toCpp(item)); + } + return QVariant(lst); + } + Q_ASSERT(false); + } }; } diff --git a/PySide/QtCore/qvariant_type_conversions.h b/PySide/QtCore/qvariant_type_conversions.h index 107fb42..d1cf9f0 100644 --- a/PySide/QtCore/qvariant_type_conversions.h +++ b/PySide/QtCore/qvariant_type_conversions.h @@ -15,7 +15,7 @@ struct Converter static QVariant::Type toCpp(PyObject* pyObj) { - const char* typeName; + const char* typeName = 0; if (pyObj == Py_None) return QVariant::Invalid; @@ -31,6 +31,15 @@ struct Converter typeName = PyString_AS_STRING(pyObj); else if (PyUnicode_Check(pyObj)) typeName = PyString_AsString(pyObj); + else if (PyDict_Check(pyObj) && checkAllStringKeys(pyObj)) + typeName = "QVariantMap"; + else if (PySequence_Check(pyObj)) + if (isStringList(pyObj)) + typeName = "QStringList"; + else + typeName = "QVariantList"; + else + Q_ASSERT(false); return QVariant::nameToType(typeName); } @@ -49,5 +58,26 @@ struct Converter Py_INCREF(pyObj); return pyObj; } + + static bool isStringList(PyObject* list) + { + bool allString = true; + AutoDecRef fast(PySequence_Fast(list, "Failed to convert QVariantList")); + Py_ssize_t size = PySequence_Fast_GET_SIZE(fast.object()); + for(int i=0; i < size; i++) { + PyObject* item = PySequence_Fast_GET_ITEM(fast.object(), i); + if (!Converter::checkType(item)) { + allString = false; + break; + } + } + return allString; + } + + static bool checkAllStringKeys(PyObject* dict) + { + AutoDecRef keys(PyDict_Keys(dict)); + return isStringList(keys); + } }; } diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 56c4f89..133ece3 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -178,6 +178,8 @@ + + From e2056540d55033e8415246c2d17d9750bd30c1f0 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 13 Jul 2010 15:12:28 -0300 Subject: [PATCH 0084/1129] Uset 60 secs as default test timeout. Reviewer: Marcelo Lira Luciano Wolf --- tests/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c1a0376..adf4179 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,6 @@ -set(PYSIDE_TIMEOUT 10) +if(NOT CTEST_TESTING_TIMEOUT) + set(CTEST_TESTING_TIMEOUT 60) +endif() macro(TEST_QT_MODULE var name) if(NOT DISABLE_${name} AND ${var}) @@ -19,7 +21,7 @@ macro(PYSIDE_TEST) set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${libpyside_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") add_test(${TEST_NAME} ${TEST_CMD}) set_tests_properties(${TEST_NAME} PROPERTIES - TIMEOUT ${PYSIDE_TIMEOUT} + TIMEOUT ${CTEST_TESTING_TIMEOUT} WILL_FAIL ${EXPECT_TO_FAIL}) endmacro(PYSIDE_TEST) From 95c7699ae37c0c4a10d606405230000cfae99bde Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Tue, 13 Jul 2010 14:15:35 -0300 Subject: [PATCH 0085/1129] Update tests to check native pointers (qchar *, void *, ...). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- tests/QtCore/qobject_connect_notify_test.py | 3 +++ tests/QtXml/qxmlsimplereader_test.py | 1 + 2 files changed, 4 insertions(+) diff --git a/tests/QtCore/qobject_connect_notify_test.py b/tests/QtCore/qobject_connect_notify_test.py index 4410375..b87dd4d 100644 --- a/tests/QtCore/qobject_connect_notify_test.py +++ b/tests/QtCore/qobject_connect_notify_test.py @@ -14,9 +14,11 @@ class Obj(QObject): QObject.__init__(self) self.con_notified = False self.dis_notified = False + self.signal = "" def connectNotify(self, signal): self.con_notified = True + self.signal = signal def disconnectNotify(self, signal): self.dis_notified = True @@ -39,6 +41,7 @@ class TestQObjectConnectNotify(UsesQCoreApplication): receiver = QObject() sender.connect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) self.assert_(sender.con_notified) + self.assertEqual(sender.signal, SIGNAL("destroyed()")) sender.disconnect(SIGNAL("destroyed()"), receiver, SLOT("deleteLater()")) self.assert_(sender.dis_notified) diff --git a/tests/QtXml/qxmlsimplereader_test.py b/tests/QtXml/qxmlsimplereader_test.py index 6c4d3f4..aaaf45a 100644 --- a/tests/QtXml/qxmlsimplereader_test.py +++ b/tests/QtXml/qxmlsimplereader_test.py @@ -28,6 +28,7 @@ class QXmlSimpleReaderTest(unittest.TestCase): reader = QXmlSimpleReader() prop, ok = reader.property('foo') self.assertEqual((prop, ok), (None, False)) + reader.setProperty('foo', 'Something') if __name__ == '__main__': unittest.main() From 28d0c480b15d566cabfb63dc6cc65697dc5b5edc Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 13 Jul 2010 17:53:59 -0300 Subject: [PATCH 0086/1129] Create unit test to bug 243. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_243.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/QtGui/bug_243.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index b875913..5ebd754 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -1,6 +1,7 @@ #Keep this in alphabetical sort PYSIDE_TEST(api2_test.py) +PYSIDE_TEST(bug_243.py) PYSIDE_TEST(add_action_test.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_243.py b/tests/QtGui/bug_243.py new file mode 100644 index 0000000..eb9f9d6 --- /dev/null +++ b/tests/QtGui/bug_243.py @@ -0,0 +1,18 @@ + +''' Test bug 243: http://bugs.openbossa.org/show_bug.cgi?id=243''' + +import unittest +import sys + +from PySide.QtGui import QApplication, QMainWindow, QLayout + +class QAppPresence(unittest.TestCase): + + def testBug(self): + app = QApplication(sys.argv) + window = QMainWindow() + l = window.layout() + self.assert_(isinstance(l, QLayout)) + +if __name__ == '__main__': + unittest.main() From c62c36a64dd4c0fc0cd586c5c2b3d4f97ba3f769 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Wed, 14 Jul 2010 18:38:13 -0300 Subject: [PATCH 0087/1129] Fix CMakeLists to include QtMultimedia tests + fix audio test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- tests/CMakeLists.txt | 12 ++++++++++++ tests/QtMultimedia/audio_test.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index adf4179..904d106 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,6 +25,18 @@ macro(PYSIDE_TEST) WILL_FAIL ${EXPECT_TO_FAIL}) endmacro(PYSIDE_TEST) +# Try to find QtMultimedia +# TODO: Remove this hack when cmake support QtMultimedia module +if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) + find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia + PATHS ${QT_HEADERS_DIR}/QtMultimedia + ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers + NO_DEFAULT_PATH) + find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY) + set(QT_QTMULTIMEDIA_FOUND ON) + endif() +endif () add_subdirectory(signals) TEST_QT_MODULE(QT_QTCORE_FOUND QtCore) diff --git a/tests/QtMultimedia/audio_test.py b/tests/QtMultimedia/audio_test.py index 04d0a1e..0d8813d 100644 --- a/tests/QtMultimedia/audio_test.py +++ b/tests/QtMultimedia/audio_test.py @@ -10,6 +10,8 @@ class testAudioDevices(unittest.TestCase): def testListDevices(self): for devInfo in QAudioDeviceInfo.availableDevices(QAudio.AudioOutput): + if devInfo.deviceName() == 'null': + continue fmt = QAudioFormat() for codec in devInfo.supportedCodecs(): fmt.setCodec(codec) From cb7d3e95a27392e504f3b99deacddb3a3e0a8a56 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Mon, 19 Jul 2010 16:30:11 -0300 Subject: [PATCH 0088/1129] Fix bug#252. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtGui/glue/qapplication_init.cpp | 2 +- tests/QtSql/qsqldatabaseandqueries_test.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp index 5c87af3..00e37b1 100644 --- a/PySide/QtGui/glue/qapplication_init.cpp +++ b/PySide/QtGui/glue/qapplication_init.cpp @@ -8,7 +8,7 @@ void DeleteQApplicationAtExit() { if (QApplication::instance()) { //disconnect and decref all widgets used on signals before destroy qApp PySide::SignalManager::instance().clear(); - delete QApplication::instance(); + QApplication::instance()->deleteLater(); for (int i = 0; i < QApplicationArgCount; ++i) delete[] QApplicationArgValues[i]; } diff --git a/tests/QtSql/qsqldatabaseandqueries_test.py b/tests/QtSql/qsqldatabaseandqueries_test.py index 7a9d30a..41daccc 100644 --- a/tests/QtSql/qsqldatabaseandqueries_test.py +++ b/tests/QtSql/qsqldatabaseandqueries_test.py @@ -6,6 +6,12 @@ import unittest from PySide import QtSql from PySide.QtCore import * +from PySide.QtGui import * + +class Foo(QWidget): + def __init__(self): + QWidget.__init__(self) + self.model = QtSql.QSqlTableModel() class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase): '''Test cases for QtSql database creation, destruction and queries''' @@ -51,6 +57,14 @@ class SqlDatabaseCreationDestructionAndQueries(unittest.TestCase): lastname = query.value(0) self.assertEqual(lastname, 'Harrison') + def testTableModelDeletion(self): + app = QApplication([]) + + bar = Foo() + model = bar.model + del bar + del app + if __name__ == '__main__': unittest.main() From e5042dc193bbcb4b1566594d832076adfef5fd94 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 21 Jul 2010 17:10:48 -0300 Subject: [PATCH 0089/1129] Added a custom cmake file to help finding Python debug provisions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Luciano Wolf Reviewed by Renato Araújo --- CMakeLists.txt | 5 ++++- cmake/Modules/FindPythonInterpWithDebug.cmake | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 cmake/Modules/FindPythonInterpWithDebug.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 61a6116..d601f84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ project(pysidebindings) cmake_minimum_required(VERSION 2.6) +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/ + ${CMAKE_MODULE_PATH}) + if(CMAKE_HOST_UNIX) option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") @@ -34,7 +37,7 @@ if(AVOID_PROTECTED_HACK OR WIN32) endif() find_package(PythonLibs REQUIRED) -find_package(PythonInterp REQUIRED) +find_package(PythonInterpWithDebug REQUIRED) find_package(Shiboken 0.3.3 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) diff --git a/cmake/Modules/FindPythonInterpWithDebug.cmake b/cmake/Modules/FindPythonInterpWithDebug.cmake new file mode 100644 index 0000000..264dd5d --- /dev/null +++ b/cmake/Modules/FindPythonInterpWithDebug.cmake @@ -0,0 +1,21 @@ +INCLUDE(FindPythonInterp) + +find_package(PythonInterp REQUIRED) + +#Fix missing variable on UNIX env +if(NOT PYTHON_DEBUG_LIBRARIES AND UNIX) + set(PYTHON_DEBUG_LIBRARIES "${PYTHON_LIBRARIES}") +endif() + +if(PYTHONINTERP_FOUND AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug") + # This is for Debian + set(PYTHON_EXECUTABLE_TMP "${PYTHON_EXECUTABLE}-dbg") + + # Fall back to the standard interpreter. + if(NOT EXISTS "${PYTHON_EXECUTABLE_TMP}") + set(PYTHON_EXECUTABLE_TMP "${PYTHON_EXECUTABLE}") + endif() + + set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE_TMP}") +endif() + From f7afa613cf4b4a7a587d29855465e1db577fcd06 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 15 Jul 2010 18:33:41 -0300 Subject: [PATCH 0090/1129] Update modules to work without protect hack. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 3 +++ PySide/QtOpenGL/typesystem_opengl.xml | 1 + PySide/typesystem_templates.xml | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 133ece3..8f30143 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1222,6 +1222,9 @@ + + <para>URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL "http://bühler.example.com" would be sent to the server as "http://xn--bhler-kva.example.com/List%20of%20applicants.xml".</para> + diff --git a/PySide/QtOpenGL/typesystem_opengl.xml b/PySide/QtOpenGL/typesystem_opengl.xml index 202b115..e1402f7 100644 --- a/PySide/QtOpenGL/typesystem_opengl.xml +++ b/PySide/QtOpenGL/typesystem_opengl.xml @@ -4,6 +4,7 @@ + diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 40e2345..1de06a1 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -154,7 +154,7 @@ From 8bde4b3800ca1c5c517fe382f6fdf78c212b9ad0 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 19 Jul 2010 15:19:45 -0300 Subject: [PATCH 0091/1129] Use correct python lib in debug mode. Reviewer: Marcelo Lira Luciano Wolf --- CMakeLists.txt | 18 +++++++++++++++++- PySide/QtCore/CMakeLists.txt | 2 +- PySide/QtDeclarative/CMakeLists.txt | 2 +- PySide/QtGui/CMakeLists.txt | 2 +- PySide/QtHelp/CMakeLists.txt | 2 +- PySide/QtMaemo5/CMakeLists.txt | 2 +- PySide/QtMultimedia/CMakeLists.txt | 2 +- PySide/QtNetwork/CMakeLists.txt | 2 +- PySide/QtOpenGL/CMakeLists.txt | 2 +- PySide/QtScript/CMakeLists.txt | 2 +- PySide/QtScriptTools/CMakeLists.txt | 2 +- PySide/QtSql/CMakeLists.txt | 2 +- PySide/QtSvg/CMakeLists.txt | 2 +- PySide/QtTest/CMakeLists.txt | 2 +- PySide/QtUiTools/CMakeLists.txt | 2 +- PySide/QtWebKit/CMakeLists.txt | 2 +- PySide/QtXml/CMakeLists.txt | 2 +- PySide/QtXmlPatterns/CMakeLists.txt | 2 +- PySide/phonon/CMakeLists.txt | 2 +- libpyside/CMakeLists.txt | 2 +- 20 files changed, 36 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d601f84..e797457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,11 @@ find_package(PythonInterpWithDebug REQUIRED) find_package(Shiboken 0.3.3 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) +#Fix missing variable on UNIX env +if(NOT PYTHON_DEBUG_LIBRARIES AND UNIX) + set(PYTHON_DEBUG_LIBRARIES "${PYTHON_LIBRARIES}") +endif() + set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "0") set(BINDING_API_MINOR_VERSION "3") @@ -135,10 +140,21 @@ execute_process( print sysconfig.get_config_var('Py_DEBUG')" OUTPUT_VARIABLE PY_DEBUG OUTPUT_STRIP_TRAILING_WHITESPACE) -if (PY_DEBUG) + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + if(NOT PYTHON_DEBUG_LIBRARIES) + message(FATAL_ERROR "Python debug library not found. Try compile PySide with -DCMAKE_BUILD_TYPE=Release") + endif() + if(NOT PY_DEBUG) + message(WARNING "Compiling PySide with debug enabled, but the python executable was not compiled with debug support.") + endif() add_definitions("-DPy_DEBUG") + set(PYSIDE_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES}) +else() + set(PYSIDE_PYTHON_LIBRARIES ${PYTHON_LIBRARIES}) endif() + set(GENERATOR_EXTRA_FLAGS --generatorSet=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic) enable_testing() diff --git a/PySide/QtCore/CMakeLists.txt b/PySide/QtCore/CMakeLists.txt index 408451f..6300a4c 100644 --- a/PySide/QtCore/CMakeLists.txt +++ b/PySide/QtCore/CMakeLists.txt @@ -147,7 +147,7 @@ add_library(QtCore MODULE ${QtCore_SRC}) set_property(TARGET QtCore PROPERTY PREFIX "") target_link_libraries(QtCore pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTCORE_LIBRARY} ) diff --git a/PySide/QtDeclarative/CMakeLists.txt b/PySide/QtDeclarative/CMakeLists.txt index d61fbf9..79b4b42 100644 --- a/PySide/QtDeclarative/CMakeLists.txt +++ b/PySide/QtDeclarative/CMakeLists.txt @@ -38,7 +38,7 @@ add_library(QtDeclarative MODULE ${QtDeclarative_SRC}) set_target_properties(QtDeclarative PROPERTIES PREFIX "") target_link_libraries(QtDeclarative pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index db0fd9e..fdc36b3 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -484,7 +484,7 @@ add_library(QtGui MODULE ${QtGui_SRC}) set_property(TARGET QtGui PROPERTY PREFIX "") target_link_libraries(QtGui pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTGUI_LIBRARY} ) diff --git a/PySide/QtHelp/CMakeLists.txt b/PySide/QtHelp/CMakeLists.txt index 0cc48db..42b0737 100644 --- a/PySide/QtHelp/CMakeLists.txt +++ b/PySide/QtHelp/CMakeLists.txt @@ -33,7 +33,7 @@ set_target_properties(QtHelp PROPERTIES PREFIX "") target_link_libraries(QtHelp pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTHELP_LIBRARY}) diff --git a/PySide/QtMaemo5/CMakeLists.txt b/PySide/QtMaemo5/CMakeLists.txt index 4590e40..5338b80 100644 --- a/PySide/QtMaemo5/CMakeLists.txt +++ b/PySide/QtMaemo5/CMakeLists.txt @@ -41,7 +41,7 @@ set_target_properties(QtMaemo5 PROPERTIES target_link_libraries(QtMaemo5 pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTMAEMO5_LIBRARY}) diff --git a/PySide/QtMultimedia/CMakeLists.txt b/PySide/QtMultimedia/CMakeLists.txt index 05f63b5..20707f7 100644 --- a/PySide/QtMultimedia/CMakeLists.txt +++ b/PySide/QtMultimedia/CMakeLists.txt @@ -37,7 +37,7 @@ add_library(QtMultimedia MODULE ${QtMultimedia_SRC}) set_property(TARGET QtMultimedia PROPERTY PREFIX "") target_link_libraries(QtMultimedia pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTMULTIMEDIA_LIBRARY} ${QT_QTGUI_LIBRARY} diff --git a/PySide/QtNetwork/CMakeLists.txt b/PySide/QtNetwork/CMakeLists.txt index 7c8d17e..6afedbd 100644 --- a/PySide/QtNetwork/CMakeLists.txt +++ b/PySide/QtNetwork/CMakeLists.txt @@ -114,7 +114,7 @@ add_library(QtNetwork MODULE ${QtNetwork_SRC}) set_property(TARGET QtNetwork PROPERTY PREFIX "") target_link_libraries(QtNetwork pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTNETWORK_LIBRARY} ) diff --git a/PySide/QtOpenGL/CMakeLists.txt b/PySide/QtOpenGL/CMakeLists.txt index 5849c9a..158f4be 100644 --- a/PySide/QtOpenGL/CMakeLists.txt +++ b/PySide/QtOpenGL/CMakeLists.txt @@ -48,7 +48,7 @@ add_library(QtOpenGL MODULE ${QtOpenGL_SRC}) set_target_properties(QtOpenGL PROPERTIES PREFIX "") target_link_libraries(QtOpenGL pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY}) diff --git a/PySide/QtScript/CMakeLists.txt b/PySide/QtScript/CMakeLists.txt index 8b63447..af6ffd4 100644 --- a/PySide/QtScript/CMakeLists.txt +++ b/PySide/QtScript/CMakeLists.txt @@ -40,7 +40,7 @@ add_library(QtScript MODULE ${QtScript_SRC}) set_property(TARGET QtScript PROPERTY PREFIX "") target_link_libraries(QtScript pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTCORE_LIBRARY} ${QT_QTSCRIPT_LIBRARY} diff --git a/PySide/QtScriptTools/CMakeLists.txt b/PySide/QtScriptTools/CMakeLists.txt index d937d66..22860b1 100644 --- a/PySide/QtScriptTools/CMakeLists.txt +++ b/PySide/QtScriptTools/CMakeLists.txt @@ -24,7 +24,7 @@ add_library(QtScriptTools MODULE ${QtScriptTools_SRC}) set_target_properties(QtScriptTools PROPERTIES PREFIX "") target_link_libraries(QtScriptTools pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_GUI_LIBRARY} ${QT_QTSCRIPT_LIBRARY} diff --git a/PySide/QtSql/CMakeLists.txt b/PySide/QtSql/CMakeLists.txt index 1cbe713..1c45ac0 100644 --- a/PySide/QtSql/CMakeLists.txt +++ b/PySide/QtSql/CMakeLists.txt @@ -37,7 +37,7 @@ add_library(QtSql MODULE ${QtSql_SRC}) set_target_properties(QtSql PROPERTIES PREFIX "") target_link_libraries(QtSql pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTSQL_LIBRARY}) diff --git a/PySide/QtSvg/CMakeLists.txt b/PySide/QtSvg/CMakeLists.txt index 631131a..33cdba5 100644 --- a/PySide/QtSvg/CMakeLists.txt +++ b/PySide/QtSvg/CMakeLists.txt @@ -49,7 +49,7 @@ add_library(QtSvg MODULE ${QtSvg_SRC}) set_property(TARGET QtSvg PROPERTY PREFIX "") target_link_libraries(QtSvg pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTSVG_LIBRARY} ${QT_QTGUI_LIBRARY} diff --git a/PySide/QtTest/CMakeLists.txt b/PySide/QtTest/CMakeLists.txt index b447f79..3ac608f 100644 --- a/PySide/QtTest/CMakeLists.txt +++ b/PySide/QtTest/CMakeLists.txt @@ -37,7 +37,7 @@ add_library(QtTest MODULE ${QtTest_SRC}) set_property(TARGET QtTest PROPERTY PREFIX "") target_link_libraries(QtTest pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} diff --git a/PySide/QtUiTools/CMakeLists.txt b/PySide/QtUiTools/CMakeLists.txt index 5809c3f..320fc1a 100644 --- a/PySide/QtUiTools/CMakeLists.txt +++ b/PySide/QtUiTools/CMakeLists.txt @@ -24,7 +24,7 @@ add_library(QtUiTools MODULE ${QtUiTools_SRC}) set_target_properties(QtUiTools PROPERTIES PREFIX "") target_link_libraries(QtUiTools pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTUITOOLS_LIBRARY}) diff --git a/PySide/QtWebKit/CMakeLists.txt b/PySide/QtWebKit/CMakeLists.txt index 7bdf6e0..464bc28 100644 --- a/PySide/QtWebKit/CMakeLists.txt +++ b/PySide/QtWebKit/CMakeLists.txt @@ -65,7 +65,7 @@ add_library(QtWebKit MODULE ${QtWebKit_SRC}) set_property(TARGET QtWebKit PROPERTY PREFIX "") target_link_libraries(QtWebKit pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${QT_QTNETWORK_LIBRARY} diff --git a/PySide/QtXml/CMakeLists.txt b/PySide/QtXml/CMakeLists.txt index e6b4e80..fc7b0d0 100644 --- a/PySide/QtXml/CMakeLists.txt +++ b/PySide/QtXml/CMakeLists.txt @@ -52,7 +52,7 @@ add_library(QtXml MODULE ${QtXml_SRC}) set_property(TARGET QtXml PROPERTY PREFIX "") target_link_libraries(QtXml pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTXML_LIBRARY} ) diff --git a/PySide/QtXmlPatterns/CMakeLists.txt b/PySide/QtXmlPatterns/CMakeLists.txt index df67372..825011f 100644 --- a/PySide/QtXmlPatterns/CMakeLists.txt +++ b/PySide/QtXmlPatterns/CMakeLists.txt @@ -41,7 +41,7 @@ add_library(QtXmlPatterns MODULE ${QtXmlPatterns_SRC}) set_target_properties(QtXmlPatterns PROPERTIES PREFIX "") target_link_libraries(QtXmlPatterns pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTXMLPATTERNS_LIBRARY}) add_dependencies(QtXmlPatterns QtCore) diff --git a/PySide/phonon/CMakeLists.txt b/PySide/phonon/CMakeLists.txt index 1b2f05f..b46304a 100644 --- a/PySide/phonon/CMakeLists.txt +++ b/PySide/phonon/CMakeLists.txt @@ -60,7 +60,7 @@ add_library(phonon MODULE ${phonon_SRC}) set_target_properties(phonon PROPERTIES PREFIX "") target_link_libraries(phonon pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_PHONON_LIBRARY}) diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index 57ecb80..9590a32 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -17,7 +17,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} add_library(pyside SHARED ${libpyside_SRC}) target_link_libraries(pyside - ${PYTHON_LIBRARIES} + ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${QT_QTCORE_LIBRARY}) From 3267accc9f8c96371302531fdb8d1c24271cfd44 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 23 Jul 2010 11:45:30 -0300 Subject: [PATCH 0092/1129] Fixed uninitialized value. --- libpyside/dynamicqmetaobject.cpp | 4 ++++ libpyside/dynamicqmetaobject.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp index 8f97b56..0e545fa 100644 --- a/libpyside/dynamicqmetaobject.cpp +++ b/libpyside/dynamicqmetaobject.cpp @@ -215,6 +215,10 @@ bool MethodData::isValid() const return m_signature->size(); } +PropertyData::PropertyData() + : m_data(0) +{ +} PropertyData::PropertyData(const char* name, PyObject* data) : m_name(name), m_data(data) diff --git a/libpyside/dynamicqmetaobject.h b/libpyside/dynamicqmetaobject.h index 23a69c9..f8c120b 100644 --- a/libpyside/dynamicqmetaobject.h +++ b/libpyside/dynamicqmetaobject.h @@ -69,7 +69,7 @@ private: class PropertyData { public: - PropertyData(){} + PropertyData(); PropertyData(const char*name, PyObject *data); QByteArray name() const; QByteArray type() const; From 078408b8c25d73b900955b87e92dc50e9b19eb33 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 23 Jul 2010 13:48:47 -0300 Subject: [PATCH 0093/1129] Avoid running x11 specific tests on others OS. --- tests/QtCore/CMakeLists.txt | 5 ++++- tests/QtGui/CMakeLists.txt | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index b5f59d4..518ff9d 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -21,7 +21,6 @@ PYSIDE_TEST(qevent_test.py) PYSIDE_TEST(qfileinfo_test.py) PYSIDE_TEST(qfile_test.py) PYSIDE_TEST(qflags_test.py) -PYSIDE_TEST(qhandle_test.py) PYSIDE_TEST(qinstallmsghandler_test.py) PYSIDE_TEST(qlinef_test.py) PYSIDE_TEST(qlocale_test.py) @@ -62,3 +61,7 @@ PYSIDE_TEST(thread_signals_test.py) PYSIDE_TEST(translation_test.py) PYSIDE_TEST(unaryoperator_test.py) PYSIDE_TEST(unicode_test.py) + +if(X11) + PYSIDE_TEST(qhandle_test.py) +endif() diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 5ebd754..077dd1a 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -62,4 +62,8 @@ PYSIDE_TEST(timed_app_test.py) PYSIDE_TEST(virtual_protected_inheritance_test.py) PYSIDE_TEST(virtual_pure_override_test.py) PYSIDE_TEST(wrong_return_test.py) -PYSIDE_TEST(x11_symbols_test.py) + + +if(X11) + PYSIDE_TEST(x11_symbols_test.py) +endif() From e42133e8e715600a948831eb9c29a5437a5f4fa1 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Fri, 23 Jul 2010 11:10:57 -0300 Subject: [PATCH 0094/1129] Fix elasticnodes segfault. --- PySide/QtCore/qvariant_conversions.h | 1 + 1 file changed, 1 insertion(+) diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index 9178aa8..7a799e1 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -57,6 +57,7 @@ struct Converter QString stypeName(typeName); stypeName += '*'; typeCode = QMetaType::type(stypeName.toAscii()); + return QVariant(typeCode, reinterpret_cast(pyObj)->cptr); } if (typeCode) return QVariant(typeCode, reinterpret_cast(pyObj)->cptr[0]); From 505ba23a9d63e7c6d014f3c5bd5b1cdf778aac56 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Tue, 27 Jul 2010 10:01:33 -0300 Subject: [PATCH 0095/1129] Fixed glue code for QApplication and QCoreApplication. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code for QApplication deletion should also invalidate the wrapper for it. Also the similar code for QCoreApplication must perform the same steps as QApplication. Reviewed by Luciano Wolf Reviewed by Renato Araújo --- PySide/QtCore/glue/qcoreapplication_init.cpp | 4 +++- PySide/QtGui/glue/qapplication_init.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/glue/qcoreapplication_init.cpp b/PySide/QtCore/glue/qcoreapplication_init.cpp index f53db03..d9bc4cf 100644 --- a/PySide/QtCore/glue/qcoreapplication_init.cpp +++ b/PySide/QtCore/glue/qcoreapplication_init.cpp @@ -7,7 +7,9 @@ static char** QCoreApplicationArgValues; */ void DeleteQCoreApplicationAtExit() { if (QCoreApplication::instance()) { - delete QCoreApplication::instance(); + PySide::SignalManager::instance().clear(); + BindingManager::instance().invalidateWrapper(QCoreApplication::instance()); + QCoreApplication::instance()->deleteLater(); for (int i = 0; i < QCoreApplicationArgCount; ++i) delete[] QCoreApplicationArgValues[i]; } diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp index 00e37b1..9911a11 100644 --- a/PySide/QtGui/glue/qapplication_init.cpp +++ b/PySide/QtGui/glue/qapplication_init.cpp @@ -8,6 +8,7 @@ void DeleteQApplicationAtExit() { if (QApplication::instance()) { //disconnect and decref all widgets used on signals before destroy qApp PySide::SignalManager::instance().clear(); + BindingManager::instance().invalidateWrapper(QApplication::instance()); QApplication::instance()->deleteLater(); for (int i = 0; i < QApplicationArgCount; ++i) delete[] QApplicationArgValues[i]; From 4f51600e20b25f05eb9730c131ca3cd51eaa1774 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 28 Jul 2010 17:50:11 -0300 Subject: [PATCH 0096/1129] Created unit test to test shiboken objects destructor. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/qobject_destructor.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/QtCore/qobject_destructor.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 518ff9d..b8f7390 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -28,6 +28,7 @@ PYSIDE_TEST(qmetaobject_test.py) PYSIDE_TEST(qmodelindex_internalpointer_test.py) PYSIDE_TEST(qobject_children_segfault_test.py) PYSIDE_TEST(qobject_connect_notify_test.py) +PYSIDE_TEST(qobject_destructor.py) PYSIDE_TEST(qobject_event_filter_test.py) PYSIDE_TEST(qobject_inherits_test.py) PYSIDE_TEST(qobject_parent_test.py) diff --git a/tests/QtCore/qobject_destructor.py b/tests/QtCore/qobject_destructor.py new file mode 100644 index 0000000..036bf1d --- /dev/null +++ b/tests/QtCore/qobject_destructor.py @@ -0,0 +1,19 @@ +import sys +import unittest +from PySide import QtCore + +class MyObject(QtCore.QObject): + def __init__(self, other=None): + QtCore.QObject.__init__(self, None) + self._o = other + +class TestDestructor(unittest.TestCase): + def testReference(self): + o = QtCore.QObject() + m = MyObject(o) + self.assertEqual(sys.getrefcount(o), 3) + del m + self.assertEqual(sys.getrefcount(o), 2) + +if __name__ == '__main__': + unittest.main() From f4668398e2c536f4ff191991af4fd992b044d196 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 29 Jul 2010 13:52:32 -0300 Subject: [PATCH 0097/1129] Call signalmanager clear during QtCore exit function instead of QtCoreApplication destrcutor, to avoid memory leaks. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/glue/qcoreapplication_init.cpp | 1 - PySide/QtCore/typesystem_core.xml | 6 ++++++ PySide/QtGui/glue/qapplication_init.cpp | 2 -- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PySide/QtCore/glue/qcoreapplication_init.cpp b/PySide/QtCore/glue/qcoreapplication_init.cpp index d9bc4cf..5fcd79a 100644 --- a/PySide/QtCore/glue/qcoreapplication_init.cpp +++ b/PySide/QtCore/glue/qcoreapplication_init.cpp @@ -7,7 +7,6 @@ static char** QCoreApplicationArgValues; */ void DeleteQCoreApplicationAtExit() { if (QCoreApplication::instance()) { - PySide::SignalManager::instance().clear(); BindingManager::instance().invalidateWrapper(QCoreApplication::instance()); QCoreApplication::instance()->deleteLater(); for (int i = 0; i < QCoreApplicationArgCount; ++i) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 8f30143..db038e2 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -648,12 +648,14 @@ + Shiboken::TypeResolver::createValueTypeResolver<QString>("unicode"); Shiboken::TypeResolver::createValueTypeResolver<QString>("str"); PySide::init(module); + Py_AtExit(QtCoreModuleExit); #include <pyside.h> @@ -669,6 +671,10 @@ Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg)); Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); } + void QtCoreModuleExit() + { + PySide::SignalManager::instance().clear(); + } diff --git a/PySide/QtGui/glue/qapplication_init.cpp b/PySide/QtGui/glue/qapplication_init.cpp index 9911a11..da9e2dc 100644 --- a/PySide/QtGui/glue/qapplication_init.cpp +++ b/PySide/QtGui/glue/qapplication_init.cpp @@ -6,8 +6,6 @@ static char** QApplicationArgValues; void DeleteQApplicationAtExit() { if (QApplication::instance()) { - //disconnect and decref all widgets used on signals before destroy qApp - PySide::SignalManager::instance().clear(); BindingManager::instance().invalidateWrapper(QApplication::instance()); QApplication::instance()->deleteLater(); for (int i = 0; i < QApplicationArgCount; ++i) From 1fe7baf787381775e845923872d78096153ab5e3 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 29 Jul 2010 13:53:47 -0300 Subject: [PATCH 0098/1129] Emit connectNotify with real signal name. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/glue/qobject_connect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp index 535dd10..8578bff 100644 --- a/PySide/QtCore/glue/qobject_connect.cpp +++ b/PySide/QtCore/glue/qobject_connect.cpp @@ -76,11 +76,11 @@ static bool qobjectConnectCallback(QObject* source, const char* signal, PyObject } if (QMetaObject::connect(source, signalIndex, receiver, slotIndex, type)) { #ifndef AVOID_PROTECTED_HACK - source->connectNotify(signal); + source->connectNotify(signal - 1); #else // Need to cast to QObjectWrapper* and call the public version of // connectNotify when avoiding the protected hack. - reinterpret_cast(source)->connectNotify(signal); + reinterpret_cast(source)->connectNotify(signal - 1); #endif if (usingGlobalReceiver) signalManager.globalReceiverConnectNotify(source, slotIndex); From 6a2df2daa4e1efc5b7e6e5946c96a528ec9b7248 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 29 Jul 2010 15:02:48 -0300 Subject: [PATCH 0099/1129] Added test case for signal signature received by QObject::connectNotify(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Luciano Wolf Reviewed by Renato Araújo --- tests/signals/CMakeLists.txt | 3 +- tests/signals/signal_signature_test.py | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/signals/signal_signature_test.py diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index e09be0e..eda247d 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -3,6 +3,7 @@ PYSIDE_TEST(decorators_test.py) PYSIDE_TEST(invalid_callback_test.py) PYSIDE_TEST(lambda_gui_test.py) PYSIDE_TEST(lambda_test.py) +PYSIDE_TEST(list_signal_test.py) PYSIDE_TEST(multiple_connections_gui_test.py) PYSIDE_TEST(multiple_connections_test.py) PYSIDE_TEST(pysignal_test.py) @@ -26,8 +27,8 @@ PYSIDE_TEST(signal_emission_test.py) PYSIDE_TEST(signal_func_test.py) PYSIDE_TEST(signal_manager_refcount_test.py) PYSIDE_TEST(signal_object_test.py) +PYSIDE_TEST(signal_signature_test.py) PYSIDE_TEST(signal_with_primitive_type_test.py) PYSIDE_TEST(slot_reference_count_test.py) PYSIDE_TEST(static_metaobject_test.py) PYSIDE_TEST(upstream_segfault_test.py) -PYSIDE_TEST(list_signal_test.py) diff --git a/tests/signals/signal_signature_test.py b/tests/signals/signal_signature_test.py new file mode 100644 index 0000000..785ebb8 --- /dev/null +++ b/tests/signals/signal_signature_test.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +'''Test case for signal signature received by QObject::connectNotify().''' + +import unittest +from PySide.QtCore import * +from helper import UsesQCoreApplication + +class Obj(QObject): + def __init__(self): + QObject.__init__(self) + self.signal = '' + + def connectNotify(self, signal): + self.signal = signal + +def callback(): + pass + +class TestConnectNotifyWithNewStyleSignals(UsesQCoreApplication): + '''Test case for signal signature received by QObject::connectNotify().''' + + def testOldStyle(self): + sender = Obj() + receiver = QObject() + sender.connect(SIGNAL('destroyed()'), receiver, SLOT('deleteLater()')) + self.assertEqual(sender.signal, SIGNAL('destroyed()')) + + def testOldStyleWithPythonCallback(self): + sender = Obj() + sender.connect(SIGNAL('destroyed()'), callback) + self.assertEqual(sender.signal, SIGNAL('destroyed()')) + + def testNewStyle(self): + sender = Obj() + sender.destroyed.connect(callback) + self.assertEqual(sender.signal, SIGNAL('destroyed(QObject*)')) + +if __name__ == '__main__': + unittest.main() + From ee7b4826c0f0e487b75a70812dbcdcab00a0afdd Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 29 Jul 2010 19:14:05 -0300 Subject: [PATCH 0100/1129] Fixed return policy on ItemList. Fixed singleShot function to invalidate temporary object. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 3 +++ PySide/QtGui/typesystem_gui_common.xml | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index db038e2..84cf906 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1697,6 +1697,8 @@ QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); PyObject* result = PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsOs"), pyTimer, SIGNAL(timeout()), %PYARG_2, %3); Py_DECREF(result); + // invalidate to avoid use of python object + Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer); timer->setSingleShot(true); timer->connect(timer, SIGNAL("timeout()"), timer, SLOT("deleteLater()")); timer->start(%1); @@ -1713,6 +1715,7 @@ timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); PyObject* result = PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsO"), pyTimer, SIGNAL(timeout()), pyargs[1]); Py_DECREF(result); + Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer); timer->start(cpp_arg0); diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 7308f00..eb0c3c8 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -2953,6 +2953,11 @@ + + + + + From 1920130fc973f61b0e42f468df9576a917bf2b2e Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 29 Jul 2010 19:20:50 -0300 Subject: [PATCH 0101/1129] Fixed cyclic dependency on duck punching test. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtCore/duck_punching_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/QtCore/duck_punching_test.py b/tests/QtCore/duck_punching_test.py index e20c0c1..880a8e4 100644 --- a/tests/QtCore/duck_punching_test.py +++ b/tests/QtCore/duck_punching_test.py @@ -37,6 +37,12 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication): child = QObject() child.setParent(parent) self.assert_(self.duck_childEvent_called) + # This is done to decrease the refcount of the vm object + # allowing the object wrapper to be deleted before the + # BindingManager. This is useful when compiling Shiboken + # for debug, since the BindingManager destructor has an + # assert that checks if the wrapper mapper is empty. + parent.childEvent = None def testChildEventMonkeyPatchWithInheritance(self): #Test if the new childEvent injected on a QObject's extension class instance is called from C++ @@ -50,6 +56,12 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication): child = QObject() child.setParent(parent) self.assert_(self.duck_childEvent_called) + # This is done to decrease the refcount of the vm object + # allowing the object wrapper to be deleted before the + # BindingManager. This is useful when compiling Shiboken + # for debug, since the BindingManager destructor has an + # assert that checks if the wrapper mapper is empty. + parent.childEvent = None if __name__ == '__main__': unittest.main() From 6c8c9c6391d55a02bb2369fa1c154e9a3a8013d2 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Mon, 2 Aug 2010 11:15:19 -0300 Subject: [PATCH 0102/1129] Fix getOpenFileName/getSaveFileName signatures. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index eb0c3c8..58e233c 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3596,6 +3596,9 @@ + + + @@ -3604,6 +3607,9 @@ + + + @@ -3612,6 +3618,9 @@ + + + From a6440638302436156fb8441a64f24eb8b5208c62 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 30 Jul 2010 11:39:00 -0300 Subject: [PATCH 0103/1129] Fix compile on cmake 2.8 for mac users. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- CMakeLists.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e797457..2e137bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,9 +3,18 @@ include(icecc.cmake) # this must be the first line! project(pysidebindings) cmake_minimum_required(VERSION 2.6) - set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/ ${CMAKE_MODULE_PATH}) +find_package(PythonLibs REQUIRED) +find_package(PythonInterpWithDebug REQUIRED) +find_package(Shiboken 0.3.3 REQUIRED) +find_package(Qt4 4.5.0 REQUIRED) + +set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) +if(CMAKE_HOST_APPLE) + set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "The Alternative value to QT_INCLUDE_DIR. Necessary to fix bug on cmake 2.8 MACOS users") +endif() if(CMAKE_HOST_UNIX) option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) @@ -22,7 +31,11 @@ if(CMAKE_HOST_UNIX) if(CMAKE_HOST_APPLE) if (NOT QT_INCLUDE_DIR) set(QT_INCLUDE_DIR "/Library/Frameworks") - endif() + endif() + if(ALTERNATIVE_QT_INCLUDE_DIR) + set(QT_INCLUDE_DIR ${ALTERNATIVE_QT_INCLUDE_DIR}) + endif() + string(REPLACE " " ":" QT_INCLUDE_DIR ${QT_INCLUDE_DIR}) endif() endif() @@ -36,11 +49,6 @@ if(AVOID_PROTECTED_HACK OR WIN32) message(STATUS "Avoiding protected hack!") endif() -find_package(PythonLibs REQUIRED) -find_package(PythonInterpWithDebug REQUIRED) -find_package(Shiboken 0.3.3 REQUIRED) -find_package(Qt4 4.5.0 REQUIRED) - #Fix missing variable on UNIX env if(NOT PYTHON_DEBUG_LIBRARIES AND UNIX) set(PYTHON_DEBUG_LIBRARIES "${PYTHON_LIBRARIES}") @@ -52,9 +60,6 @@ set(BINDING_API_MINOR_VERSION "3") set(BINDING_API_MICRO_VERSION "3") set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}") -set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) -set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) - if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() From d4f911f5b377b6847bd6309e3f6c5aa00a3690bd Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 2 Aug 2010 11:39:17 -0300 Subject: [PATCH 0104/1129] Raise a python error when signal not found on object. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- libpyside/qsignal.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index dff9cc1..ec0610b 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -212,6 +212,7 @@ PyObject* signal_instance_get_item(PyObject* self, PyObject* key) char* sigKey = signal_parse_signature(key); char* sig = signal_build_signature(data->signalName, sigKey); free(sigKey); + const char* sigName = data->signalName; while(data) { if (strcmp(data->signature, sig) == 0) { @@ -222,7 +223,9 @@ PyObject* signal_instance_get_item(PyObject* self, PyObject* key) } data = reinterpret_cast(data->next); } + PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s", sig, sigName); free(sig); + return 0; } From 09876a43863e7846ce514ae94d2ad0056a32bc67 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 2 Aug 2010 14:53:01 -0300 Subject: [PATCH 0105/1129] Created unit test to bug #274. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtGui/qaction_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/QtGui/qaction_test.py b/tests/QtGui/qaction_test.py index b926ad6..0379d20 100644 --- a/tests/QtGui/qaction_test.py +++ b/tests/QtGui/qaction_test.py @@ -16,6 +16,14 @@ class QPainterDrawText(UsesQApplication): act.trigger() self.assert_(self._called) + def testNewCtor(self): + o = QWidget() + self._called = False + myAction = QAction("&Quit", o, triggered=self._cb) + myAction.trigger() + self.assert_(self._called) + + if __name__ == '__main__': unittest.main() From efe8019eda0471baf99ed4372ceda4af06cbe3c1 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 2 Aug 2010 14:53:29 -0300 Subject: [PATCH 0106/1129] Created a pythonic constructor to QAction Fixes bug #274. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 58e233c..64849ae 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -4251,6 +4251,24 @@ + + + + + + + + + + + %0 = new QActionWrapper(%1, %2); + + + + if (%PYARG_3 != Py_None) + Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(triggered(bool)), %PYARG_3)); + + @@ -4366,7 +4384,6 @@ - From 114bca41a21bf5504094b30d7c8735ac8483e50d Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 2 Aug 2010 14:55:03 -0300 Subject: [PATCH 0107/1129] Created unit test to layout ref leak. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtGui/qlayout_ref_test.py | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/QtGui/qlayout_ref_test.py b/tests/QtGui/qlayout_ref_test.py index 27c599c..695e2f1 100644 --- a/tests/QtGui/qlayout_ref_test.py +++ b/tests/QtGui/qlayout_ref_test.py @@ -108,5 +108,45 @@ class MultipleAdd(UsesQApplication): self.layout.addWidget(self.widget) self.assertEqual(getrefcount(self.widget), 3) +class InternalAdd(UsesQApplication): + def testInternalRef(self): + mw = QWidget() + w = QWidget() + ow = QWidget() + + topLayout = QGridLayout() + + # unique reference + self.assertEqual(getrefcount(w), 2) + self.assertEqual(getrefcount(ow), 2) + + topLayout.addWidget(w, 0, 0) + topLayout.addWidget(ow, 1, 0) + + # layout keep the referemce + self.assertEqual(getrefcount(w), 3) + self.assertEqual(getrefcount(ow), 3) + + mainLayout = QGridLayout() + + mainLayout.addLayout(topLayout, 1, 0, 1, 4) + + # the same reference + self.assertEqual(getrefcount(w), 3) + self.assertEqual(getrefcount(ow), 3) + + mw.setLayout(mainLayout) + + # now trasfer the ownership to mw + self.assertEqual(getrefcount(w), 3) + self.assertEqual(getrefcount(ow), 3) + + del mw + + # remove the ref and invalidate the widget + self.assertEqual(getrefcount(w), 2) + self.assertEqual(getrefcount(ow), 2) + + if __name__ == '__main__': unittest.main() From 630a4062ff9d837ae0f91056ab610183bf47370a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 2 Aug 2010 14:55:50 -0300 Subject: [PATCH 0108/1129] Fixed ref leak on QMenu inject code. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/glue/qmenu_glue.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/QtGui/glue/qmenu_glue.h b/PySide/QtGui/glue/qmenu_glue.h index 7f0475a..1a6cb19 100644 --- a/PySide/QtGui/glue/qmenu_glue.h +++ b/PySide/QtGui/glue/qmenu_glue.h @@ -13,8 +13,8 @@ addActionWithPyObject(QMenu *self, const QIcon& icon, const QString& text, PyObj self->addAction(act); PyObject *pyAct = Shiboken::Converter::toPython(act); - PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback); - if (result == 0) { + Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback)); + if (result.isNull()) { Py_DECREF(pyAct); return 0; } From 34a06b8de43767cc206d2a200c84e5505516e111 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Mon, 2 Aug 2010 17:12:18 -0300 Subject: [PATCH 0109/1129] Fix bug273 - QT_VERSION and QT_VERSION_STR constants. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 6 ++++++ tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/qqtversion_test.py | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 tests/QtCore/qqtversion_test.py diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 84cf906..9d38208 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -522,6 +522,12 @@ %PYARG_0 = %CONVERTTOPYTHON[long](qAbs(%1)); + + + PyModule_AddIntConstant(module, "QT_VERSION", QT_VERSION); + PyModule_AddStringConstant(module, "QT_VERSION_STR", QT_VERSION_STR); + + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index b8f7390..490f734 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -39,6 +39,7 @@ PYSIDE_TEST(qobject_timer_event_test.py) PYSIDE_TEST(qobject_tr_as_instance_test.py) PYSIDE_TEST(qpoint_test.py) PYSIDE_TEST(qprocess_test.py) +PYSIDE_TEST(qqtversion_test.py) PYSIDE_TEST(qrect_test.py) PYSIDE_TEST(qresource_test.py) PYSIDE_TEST(qsize_test.py) diff --git a/tests/QtCore/qqtversion_test.py b/tests/QtCore/qqtversion_test.py new file mode 100644 index 0000000..344de69 --- /dev/null +++ b/tests/QtCore/qqtversion_test.py @@ -0,0 +1,18 @@ + +import unittest + +from PySide import QtCore + + +class QQtVersionTest(unittest.TestCase): + '''Tests for QtCore.QT_VERSION and QT_VERSION_STR''' + + def testVersion(self): + self.assert_(hex(QtCore.QT_VERSION) > 0x40500) + + def testVersionStr(self): + self.assert_(QtCore.QT_VERSION_STR) + + +if __name__ == '__main__': + unittest.main() From f098bb9f3ab5034d8fd04f5ea06e7128bee50d5a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 2 Aug 2010 15:54:35 -0300 Subject: [PATCH 0110/1129] Included support to double values on qAbs. Fixes bug #269. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 4 ++-- tests/QtCore/qabs_test.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 9d38208..94a0a8c 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -517,9 +517,9 @@ - + - %PYARG_0 = %CONVERTTOPYTHON[long](qAbs(%1)); + %PYARG_0 = %CONVERTTOPYTHON[double](qAbs(%1)); diff --git a/tests/QtCore/qabs_test.py b/tests/QtCore/qabs_test.py index 1727ae6..37ff9c7 100644 --- a/tests/QtCore/qabs_test.py +++ b/tests/QtCore/qabs_test.py @@ -14,7 +14,8 @@ class QAbsTest(unittest.TestCase): check(0) check(-10) check(10) - + check(10.5) + check(-10.5) if __name__ == '__main__': unittest.main() From 5ce8d05a089d0409b474be03eab1c7c4d5cfabb6 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Tue, 3 Aug 2010 09:07:34 -0300 Subject: [PATCH 0111/1129] Bump version to 0.4.0 and update shiboken version Reviewer: Luciano Wolf Reviewer: Renato Filho --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e137bf..4f1ee85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/ ${CMAKE_MODULE_PATH}) find_package(PythonLibs REQUIRED) find_package(PythonInterpWithDebug REQUIRED) -find_package(Shiboken 0.3.3 REQUIRED) +find_package(Shiboken 0.4.0 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) @@ -56,8 +56,8 @@ endif() set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "0") -set(BINDING_API_MINOR_VERSION "3") -set(BINDING_API_MICRO_VERSION "3") +set(BINDING_API_MINOR_VERSION "4") +set(BINDING_API_MICRO_VERSION "0") set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}") if (NOT CMAKE_BUILD_TYPE) From ee9e1f6155db49bbb46ecf6a4d264b5658a05e4a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 3 Aug 2010 11:45:53 -0300 Subject: [PATCH 0112/1129] Added support to shortcut named arg on QAction constructor. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 64849ae..e0341e0 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -4251,22 +4251,33 @@ - + + + + + + + + + + %0 = new QActionWrapper(%1, %2); + %0->setShortcut(%3); - if (%PYARG_3 != Py_None) - Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(triggered(bool)), %PYARG_3)); + if (%PYARG_4 != Py_None) + Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(triggered(bool)), %PYARG_4)); From f3a1585e6e2798aa105cb1f775afa75c21da0591 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 3 Aug 2010 19:47:23 -0300 Subject: [PATCH 0113/1129] Bump to version 0.4.1. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f1ee85..f12da82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ endif() set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "0") set(BINDING_API_MINOR_VERSION "4") -set(BINDING_API_MICRO_VERSION "0") +set(BINDING_API_MICRO_VERSION "1") set(BINDING_API_VERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}") if (NOT CMAKE_BUILD_TYPE) From 9e7369e4aec34ce42b92c5686d192e3bf93c3966 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 4 Aug 2010 16:39:27 -0300 Subject: [PATCH 0114/1129] Fixes QAction code injection for constructor code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Luciano Wolf Reviewed by Renato Araújo --- PySide/QtGui/typesystem_gui_common.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index e0341e0..1a98e7c 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -4251,6 +4251,7 @@ + + + + + From 0cf8145d78125453723680135881d5424a9c6168 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 12 Aug 2010 09:59:48 -0300 Subject: [PATCH 0124/1129] Fix bug 295 - "QModelIndex::model() sets the QModelIndex as parent of the model" --- PySide/QtCore/typesystem_core.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index b4f02ca..2a5be3d 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -657,7 +657,7 @@ - + @@ -2157,6 +2157,11 @@ Py_XINCREF(%PYARG_0); + + + + + From 26a48c4ed389cb619ee0109fb1a22a4699e8236a Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 12 Aug 2010 10:00:17 -0300 Subject: [PATCH 0125/1129] Fix ownership of value returned by QItemDelegate::createEditor method. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 9afab40..0942331 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -2917,6 +2917,11 @@ + + + + + From 5cbfffc005c90761af3ba97043ca728970a732b1 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 12 Aug 2010 11:59:48 -0300 Subject: [PATCH 0126/1129] Removed rename command from unecessary functions. Fixes bug #287. Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 38 ++------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 0942331..bc82377 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -572,7 +572,6 @@ - @@ -2088,8 +2087,7 @@ - - + emodify-function signature="isEmpty()const" remove="all"/> @@ -2436,7 +2434,6 @@ - addLayoutOwnership(%CPPSELF, %1); @@ -3862,12 +3859,6 @@ - - - - - - @@ -4049,17 +4040,11 @@ - - - - - - @@ -4077,15 +4062,8 @@ - - - - - + - - - @@ -4315,18 +4293,6 @@ - - - - - - - - - - - - From 533cdcd07b61ffe7d578f0c54b923a1fdbff2ced Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 12 Aug 2010 14:56:25 -0300 Subject: [PATCH 0127/1129] Fix typo on typesystem. --- PySide/QtGui/typesystem_gui_common.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index bc82377..326d830 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -2087,8 +2087,8 @@ - emodify-function signature="isEmpty()const" remove="all"/> + From 8ea5127ccbb0a5d84313041559769bc40fc2ad67 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 13 Aug 2010 11:22:02 -0300 Subject: [PATCH 0128/1129] Created unit test to QVariant converstion of QStringList. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_278_test.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/QtCore/bug_278_test.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 490f734..3b155df 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -1,3 +1,4 @@ +PYSIDE_TEST(bug_278_test.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deletelater_test.py) diff --git a/tests/QtCore/bug_278_test.py b/tests/QtCore/bug_278_test.py new file mode 100644 index 0000000..28d7b37 --- /dev/null +++ b/tests/QtCore/bug_278_test.py @@ -0,0 +1,24 @@ +#!/usr/bin/python + +import unittest + +from PySide import QtCore + +def setValue(o): + values = ['Name'] + o.setProperty('test1', values) + +class QQtVersionTest(unittest.TestCase): + '''Tests for QVariant conversion of QStringList''' + + def testGet(self): + o = QtCore.QObject() + setValue(o) + self.assertEqual(o.property('test1'), ['Name']) + + + +if __name__ == '__main__': + unittest.main() + + From 2b21d79f5439d982de2495d3a190c4f82f51e458 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Fri, 13 Aug 2010 14:15:52 -0300 Subject: [PATCH 0129/1129] All tests using GUI aren't shown if the host machine has xvfb installed. Unwanted graphical output from tests are redirected to a fake X server on Unix system. This depends on the presence of the Xvfb server. Reviewed by Hugo Parente Reviewed by Luciano Wolf --- CMakeLists.txt | 7 +++++++ tests/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b75d1f9..dd6b863 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,13 @@ find_package(PythonInterpWithDebug REQUIRED) find_package(Shiboken 0.4.0 REQUIRED) find_package(Qt4 4.5.0 REQUIRED) +find_program(XVFB_RUN NAMES xvfb-run) +set(XVFB_EXEC "") +if (NOT ${XVFB_RUN} MATCHES "XVFB_RUN-NOTFOUND") + set(XVFB_EXEC ${XVFB_RUN}) + message("Using xvfb-run to perform QtGui tests.") +endif() + set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) if(CMAKE_HOST_APPLE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 904d106..a3f5278 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,7 +18,7 @@ macro(PYSIDE_TEST) else() message(WARNING "Ivalid call of macro PYSIDE_TEST") endif() - set(TEST_CMD ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${libpyside_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") + set(TEST_CMD ${XVFB_EXEC} ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${libpyside_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") add_test(${TEST_NAME} ${TEST_CMD}) set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT ${CTEST_TESTING_TIMEOUT} From 9a19bd26d2282743aae939c0497a9bc2d92ee8d9 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 12 Aug 2010 14:44:36 -0300 Subject: [PATCH 0130/1129] Added tests for QObject properties being set with named arguments on the constructor. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Luciano Wolf Reviewed by Renato Araújo --- tests/QtCore/qobject_property_test.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index e94562c..233d1e8 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -13,6 +13,10 @@ class MySize(QSize): '''Extended class''' pass +class ExtQObject(QObject): + registeredproperty = QProperty(int) + + class PropertyCase(unittest.TestCase): '''Test case for QObject properties''' @@ -91,5 +95,27 @@ class PropertyCase(unittest.TestCase): self.assertTrue(obj.property('foo') is mysize) + +class PropertyWithConstructorCase(unittest.TestCase): + '''Test case for QObject properties set using named arguments in the constructor.''' + + def testObjectNameProperty(self): + #QObject(property=value) for existing C++ property + obj = QObject(objectName='dummy') + self.assertEqual(obj.objectName(), 'dummy') + + def testDynamicPropertyRaisesException(self): + self.assertRaises(AttributeError, QObject, dummy=42) + + def testPythonDeclaredProperty(self): + obj = ExtQObject(registeredproperty=123) + + def testConstructorPropertyInQObjectDerived(self): + #QTimer(property=value) for existing C++ property + obj = QTimer(objectName='dummy') + self.assertEqual(obj.objectName(), 'dummy') + + if __name__ == '__main__': unittest.main() + From c130273ee0fd41be0ed756a90ab8a24934ddb7e9 Mon Sep 17 00:00:00 2001 From: renato Date: Fri, 13 Aug 2010 15:28:59 -0300 Subject: [PATCH 0131/1129] Fixed arguments parser on QProperty constructor. Reviewer: Marcelo Lira Luciano Wolf --- libpyside/qproperty.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libpyside/qproperty.cpp b/libpyside/qproperty.cpp index 781c8cf..f20c387 100644 --- a/libpyside/qproperty.cpp +++ b/libpyside/qproperty.cpp @@ -139,15 +139,15 @@ int qproperty_init(PyObject* self, PyObject* args, PyObject* kwds) data->scriptable = true; data->stored = true; - static const char *kwlist[] = {"fget", "fset", "freset", "fdel", "doc", + static const char *kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "designable", "scriptable", "stored", "user", "constant", "final", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOOsbbbbbb:QtCore.QProperty", (char**) kwlist, - &type, &data->fget, &data->fset, &data->freset, - &data->fdel, &data->doc, &data->designable, - &data->scriptable, &data->stored, &data->user, - &data->constant, &data->final)) + /*O*/&type, + /*OOOO*/ &(data->fget), &(data->fset), &(data->freset), &(data->fdel), + /*s*/&(data->doc), + /*bbbbbb*/&(data->designable), &(data->scriptable), &(data->stored), &(data->user), &(data->constant), &(data->final))) return 0; if (!data->fset && data->fget) From 1162a844bd689958205d10eeff549451ee8cb93b Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 13 Aug 2010 17:25:57 -0300 Subject: [PATCH 0132/1129] Fixed Http test to work with Qt 4.7. Reviewer: Marcelo Lira Luciano Wolf --- tests/QtNetwork/http_test.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py index 531316d..ee6eeea 100644 --- a/tests/QtNetwork/http_test.py +++ b/tests/QtNetwork/http_test.py @@ -6,18 +6,17 @@ import unittest from PySide.QtCore import * from PySide.QtNetwork import * -from helper import UsesQApplication +from helper import UsesQCoreApplication from httpd import TestServer -class HttpSignalsCase(UsesQApplication): +class HttpSignalsCase(UsesQCoreApplication): '''Test case for launching QHttp signals''' def setUp(self): super(HttpSignalsCase, self).setUp() - self.http = QHttp() self.httpd = TestServer() self.httpd.start() - self.url = QUrl('localhost:' + str(self.httpd.port())) + self.http = QHttp('localhost' , self.httpd.port()) self.called = False def tearDown(self): @@ -34,8 +33,7 @@ class HttpSignalsCase(UsesQApplication): #QHttp signal requestStarted signal # @bug 114 self.http.requestStarted.connect(self.callback) - self.http.get(self.url.path()) - + self.http.get("index.html") self.app.exec_() self.assert_(self.called) From 6bd528978cad1fe2c0e56cb35b270346da3fbbdd Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 13 Aug 2010 18:22:22 -0300 Subject: [PATCH 0133/1129] Raise a error when try to modify a read-only property. Add get function as mandatory in QProperty constructor. Reviewer: Marcelo Lira Luciano Wolf --- libpyside/qproperty.cpp | 12 +++++++----- libpyside/signalmanager.cpp | 1 - tests/QtCore/qobject_property_test.py | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libpyside/qproperty.cpp b/libpyside/qproperty.cpp index f20c387..b2d011e 100644 --- a/libpyside/qproperty.cpp +++ b/libpyside/qproperty.cpp @@ -143,11 +143,11 @@ int qproperty_init(PyObject* self, PyObject* args, PyObject* kwds) "designable", "scriptable", "stored", "user", "constant", "final", 0}; if (!PyArg_ParseTupleAndKeywords(args, kwds, - "O|OOOOsbbbbbb:QtCore.QProperty", (char**) kwlist, - /*O*/&type, - /*OOOO*/ &(data->fget), &(data->fset), &(data->freset), &(data->fdel), - /*s*/&(data->doc), - /*bbbbbb*/&(data->designable), &(data->scriptable), &(data->stored), &(data->user), &(data->constant), &(data->final))) + "OO|OOOsbbbbbb:QtCore.QProperty", (char**) kwlist, + /*OO*/ &type, &(data->fget), + /*OOOO*/ &(data->fset), &(data->freset), &(data->fdel), + /*s*/ &(data->doc), + /*bbbbbb*/ &(data->designable), &(data->scriptable), &(data->stored), &(data->user), &(data->constant), &(data->final))) return 0; if (!data->fset && data->fget) @@ -187,6 +187,8 @@ int qproperty_set(PyObject* self, PyObject* source, PyObject* value) Py_INCREF(value); Shiboken::AutoDecRef result(PyObject_CallObject(data->fset, args)); return (result.isNull() ? -1 : 0); + } else { + PyErr_SetString(PyExc_AttributeError, "Attibute read only"); } return -1; } diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 7482f01..ed15732 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -373,7 +373,6 @@ int SignalManager::qt_metacall(QObject* object, QMetaObject::Call call, int id, Py_XDECREF(pp_name); return id - metaObject->methodCount(); } - printf("access to property: %s-%s\n", mp.name(), mp.typeName()); typeResolver = Shiboken::TypeResolver::get(mp.typeName()); } diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index 233d1e8..7d53e0a 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -16,6 +16,16 @@ class MySize(QSize): class ExtQObject(QObject): registeredproperty = QProperty(int) +class MyObject(QObject): + '''Test Property''' + + def readPP(self): + return 42 + + def trySetPP(self): + self.pp = 0 + + pp = QProperty(int, readPP) class PropertyCase(unittest.TestCase): '''Test case for QObject properties''' @@ -115,6 +125,11 @@ class PropertyWithConstructorCase(unittest.TestCase): obj = QTimer(objectName='dummy') self.assertEqual(obj.objectName(), 'dummy') + def testPythonProperty(self): + o = MyObject() + self.assertEqual(o.pp, 42) + o.pp = 0 + self.assertRaises(AttributeError, o.trySetPP) if __name__ == '__main__': unittest.main() From 2d24d300d8ef7e65489051f2f6d3d7d213d4a86a Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 16 Aug 2010 12:07:12 -0300 Subject: [PATCH 0134/1129] Avoid read the property in the QObject constructor. Create unit test to verify if the python property is setted during the constructor. Reviewer: Hugo Parente Luciano Wolf --- libpyside/qproperty.cpp | 12 +++++++----- tests/QtCore/qobject_property_test.py | 20 ++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/libpyside/qproperty.cpp b/libpyside/qproperty.cpp index b2d011e..c4b728a 100644 --- a/libpyside/qproperty.cpp +++ b/libpyside/qproperty.cpp @@ -231,12 +231,14 @@ const char* qproperty_get_type(PyObject* self) PyObject* qproperty_get_object(PyObject* source, PyObject* name) { - if (PyObject_HasAttr(source, name)) { - PyObject* attr = PyObject_GenericGetAttr(source, name); - if (isQPropertyType(attr)) - return attr; + PyObject* attr = PyObject_GenericGetAttr(source, name); + if (attr && isQPropertyType(attr)) + return attr; + + if (!attr) + PyErr_Clear(); //Clear possible error caused by PyObject_GenericGetAttr + else Py_DECREF(attr); - } return 0; } diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py index 7d53e0a..1d8a16c 100644 --- a/tests/QtCore/qobject_property_test.py +++ b/tests/QtCore/qobject_property_test.py @@ -13,8 +13,17 @@ class MySize(QSize): '''Extended class''' pass -class ExtQObject(QObject): - registeredproperty = QProperty(int) +class ExQObject(QObject): + def __init__(self, *args, **kargs): + QObject.__init__(self, *args, **kargs) + + def setProperty(self, value): + self._value = value + + def getProperty(self): + return self._value + + registeredproperty = QProperty(int, getProperty, setProperty) class MyObject(QObject): '''Test Property''' @@ -105,7 +114,6 @@ class PropertyCase(unittest.TestCase): self.assertTrue(obj.property('foo') is mysize) - class PropertyWithConstructorCase(unittest.TestCase): '''Test case for QObject properties set using named arguments in the constructor.''' @@ -118,17 +126,17 @@ class PropertyWithConstructorCase(unittest.TestCase): self.assertRaises(AttributeError, QObject, dummy=42) def testPythonDeclaredProperty(self): - obj = ExtQObject(registeredproperty=123) + obj = ExQObject(registeredproperty=123) + self.assertEqual(obj.registeredproperty, 123) def testConstructorPropertyInQObjectDerived(self): #QTimer(property=value) for existing C++ property obj = QTimer(objectName='dummy') self.assertEqual(obj.objectName(), 'dummy') - def testPythonProperty(self): + def testReadOnlyPythonProperty(self): o = MyObject() self.assertEqual(o.pp, 42) - o.pp = 0 self.assertRaises(AttributeError, o.trySetPP) if __name__ == '__main__': From aedea32f131a553a9db0670cd89c43d171244951 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 16 Aug 2010 18:21:25 -0300 Subject: [PATCH 0135/1129] Implemented help function to connect signal with python callback. Updated QAction unittest to work with signal connection on constructor. Reviewer: Hugo Parente Luciano Wolf --- libpyside/qsignal.cpp | 18 +++++++++++++++++- libpyside/qsignal.h | 1 + tests/QtGui/qaction_test.py | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index ec0610b..c6a8240 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -448,12 +448,28 @@ PyObject* signal_instance_connect(PyObject* self, PyObject* args, PyObject* kwds if (match) { Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "connect")); - return PyObject_CallObject(pyMethod, tupleArgs); + return PyObject_CallObject(pyMethod, tupleArgs); } return 0; } +bool signal_connect(PyObject* source, const char* signal, PyObject* callback) +{ + Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source, "connect")); + if (pyMethod.isNull()) + return false; + + Shiboken::AutoDecRef pyArgs(PyList_New(0)); + Shiboken::AutoDecRef pySignature(PyString_FromString(signal)); + PyList_Append(pyArgs, source); + PyList_Append(pyArgs, pySignature); + PyList_Append(pyArgs, callback); + Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); + + return PyObject_CallObject(pyMethod, tupleArgs); +} + PyObject* signal_instance_disconnect(PyObject* self, PyObject* args) { SignalInstanceData *source = reinterpret_cast(self); diff --git a/libpyside/qsignal.h b/libpyside/qsignal.h index 63eded1..b208343 100644 --- a/libpyside/qsignal.h +++ b/libpyside/qsignal.h @@ -59,6 +59,7 @@ extern "C" PYSIDE_API PyAPI_FUNC(PyObject*) signalNew(const char* name, ...); PYSIDE_API void signalUpdateSource(PyObject* source); +PYSIDE_API bool signal_connect(PyObject* source, const char* signal, PyObject* callback); } //namespace PySide diff --git a/tests/QtGui/qaction_test.py b/tests/QtGui/qaction_test.py index ff7efbe..b6a45d1 100644 --- a/tests/QtGui/qaction_test.py +++ b/tests/QtGui/qaction_test.py @@ -5,7 +5,7 @@ from helper import UsesQApplication class QPainterDrawText(UsesQApplication): - def _cb(self, checked): + def _cb(self): self._called = True def testSignal(self): From d686c687074708af1654131f603b767d52f611e6 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 16 Aug 2010 18:22:56 -0300 Subject: [PATCH 0136/1129] Fixed gui typesystem to avoid warnings. Reviewer: Hugo Parente Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 41 +++----------------------- libpyside/qsignal.cpp | 9 ++---- 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 326d830..1110964 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -547,18 +547,13 @@ - - - - - - - + + @@ -4241,36 +4236,6 @@ - - - - - - - - - - - - - - - - - %0 = new %TYPE(%1, %2); - %0->setShortcut(%3); - - - - if (%PYARG_4 && %PYARG_4 != Py_None) - Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(triggered(bool)), %PYARG_4)); - - @@ -4857,4 +4822,6 @@ + + diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp index c6a8240..f465a7b 100644 --- a/libpyside/qsignal.cpp +++ b/libpyside/qsignal.cpp @@ -460,14 +460,9 @@ bool signal_connect(PyObject* source, const char* signal, PyObject* callback) if (pyMethod.isNull()) return false; - Shiboken::AutoDecRef pyArgs(PyList_New(0)); Shiboken::AutoDecRef pySignature(PyString_FromString(signal)); - PyList_Append(pyArgs, source); - PyList_Append(pyArgs, pySignature); - PyList_Append(pyArgs, callback); - Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); - - return PyObject_CallObject(pyMethod, tupleArgs); + Shiboken::AutoDecRef pyArgs(PyTuple_Pack(3, source, pySignature.object(), callback)); + return PyObject_CallObject(pyMethod, pyArgs); } PyObject* signal_instance_disconnect(PyObject* self, PyObject* args) From 9a969935ccc866804574480ac41ec004646f104c Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 17 Aug 2010 10:44:48 -0300 Subject: [PATCH 0137/1129] Fix bug 294 addind a converter specific for QFlags. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Luciano Wolf Renato Araújo --- libpyside/pysideconversions.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libpyside/pysideconversions.h b/libpyside/pysideconversions.h index 32d5f34..c7fdcb5 100644 --- a/libpyside/pysideconversions.h +++ b/libpyside/pysideconversions.h @@ -37,6 +37,7 @@ #include #include +#include template struct QtDictConverter @@ -222,4 +223,34 @@ struct QSequenceConverter } }; +template +struct QFlagsConverter +{ + static inline bool checkType(PyObject* pyObj) + { + return PyObject_TypeCheck(pyObj, Shiboken::SbkType()); + } + + static inline bool isConvertible(PyObject* pyObj) + { + return PyObject_TypeCheck(pyObj, Shiboken::SbkType()) + || PyObject_TypeCheck(pyObj, Shiboken::SbkType()); + } + + static inline PyObject* toPython(void* cppobj) + { + return toPython(*reinterpret_cast(cppobj)); + } + + static inline PyObject* toPython(T cppenum) + { + return Shiboken::SbkEnumObject_New(Shiboken::SbkType(), (long) cppenum); + } + + static inline T toCpp(PyObject* pyobj) + { + return T(QFlag(reinterpret_cast(pyobj)->ob_ival)); + } +}; + #endif From 23672770ea6fd79c38fed0695fc92ca193f0ece4 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Tue, 17 Aug 2010 15:49:55 -0300 Subject: [PATCH 0138/1129] Disable remove of QAbstractItemModel signals. Fixes bug #300. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 13 ------------- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_300_test.py | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 tests/QtCore/bug_300_test.py diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 2a5be3d..571cc91 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -985,19 +985,6 @@ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME(%1, %2, %PYARG_3)); - - - - - - - - - - - - - diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 3b155df..cf7727f 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -1,4 +1,5 @@ PYSIDE_TEST(bug_278_test.py) +PYSIDE_TEST(bug_300_test.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deletelater_test.py) diff --git a/tests/QtCore/bug_300_test.py b/tests/QtCore/bug_300_test.py new file mode 100644 index 0000000..ec02cdf --- /dev/null +++ b/tests/QtCore/bug_300_test.py @@ -0,0 +1,17 @@ +from PySide.QtGui import QStringListModel +from PySide.QtCore import QModelIndex +import unittest + +class TestQAbstractItemModelSignals(unittest.TestCase): + def sigCallback(self, index, r, c): + self._called = True + + def testSignals(self): + self._called = False + m = QStringListModel() + m.rowsAboutToBeInserted[QModelIndex,int,int].connect(self.sigCallback) + m.insertRows(0, 3) + self.assert_(self._called) + +if __name__ == '__main__': + unittest.main() From 465649d73e552cfb1e74e343eea3341b2842ccd6 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 19 Aug 2010 17:48:08 -0300 Subject: [PATCH 0139/1129] created macro to compile pyside modules. Reviewer: Luciano Wolf Hugo Parente Lima --- CMakeLists.txt | 10 +++-- PySide/CMakeLists.txt | 44 +++++++++++++----- PySide/QtCore/CMakeLists.txt | 39 +++++++--------- PySide/QtDeclarative/CMakeLists.txt | 69 ++++++++++++++--------------- PySide/QtGui/CMakeLists.txt | 44 +++++++++--------- PySide/QtHelp/CMakeLists.txt | 47 +++++++++----------- PySide/QtMaemo5/CMakeLists.txt | 48 +++++++++----------- PySide/QtMultimedia/CMakeLists.txt | 56 +++++++++++------------ PySide/QtNetwork/CMakeLists.txt | 49 +++++++++----------- PySide/QtOpenGL/CMakeLists.txt | 54 ++++++++++------------ PySide/QtScript/CMakeLists.txt | 52 +++++++++------------- PySide/QtSql/CMakeLists.txt | 56 ++++++++++------------- PySide/QtSvg/CMakeLists.txt | 59 +++++++++++------------- PySide/QtTest/CMakeLists.txt | 61 +++++++++++-------------- PySide/QtUiTools/CMakeLists.txt | 60 +++++++++++-------------- PySide/QtWebKit/CMakeLists.txt | 65 ++++++++++++--------------- PySide/QtXml/CMakeLists.txt | 54 ++++++++++------------ PySide/QtXmlPatterns/CMakeLists.txt | 47 +++++++++----------- PySide/phonon/CMakeLists.txt | 46 +++++++++---------- libpyside/CMakeLists.txt | 3 +- libpyside/pysidemacros.h | 8 +++- 21 files changed, 442 insertions(+), 529 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd6b863..06b729e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,10 +23,14 @@ if(CMAKE_HOST_APPLE) set(ALTERNATIVE_QT_INCLUDE_DIR "" CACHE PATH "The Alternative value to QT_INCLUDE_DIR. Necessary to fix bug on cmake 2.8 MACOS users") endif() -if(CMAKE_HOST_UNIX) - option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") +if(MSVC) + set(CMAKE_CXX_FLAGS "/Zc:wchar_t- /GR /EHsc /DNOCOLOR /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS") +else() + if(CMAKE_HOST_UNIX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") + endif() set(CMAKE_CXX_FLAGS_DEBUG "-g") + option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) if(ENABLE_GCC_OPTIMIZATION) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1") diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index b1b3286..22ccde8 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -3,20 +3,40 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}") macro(execute_generator module sources typesystem_path) -add_custom_command(OUTPUT ${${sources}} -COMMAND ${GENERATOR} ${GENERATOR_EXTRA_FLAGS} - ${CMAKE_BINARY_DIR}/PySide/global.h - --include-paths=${pyside_SOURCE_DIR}:${QT_INCLUDE_DIR} - --typesystem-paths=${pyside_SOURCE_DIR}:${typesystem_path} - --output-directory=${CMAKE_CURRENT_BINARY_DIR} - --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt - ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_${module}.xml - --api-version=${SUPPORTED_QT_VERSION} -WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -COMMENT "Running generator for ${module}..." -) + message("Running generator for ${module}...") endmacro(execute_generator) +macro(create_pyside_module module_name typesystem_file module_include_dir module_libraries module_deps module_typesystem_path module_sources) + add_custom_command(OUTPUT ${${module_sources}} + COMMAND ${GENERATOR} ${GENERATOR_EXTRA_FLAGS} + ${CMAKE_BINARY_DIR}/PySide/global.h + --include-paths=${pyside_SOURCE_DIR}:${QT_INCLUDE_DIR} + --typesystem-paths=${pyside_SOURCE_DIR}:${${module_typesystem_path}} + --output-directory=${CMAKE_CURRENT_BINARY_DIR} + --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt + ${typesystem_file} + --api-version=${SUPPORTED_QT_VERSION} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Running generator for ${module_name}...") + + include_directories(${module_name} ${${module_include_dir}}) + add_library(${module_name} MODULE ${${module_sources}}) + set_target_properties(${module_name} PROPERTIES PREFIX "") + target_link_libraries(${module_name} ${${module_libraries}}) + if(${module_deps}) + add_dependencies(${module_name} ${${module_deps}}) + endif() + + # install + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${module_name}${CMAKE_DEBUG_POSTFIX}.so + DESTINATION ${SITE_PACKAGE}/PySide) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module_name}/pyside_${module_name}_python.h + DESTINATION include/PySide/${module_name}/) + install(FILES ${typesystem_file} + DESTINATION share/PySide/typesystems) +endmacro(create_pyside_module) + + # Configure include based on platform configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in" "${CMAKE_CURRENT_BINARY_DIR}/global.h" @ONLY) diff --git a/PySide/QtCore/CMakeLists.txt b/PySide/QtCore/CMakeLists.txt index 6300a4c..b6c7534 100644 --- a/PySide/QtCore/CMakeLists.txt +++ b/PySide/QtCore/CMakeLists.txt @@ -134,29 +134,22 @@ ${QtCore_46_SRC} ${QtCore_47_SRC} ) -execute_generator(core QtCore_SRC "${CMAKE_CURRENT_BINARY_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtCore/ - ${QT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ) -add_library(QtCore MODULE ${QtCore_SRC}) -set_property(TARGET QtCore PROPERTY PREFIX "") -target_link_libraries(QtCore - pyside +set(QtCore_typesystem_path ${CMAKE_CURRENT_BINARY_DIR}) +set(QtCore_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtCore/ + ${QT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH}) +set(QtCore_libraries pyside ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} - ${QT_QTCORE_LIBRARY} - ) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtCore${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/${BINDING_NAME}) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtCore/pyside_qtcore_python.h - DESTINATION include/PySide/QtCore/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_core.xml - DESTINATION share/PySide/typesystems) + ${QT_QTCORE_LIBRARY}) +create_pyside_module(QtCore + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_core.xml + QtCore_include_dirs + QtCore_libraries + "" + QtCore_typesystem_path + QtCore_SRC) diff --git a/PySide/QtDeclarative/CMakeLists.txt b/PySide/QtDeclarative/CMakeLists.txt index 79b4b42..fc38103 100644 --- a/PySide/QtDeclarative/CMakeLists.txt +++ b/PySide/QtDeclarative/CMakeLists.txt @@ -20,43 +20,40 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qdeclarativeview_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/qtdeclarative_module_wrapper.cpp ) -execute_generator(declarative QtDeclarative_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtDeclarative_SOURCE_DIR}:${QtNetwork_SOURCE_DIR}:${QtNetwork_BINARY_DIR}") +set(QtDeclarative_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtDeclarative_SOURCE_DIR}:${QtNetwork_SOURCE_DIR}:${QtNetwork_BINARY_DIR}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} - ${QT_QTDECLARATIVE_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative) -add_library(QtDeclarative MODULE ${QtDeclarative_SRC}) -set_target_properties(QtDeclarative PROPERTIES PREFIX "") -target_link_libraries(QtDeclarative - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTSVG_LIBRARY} - ${QT_QTSQL_LIBRARY} - ${QT_QTXMLPATTERNS_LIBRARY} - ${QT_QTOPENGL_LIBRARY} - ${QT_QTDECLARATIVE_LIBRARY}) -add_dependencies(QtDeclarative QtGui) -add_dependencies(QtDeclarative QtNetwork) +set(QtDeclarative_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTDECLARATIVE_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtDeclarative${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtDeclarative/pyside_qtdeclarative_python.h - DESTINATION include/PySide/QtDeclarative/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_declarative.xml - DESTINATION share/PySide/typesystems) +set(QtDeclarative_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTSCRIPT_LIBRARY} + ${QT_QTSVG_LIBRARY} + ${QT_QTSQL_LIBRARY} + ${QT_QTXMLPATTERNS_LIBRARY} + ${QT_QTOPENGL_LIBRARY} + ${QT_QTDECLARATIVE_LIBRARY}) +set(QtDeclarative_deps QtGui QtNetwork) + +create_pyside_module(QtDeclarative + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_declarative.xml + QtDeclarative_include_dirs + QtDeclarative_libraries + QtDeclarative_deps + QtDeclarative_typesystem_path + QtDeclarative_SRC) diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index fdc36b3..18ce256 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -470,34 +470,32 @@ CHECK_QT_GUI_MACRO("SessionManager Support" QT_NO_SESSIONMANAGER QT_SESSIONMANAG configure_file(typesystem_gui.xml.in "${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml" @ONLY) -execute_generator(gui QtGui_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtCore_BINARY_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/ - ${QT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ) -add_library(QtGui MODULE ${QtGui_SRC}) -set_property(TARGET QtGui PROPERTY PREFIX "") -target_link_libraries(QtGui - pyside +set(QtGui_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtCore_BINARY_DIR}") +set(QtGui_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/ + ${QT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore/) +set(QtGui_libraries pyside ${PYSIDE_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtGui QtCore) + ${QT_QTGUI_LIBRARY}) +set(QtGui_deps "QtCore") -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtGui${CMAKE_DEBUG_POSTFIX}.so DESTINATION "${SITE_PACKAGE}/PySide") -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/pyside_qtgui_python.h - DESTINATION include/PySide/QtGui/) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml - ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_common.xml +# extra install +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_common.xml ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_mac.xml ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_maemo.xml ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_gui_x11.xml DESTINATION share/PySide/typesystems) +create_pyside_module(QtGui + ${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml + QtGui_include_dirs + QtGui_libraries + QtGui_deps + QtGui_typesystem_path + QtGui_SRC) + diff --git a/PySide/QtHelp/CMakeLists.txt b/PySide/QtHelp/CMakeLists.txt index 42b0737..d5140c2 100644 --- a/PySide/QtHelp/CMakeLists.txt +++ b/PySide/QtHelp/CMakeLists.txt @@ -15,35 +15,28 @@ set(QtHelp_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp/qthelp_module_wrapper.cpp ) -execute_generator(help QtHelp_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtHelp_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTHELP_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp) -add_library(QtHelp MODULE ${QtHelp_SRC}) - -set_target_properties(QtHelp PROPERTIES PREFIX "") - -target_link_libraries(QtHelp - pyside +set(QtHelp_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtHelp_SOURCE_DIR}") +set(QtHelp_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTHELP_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp) +set(QtHelp_libraries pyside ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTHELP_LIBRARY}) -add_dependencies(QtHelp QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtHelp${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtHelp/pyside_qthelp_python.h - DESTINATION include/PySide/QtHelp/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_help.xml - DESTINATION share/PySide/typesystems) +set(QtHelp_deps QtGui) +create_pyside_module(QtHelp + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_help.xml + QtHelp_include_dirs + QtHelp_libraries + QtHelp_deps + QtHelp_typesystem_path + QtHelp_SRC) diff --git a/PySide/QtMaemo5/CMakeLists.txt b/PySide/QtMaemo5/CMakeLists.txt index 5338b80..fbcf75f 100644 --- a/PySide/QtMaemo5/CMakeLists.txt +++ b/PySide/QtMaemo5/CMakeLists.txt @@ -11,8 +11,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5/qmaemo5valuebutton_wrapper. ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5/qtmaemo5_module_wrapper.cpp ) -execute_generator(maemo5 QtMaemo5_SRC - "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtMaemo5_SOURCE_DIR}") +set(QtMaemo5_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtMaemo5_SOURCE_DIR}") # QT_QTMAEMO5_* variables are not defined by CMake if(NOT QT_QTMAEMO5_INCLUDE_DIR) @@ -24,35 +23,28 @@ if(NOT QT_QTMAEMO5_LIBRARY) PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) endif(NOT QT_QTMAEMO5_LIBRARY) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTMAEMO5_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/${BINDING_NAME}/QtCore/ - ${QtGui_BINARY_DIR}/${BINDING_NAME}/QtGui/ - ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5) -add_library(QtMaemo5 MODULE ${QtMaemo5_SRC}) - -set_target_properties(QtMaemo5 PROPERTIES - PREFIX "") - -target_link_libraries(QtMaemo5 - pyside +set(QtMaemo5_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTMAEMO5_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/${BINDING_NAME}/QtCore/ + ${QtGui_BINARY_DIR}/${BINDING_NAME}/QtGui/ + ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5) +set(QtMaemo5_libraries pyside ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTMAEMO5_LIBRARY}) +set(QtMaemo5_deps QtGui) -add_dependencies(QtMaemo5 QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMaemo5${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/${BINDING_NAME}) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMaemo5/pyside_qtmaemo5_python.h - DESTINATION include/${BINDING_NAME}/QtMaemo5/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_maemo5.xml - DESTINATION share/PySide/typesystems) +create_pyside_module(QtMaemo5 + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_maemo5.xml + QtMaemo5_include_dirs + QtMaemo5_libraries + QtMaemo5_deps + QtMaemo5_typesystem_path + QtMaemo5_SRC) diff --git a/PySide/QtMultimedia/CMakeLists.txt b/PySide/QtMultimedia/CMakeLists.txt index 20707f7..1829697 100644 --- a/PySide/QtMultimedia/CMakeLists.txt +++ b/PySide/QtMultimedia/CMakeLists.txt @@ -17,38 +17,32 @@ set(QtMultimedia_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/qvideoframe_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/qtmultimedia_module_wrapper.cpp ) +set(QtMultimedia_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") -execute_generator(multimedia QtMultimedia_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") +set(QtMultimedia_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTMULTIMEDIA_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTMULTIMEDIA_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ) +set(QtMultimedia_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTMULTIMEDIA_LIBRARY} + ${QT_QTGUI_LIBRARY}) -add_library(QtMultimedia MODULE ${QtMultimedia_SRC}) -set_property(TARGET QtMultimedia PROPERTY PREFIX "") -target_link_libraries(QtMultimedia - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTMULTIMEDIA_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtMultimedia QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtMultimedia${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtMultimedia/pyside_qtmultimedia_python.h - DESTINATION include/PySide/QtMultimedia/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_multimedia.xml - DESTINATION share/PySide/typesystems) +set(QtMultimedia_deps QtGui) +create_pyside_module(QtMultimedia + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_multimedia.xml + QtMultimedia_include_dirs + QtMultimedia_libraries + QtMultimedia_deps + QtMultimedia_typesystem_path + QtMultimedia_SRC) diff --git a/PySide/QtNetwork/CMakeLists.txt b/PySide/QtNetwork/CMakeLists.txt index 6afedbd..df3c129 100644 --- a/PySide/QtNetwork/CMakeLists.txt +++ b/PySide/QtNetwork/CMakeLists.txt @@ -98,33 +98,26 @@ set(OPENSSL_SOURCES CHECK_QT_NETWORK_MACRO("Network OPENSSL" QT_NO_OPENSSL OPENSSL_SOURCES QtNetwork_SRC) -execute_generator(network QtNetwork_SRC "${CMAKE_CURRENT_SOURCE_DIR}:${QtCore_SOURCE_DIR}") +set(QtNetwork_typesystem_path "${CMAKE_CURRENT_SOURCE_DIR}:${QtCore_SOURCE_DIR}") +set(QtNetwork_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/ + ${QT_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore/) +set(QtNetwork_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTNETWORK_LIBRARY}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/ - ${QT_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ) - -add_library(QtNetwork MODULE ${QtNetwork_SRC}) -set_property(TARGET QtNetwork PROPERTY PREFIX "") -target_link_libraries(QtNetwork - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ) -add_dependencies(QtNetwork QtCore) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtNetwork${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/pyside_qtnetwork_python.h - DESTINATION include/PySide/QtNetwork/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_network.xml - DESTINATION share/PySide/typesystems) +set(QtNetwork_deps QtCore) +create_pyside_module(QtNetwork + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_network.xml + QtNetwork_include_dirs + QtNetwork_libraries + QtNetwork_deps + QtNetwork_typesystem_path + QtNetwork_SRC) diff --git a/PySide/QtOpenGL/CMakeLists.txt b/PySide/QtOpenGL/CMakeLists.txt index 158f4be..42173a4 100644 --- a/PySide/QtOpenGL/CMakeLists.txt +++ b/PySide/QtOpenGL/CMakeLists.txt @@ -32,33 +32,27 @@ set(QtOpenGL_SRC ${QtOpenGL_47_SRC} ) -execute_generator(opengl QtOpenGL_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtOpenGL_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTOPENGL_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL) -add_library(QtOpenGL MODULE ${QtOpenGL_SRC}) -set_target_properties(QtOpenGL PROPERTIES PREFIX "") -target_link_libraries(QtOpenGL - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTOPENGL_LIBRARY}) -add_dependencies(QtOpenGL QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtOpenGL${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL/pyside_qtopengl_python.h - DESTINATION include/PySide/QtOpenGL/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_opengl.xml - DESTINATION share/PySide/typesystems) - +set(QtOpenGL_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtOpenGL_SOURCE_DIR}") +set(QtOpenGL_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTOPENGL_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtOpenGL) +set(QtOpenGL_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTOPENGL_LIBRARY}) +set(QtOpenGL_deps QtGui) +create_pyside_module(QtOpenGL + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_opengl.xml + QtOpenGL_include_dirs + QtOpenGL_libraries + QtOpenGL_deps + QtOpenGL_typesystem_path + QtOpenGL_SRC) diff --git a/PySide/QtScript/CMakeLists.txt b/PySide/QtScript/CMakeLists.txt index af6ffd4..d9e8264 100644 --- a/PySide/QtScript/CMakeLists.txt +++ b/PySide/QtScript/CMakeLists.txt @@ -25,33 +25,25 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/qscriptvalueiterator_wrapper.cpp ${QtScript_46_SRC} ) -execute_generator(script QtScript_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript - ${QT_INCLUDE_DIR} - ${QT_QTSCRIPT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore - ) -add_library(QtScript MODULE ${QtScript_SRC}) -set_property(TARGET QtScript PROPERTY PREFIX "") -target_link_libraries(QtScript - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTCORE_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} - ) -add_dependencies(QtScript QtCore) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtScript${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript/pyside_qtscript_python.h - DESTINATION include/PySide/QtScript/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_script.xml - DESTINATION share/PySide/typesystems) - - +set(QtScript_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") +set(QtScript_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScript + ${QT_INCLUDE_DIR} + ${QT_QTSCRIPT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore ) +set(QtScript_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTCORE_LIBRARY} + ${QT_QTSCRIPT_LIBRARY}) +set(QtScript_deps QtCore) +create_pyside_module(QtScript + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_script.xml + QtScript_include_dirs + QtScript_libraries + QtScript_deps + QtScript_typesystem_path + QtScript_SRC) diff --git a/PySide/QtSql/CMakeLists.txt b/PySide/QtSql/CMakeLists.txt index 1c45ac0..f8e105d 100644 --- a/PySide/QtSql/CMakeLists.txt +++ b/PySide/QtSql/CMakeLists.txt @@ -21,35 +21,27 @@ set(QtSql_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/qtsql_module_wrapper.cpp ) -execute_generator(sql QtSql_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtSql_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTSQL_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/) -add_library(QtSql MODULE ${QtSql_SRC}) -set_target_properties(QtSql PROPERTIES PREFIX "") -target_link_libraries(QtSql - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTSQL_LIBRARY}) - -add_dependencies(QtSql QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtSql${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/pyside_qtsql_python.h - DESTINATION include/PySide/QtSql/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sql.xml - DESTINATION share/PySide/typesystems) - - +set(QtSql_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtSql_SOURCE_DIR}") +set(QtSql_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTSQL_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSql/) +set(QtSql_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTSQL_LIBRARY}) +set(QtSql_deps QtGui) +create_pyside_module(QtSql + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sql.xml + QtSql_include_dirs + QtSql_libraries + QtSql_deps + QtSql_typesystem_path + QtSql_SRC) diff --git a/PySide/QtSvg/CMakeLists.txt b/PySide/QtSvg/CMakeLists.txt index 33cdba5..4119512 100644 --- a/PySide/QtSvg/CMakeLists.txt +++ b/PySide/QtSvg/CMakeLists.txt @@ -30,37 +30,28 @@ ${SPECIFIC_OS_FILES} ${QtSvg_46_SRC} ) -execute_generator(svg QtSvg_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTSVG_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ) - -add_library(QtSvg MODULE ${QtSvg_SRC}) -set_property(TARGET QtSvg PROPERTY PREFIX "") -target_link_libraries(QtSvg - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTSVG_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtSvg QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtSvg${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/pyside_qtsvg_python.h - DESTINATION include/PySide/QtSvg/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_svg.xml - DESTINATION share/PySide/typesystems) - +set(QtSvg_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") +set(QtSvg_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtSvg/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTSVG_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/) +set(QtSvg_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTSVG_LIBRARY} + ${QT_QTGUI_LIBRARY}) +set(QtSvg_deps QtGui) +create_pyside_module(QtSvg + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_svg.xml + QtSvg_include_dirs + QtSvg_libraries + QtSvg_deps + QtSvg_typesystem_path + QtSvg_SRC) diff --git a/PySide/QtTest/CMakeLists.txt b/PySide/QtTest/CMakeLists.txt index 3ac608f..def84db 100644 --- a/PySide/QtTest/CMakeLists.txt +++ b/PySide/QtTest/CMakeLists.txt @@ -18,38 +18,29 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/qttest_module_wrapper.cpp ${SPECIFIC_OS_FILES} ) -execute_generator(test QtTest_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTTEST_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ) - -add_library(QtTest MODULE ${QtTest_SRC}) -set_property(TARGET QtTest PROPERTY PREFIX "") -target_link_libraries(QtTest - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTTEST_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTCORE_LIBRARY} - ) -add_dependencies(QtTest QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtTest${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/pyside_qttest_python.h - DESTINATION include/PySide/QtTest/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_test.xml - DESTINATION share/PySide/typesystems) - +set(QtTest_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}") +set(QtTest_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTTEST_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/) +set(QtTest_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTTEST_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTCORE_LIBRARY}) +set(QtTest_deps QtGui) +create_pyside_module(QtTest + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_test.xml + QtTest_include_dirs + QtTest_libraries + QtTest_deps + QtTest_typesystem_path + QtTest_SRC) diff --git a/PySide/QtUiTools/CMakeLists.txt b/PySide/QtUiTools/CMakeLists.txt index 320fc1a..9af11fb 100644 --- a/PySide/QtUiTools/CMakeLists.txt +++ b/PySide/QtUiTools/CMakeLists.txt @@ -5,37 +5,29 @@ set(QtUiTools_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools/quiloader_wrapper.cpp ) -execute_generator(uitools QtUiTools_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtXml_SOURCE_DIR}:${QtUiTools_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR} - ${QT_QTUITOOLS_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtXml_BINARY_DIR}/PySide/QtXml/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools) - -add_library(QtUiTools MODULE ${QtUiTools_SRC}) -set_target_properties(QtUiTools PROPERTIES PREFIX "") -target_link_libraries(QtUiTools - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${QT_QTUITOOLS_LIBRARY}) - -add_dependencies(QtUiTools QtGui QtXml) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtUiTools${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools/pyside_qtuitools_python.h - DESTINATION include/PySide/QtUiTools/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_uitools.xml - DESTINATION share/PySide/typesystems) - +set(QtUiTools_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${QtXml_SOURCE_DIR}:${QtUiTools_SOURCE_DIR}") +set(QtUiTools_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTXML_INCLUDE_DIR} + ${QT_QTUITOOLS_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtXml_BINARY_DIR}/PySide/QtXml/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools) +set(QtUiTools_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTUITOOLS_LIBRARY}) +set(QtUiTools_deps QtGui QtXml) +create_pyside_module(QtUiTools + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_uitools.xml + QtUiTools_include_dirs + QtUiTools_libraries + QtUiTools_deps + QtUiTools_typesystem_path + QtUiTools_SRC) diff --git a/PySide/QtWebKit/CMakeLists.txt b/PySide/QtWebKit/CMakeLists.txt index 464bc28..08e20be 100644 --- a/PySide/QtWebKit/CMakeLists.txt +++ b/PySide/QtWebKit/CMakeLists.txt @@ -44,41 +44,32 @@ ${SPECIFIC_OS_FILES} ${QtWebKit_46_SRC} ) -execute_generator(webkit QtWebKit_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtNetwork_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebkit/ - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QTNETWORK_INCLUDE_DIR} - ${QT_QTWEBKIT_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ - ) - -add_library(QtWebKit MODULE ${QtWebKit_SRC}) -set_property(TARGET QtWebKit PROPERTY PREFIX "") -target_link_libraries(QtWebKit - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} - ${QT_QTNETWORK_LIBRARY} - ${QT_QTGUI_LIBRARY} - ) -add_dependencies(QtWebKit QtGui) -add_dependencies(QtWebKit QtNetwork) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtWebKit${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebKit/pyside_qtwebkit_python.h - DESTINATION include/PySide/QtWebKit/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_webkit.xml - DESTINATION share/PySide/typesystems) +set(QtWebKit_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtNetwork_SOURCE_DIR}") +set(QtWebkit_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtWebkit/ + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTWEBKIT_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtNetwork_BINARY_DIR}/PySide/QtNetwork/ ) +set(QtWebKit_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTWEBKIT_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTGUI_LIBRARY}) +set(QtWebKit_deps QtGui QtNetwork) +create_pyside_module(QtWebKit + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_webkit.xml + QtWebkit_include_dirs + QtWebKit_libraries + QtWebKit_deps + QtWebKit_typesystem_path + QtWebKit_SRC) diff --git a/PySide/QtXml/CMakeLists.txt b/PySide/QtXml/CMakeLists.txt index fc7b0d0..c76cabd 100644 --- a/PySide/QtXml/CMakeLists.txt +++ b/PySide/QtXml/CMakeLists.txt @@ -35,34 +35,26 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/qxmlreader_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/qxmlsimplereader_wrapper.cpp ) -execute_generator(xml QtXml_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml - ${CMAKE_SOURCE_DIR} - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QtCore_BINARY_DIR}/PySide/QtCore - ) -add_library(QtXml MODULE ${QtXml_SRC}) -set_property(TARGET QtXml PROPERTY PREFIX "") -target_link_libraries(QtXml - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${SHIBOKEN_LIBRARY} - ${QT_QTXML_LIBRARY} - ) -add_dependencies(QtXml QtCore) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXml${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml/pyside_qtxml_python.h - DESTINATION include/PySide/QtXml/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_xml.xml - DESTINATION share/PySide/typesystems) - - +set(QtXml_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") +set(QtXml_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXml + ${CMAKE_SOURCE_DIR} + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTXML_INCLUDE_DIR} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${PYTHON_INCLUDE_PATH} + ${QtCore_BINARY_DIR}/PySide/QtCore) +set(QtXml_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${SHIBOKEN_LIBRARY} + ${QT_QTXML_LIBRARY}) +set(QtXml_deps QtCore) +create_pyside_module(QtXml + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_xml.xml + QtXml_include_dirs + QtXml_libraries + QtXml_deps + QtXml_typesystem_path + QtXml_SRC) diff --git a/PySide/QtXmlPatterns/CMakeLists.txt b/PySide/QtXmlPatterns/CMakeLists.txt index 825011f..3456e9e 100644 --- a/PySide/QtXmlPatterns/CMakeLists.txt +++ b/PySide/QtXmlPatterns/CMakeLists.txt @@ -26,30 +26,25 @@ set(QtXmlPatterns_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns/qxmlserializer_wrapper.cpp ${QtXmlPatterns_46_SRC} ) - -execute_generator(xmlpatterns QtXmlPatterns_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTXMLPATTERNS_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns) -add_library(QtXmlPatterns MODULE ${QtXmlPatterns_SRC}) -set_target_properties(QtXmlPatterns PROPERTIES PREFIX "") -target_link_libraries(QtXmlPatterns - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_QTXMLPATTERNS_LIBRARY}) -add_dependencies(QtXmlPatterns QtCore) -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXmlPatterns${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns/pyside_qtxmlpatterns_python.h - DESTINATION include/PySide/QtXmlPatterns/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_xmlpatterns.xml - DESTINATION share/PySide/typesystems) +set(QtXmlPatterns_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}") +set(QtXmlPatterns_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTXMLPATTERNS_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtXmlPatterns) +set(QtXmlPatterns_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_QTXMLPATTERNS_LIBRARY}) +set(QtXmlPatterns_deps QtCore) +create_pyside_module(QtXmlPatterns + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_xmlpatterns.xml + QtXmlPatterns_include_dirs + QtXmlPatterns_libraries + QtXmlPatterns_deps + QtXmlPatterns_typesystem_path + QtXmlPatterns_SRC) diff --git a/PySide/phonon/CMakeLists.txt b/PySide/phonon/CMakeLists.txt index b46304a..062f17d 100644 --- a/PySide/phonon/CMakeLists.txt +++ b/PySide/phonon/CMakeLists.txt @@ -43,34 +43,28 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_volumeslider_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/phonon_backendcapabilities_notifierwrapper_wrapper.cpp ) - -execute_generator(phonon phonon_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${phonon_SOURCE_DIR}") - -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} - ${QT_PHONON_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon) -add_library(phonon MODULE ${phonon_SRC}) -set_target_properties(phonon PROPERTIES PREFIX "") -target_link_libraries(phonon - pyside +set(phonon_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtGui_SOURCE_DIR}:${phonon_SOURCE_DIR}") +set(phonon_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ${QT_PHONON_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon) +set(phonon_libraries pyside ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_PHONON_LIBRARY}) -add_dependencies(phonon QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/phonon${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/phonon/pyside_phonon_python.h - DESTINATION include/PySide/phonon/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_phonon.xml - DESTINATION share/PySide/typesystems) +set(phonon_deps QtGui) +create_pyside_module(phonon + "typesystem_phonon.xml" + phonon_include_dirs + phonon_libraries + phonon_depend + phonon_typesystem_path + phonon_SRC) diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index 9590a32..284a384 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -23,7 +23,8 @@ target_link_libraries(pyside set_target_properties(pyside PROPERTIES VERSION ${BINDING_API_VERSION} - SOVERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}") + SOVERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}" + DEFINE_SYMBOL PYSIDE_EXPORTS) # # install stuff diff --git a/libpyside/pysidemacros.h b/libpyside/pysidemacros.h index c9e1e11..ccf8e37 100644 --- a/libpyside/pysidemacros.h +++ b/libpyside/pysidemacros.h @@ -36,10 +36,14 @@ #define PYSIDEMACROS_H #if defined _WIN32 || defined __CYGWIN__ - #if PYSIDE_BUILD + #if PYSIDE_EXPORTS #define PYSIDE_API __declspec(dllexport) #else - #define PYSIDE_API __declspec(dllimport) + #if defined __MINGW32__ + #define PYSIDE_API + #else + #define PYSIDE_API __declspec(dllimport) + #endif #endif #else #if __GNUC__ >= 4 From 0fb81692e3804ff92e326566994c4e1d1255b737 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 19 Aug 2010 17:49:44 -0300 Subject: [PATCH 0140/1129] Use .pyd for modules on windows. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 22ccde8..25f267e 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -22,6 +22,9 @@ macro(create_pyside_module module_name typesystem_file module_include_dir module include_directories(${module_name} ${${module_include_dir}}) add_library(${module_name} MODULE ${${module_sources}}) set_target_properties(${module_name} PROPERTIES PREFIX "") + if(WIN32) + set_target_properties(${module_name} PROPERTIES SUFFIX ".pyd") + endif() target_link_libraries(${module_name} ${${module_libraries}}) if(${module_deps}) add_dependencies(${module_name} ${${module_deps}}) From 18d65457dc735543cfcead4a4cac427138b522bb Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Thu, 19 Aug 2010 18:24:20 -0300 Subject: [PATCH 0141/1129] Updated test to work with Cmake 2.8 in multiples plataforms. Reviewer: Luciano Wolf Hugo Parente Lima --- tests/CMakeLists.txt | 127 +++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 53 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a3f5278..fe4f7ec 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,59 +1,80 @@ -if(NOT CTEST_TESTING_TIMEOUT) - set(CTEST_TESTING_TIMEOUT 60) -endif() +if(CMAKE_VERSION VERSION_LESS 2.8) + message("CMake version greater than 2.8 necessary to run tests") +else() + if(NOT CTEST_TESTING_TIMEOUT) + set(CTEST_TESTING_TIMEOUT 60) + endif() -macro(TEST_QT_MODULE var name) - if(NOT DISABLE_${name} AND ${var}) - add_subdirectory(${name}) - endif() -endmacro(TEST_QT_MODULE) + if(WIN32) + set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util") + set(TEST_LIBRARY_PATH "$ENV{PATH};${libpyside_BINARY_DIR}") + set(LIBRARY_PATH_VAR "PATH") + string(REPLACE "\\" "/" TEST_PYTHONPATH "${TEST_PYTHONPATH}") + string(REPLACE "\\" "/" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}") -macro(PYSIDE_TEST) - string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" ) - set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") - if (${ARGC} EQUAL 1) - set(EXPECT_TO_FAIL 0) - elseif(${ARGC} EQUAL 2) - set(EXPECT_TO_FAIL ${ARGV1}) + string(REPLACE ";" "\\;" TEST_PYTHONPATH "${TEST_PYTHONPATH}") + string(REPLACE ";" "\\;" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}") else() - message(WARNING "Ivalid call of macro PYSIDE_TEST") + set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util") + set(TEST_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}:${libpyside_BINARY_DIR}") + set(LIBRARY_PATH_VAR "LD_LIBRARY_PATH") endif() - set(TEST_CMD ${XVFB_EXEC} ${CMAKE_SOURCE_DIR}/tests/run_test.sh ${libpyside_BINARY_DIR} "${CMAKE_BINARY_DIR}:${CMAKE_SOURCE_DIR}/tests/util" ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") - add_test(${TEST_NAME} ${TEST_CMD}) - set_tests_properties(${TEST_NAME} PROPERTIES - TIMEOUT ${CTEST_TESTING_TIMEOUT} - WILL_FAIL ${EXPECT_TO_FAIL}) -endmacro(PYSIDE_TEST) -# Try to find QtMultimedia -# TODO: Remove this hack when cmake support QtMultimedia module -if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) - find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia - PATHS ${QT_HEADERS_DIR}/QtMultimedia - ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY) - set(QT_QTMULTIMEDIA_FOUND ON) - endif() -endif () -add_subdirectory(signals) -TEST_QT_MODULE(QT_QTCORE_FOUND QtCore) -TEST_QT_MODULE(QT_QTGUI_FOUND QtGui) -TEST_QT_MODULE(QT_QTNETWORK_FOUND QtNetwork) -TEST_QT_MODULE(QT_QTWEBKIT_FOUND QtWebKit) -TEST_QT_MODULE(QT_QTSVG_FOUND QtSvg) -TEST_QT_MODULE(QT_QTXML_FOUND QtXml) -TEST_QT_MODULE(QT_QTTEST_FOUND QtTest) -TEST_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL) -TEST_QT_MODULE(QT_QTSQL_FOUND QtSql) -TEST_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) -TEST_QT_MODULE(QT_QTHELP_FOUND QtHelp) -TEST_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns) -TEST_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5) -TEST_QT_MODULE(QT_QTSCRIPT_FOUND QtScript) -TEST_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools) -TEST_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia) -TEST_QT_MODULE(QT_PHONON_FOUND phonon) -TEST_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative) + macro(TEST_QT_MODULE var name) + if(NOT DISABLE_${name} AND ${var}) + add_subdirectory(${name}) + endif() + endmacro(TEST_QT_MODULE) + + macro(PYSIDE_TEST) + string(REGEX MATCH "/([^/]+)//?([^/]+)\\.py" foo "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}" ) + set(TEST_NAME "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}") + if (${ARGC} EQUAL 1) + set(EXPECT_TO_FAIL 0) + elseif(${ARGC} EQUAL 2) + set(EXPECT_TO_FAIL ${ARGV1}) + else() + message(WARNING "Ivalid call of macro PYSIDE_TEST") + endif() + set(TEST_CMD ${XVFB_EXEC} ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}") + add_test(${TEST_NAME} ${TEST_CMD}) + set_tests_properties(${TEST_NAME} PROPERTIES + TIMEOUT ${CTEST_TESTING_TIMEOUT} + WILL_FAIL ${EXPECT_TO_FAIL} + ENVIRONMENT "PYTHONPATH=${TEST_PYTHONPATH};${LIBRARY_PATH_VAR}=${TEST_LIBRARY_PATH}") + endmacro(PYSIDE_TEST) + + # Try to find QtMultimedia + # TODO: Remove this hack when cmake support QtMultimedia module + if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) + find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia + PATHS ${QT_HEADERS_DIR}/QtMultimedia + ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers + NO_DEFAULT_PATH) + find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY) + set(QT_QTMULTIMEDIA_FOUND ON) + endif() + endif () + + add_subdirectory(signals) + TEST_QT_MODULE(QT_QTCORE_FOUND QtCore) + TEST_QT_MODULE(QT_QTGUI_FOUND QtGui) + TEST_QT_MODULE(QT_QTNETWORK_FOUND QtNetwork) + TEST_QT_MODULE(QT_QTWEBKIT_FOUND QtWebKit) + TEST_QT_MODULE(QT_QTSVG_FOUND QtSvg) + TEST_QT_MODULE(QT_QTXML_FOUND QtXml) + TEST_QT_MODULE(QT_QTTEST_FOUND QtTest) + TEST_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL) + TEST_QT_MODULE(QT_QTSQL_FOUND QtSql) + TEST_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) + TEST_QT_MODULE(QT_QTHELP_FOUND QtHelp) + TEST_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns) + TEST_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5) + TEST_QT_MODULE(QT_QTSCRIPT_FOUND QtScript) + TEST_QT_MODULE(QT_QTSCRIPTTOOLS_FOUND QtScriptTools) + TEST_QT_MODULE(QT_QTMULTIMEDIA_FOUND QtMultimedia) + TEST_QT_MODULE(QT_PHONON_FOUND phonon) + TEST_QT_MODULE(QT_QTDECLARATIVE_FOUND QtDeclarative) +endif() From 4c7979877a2808a98cc60e234b8f2a0dc51acd4b Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Fri, 20 Aug 2010 12:42:25 +0300 Subject: [PATCH 0142/1129] fixed the newsigslot documentation to use API 2 --- doc/newsigslot.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/newsigslot.rst b/doc/newsigslot.rst index 15e9fca..99db7e0 100644 --- a/doc/newsigslot.rst +++ b/doc/newsigslot.rst @@ -91,15 +91,15 @@ Nothing better than examples to show how to use the new-style. Here you can find import sys from PySide import QtCore - # define a new slot that receives a QString and has + # define a new slot that receives a string and has # 'saySomeWords' as its name - @QtCore.Slot(QtCore.QString) + @QtCore.Slot(str) def saySomeWords(words): print words class Communicate(QtCore.QObject): # create a new signal on the fly and name it 'speak' - speak = QtCore.Signal(QtCore.QString) + speak = QtCore.Signal(str) someone = Communicate() # connect signal and slot @@ -114,18 +114,18 @@ Nothing better than examples to show how to use the new-style. Here you can find import sys from PySide import QtCore - # define a new slot that receives a C 'int' or a 'QString' + # define a new slot that receives a C 'int' or a 'str' # and has 'saySomething' as its name @QtCore.Slot(int) - @QtCore.Slot(QtCore.QString) + @QtCore.Slot(str) def saySomething(stuff): print stuff class Communicate(QtCore.QObject): # create two new signals on the fly: one will handle - # int type, the other will handle QStrings + # int type, the other will handle strings speakNumber = QtCore.Signal(int) - speakWord = QtCore.Signal(QtCore.QString) + speakWord = QtCore.Signal(str) someone = Communicate() # connect signal and slot properly @@ -143,29 +143,29 @@ Nothing better than examples to show how to use the new-style. Here you can find import sys from PySide import QtCore - # define a new slot that receives an C 'int' or a 'QString' + # define a new slot that receives an C 'int' or a 'str' # and has 'saySomething' as its name @QtCore.Slot(int) - @QtCore.Slot(QtCore.QString) + @QtCore.Slot(str) def saySomething(stuff): print stuff class Communicate(QtCore.QObject): # create two new signals on the fly: one will handle - # int type, the other will handle QStrings - speak = QtCore.Signal((int,), (QtCore.QString,)) + # int type, the other will handle strings + speak = QtCore.Signal((int,), (str,)) someone = Communicate() # connect signal and slot. As 'int' is the default - # we have to inform the QString when connecting the + # we have to specify the str when connecting the # second signal someone.speak.connect(saySomething) - someone.speak[QtCore.QString].connect(saySomething) + someone.speak[str].connect(saySomething) # emit 'speak' signal with different arguments. - # we have to inform the QString as int is the default + # we have to specify the str as int is the default someone.speak.emit(10) - someone.speak[QtCore.QString].emit("Hello everybody!") + someone.speak[str].emit("Hello everybody!") PyQt compatibility From 7b9ec90b4dffee089d3b1cbcbe5b933b3aa91c9b Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 10:48:06 -0300 Subject: [PATCH 0143/1129] Fixed QtScriptTools CMake file and others files. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/QtNetwork/CMakeLists.txt | 13 ------- PySide/QtScriptTools/CMakeLists.txt | 59 +++++++++++++---------------- PySide/QtSvg/CMakeLists.txt | 12 ------ PySide/QtTest/CMakeLists.txt | 12 ------ PySide/QtWebKit/CMakeLists.txt | 12 ------ 5 files changed, 27 insertions(+), 81 deletions(-) diff --git a/PySide/QtNetwork/CMakeLists.txt b/PySide/QtNetwork/CMakeLists.txt index df3c129..1550499 100644 --- a/PySide/QtNetwork/CMakeLists.txt +++ b/PySide/QtNetwork/CMakeLists.txt @@ -34,19 +34,6 @@ macro(CHECK_QT_NETWORK_MACRO macro_display_name qt_macro module_sources global_s endmacro(CHECK_QT_NETWORK_MACRO) -if(Q_WS_X11) - set(MODULE_NAME network_x11) - set(SPECIFIC_OS_FILES - ) - -elseif(Q_WS_MAC) - set(MODULE_NAME network_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} GREATER 6) set (QtNetwork_47_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qnetworkconfiguration_wrapper.cpp diff --git a/PySide/QtScriptTools/CMakeLists.txt b/PySide/QtScriptTools/CMakeLists.txt index 22860b1..39faee4 100644 --- a/PySide/QtScriptTools/CMakeLists.txt +++ b/PySide/QtScriptTools/CMakeLists.txt @@ -5,38 +5,33 @@ set(QtScriptTools_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools/qscriptenginedebugger_wrapper.cpp ) -execute_generator(scripttools QtScriptTools_SRC "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtScript_SOURCE_DIR}:${QtScriptTools_SOURCE_DIR}") +set(QtScriptTools_typesystem_path "${CMAKE_CURRENT_BINARY_DIR}:${QtCore_SOURCE_DIR}:${QtGui_SOURCE_DIR}:${QtGui_BINARY_DIR}:${QtScript_SOURCE_DIR}:${QtScriptTools_SOURCE_DIR}") -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_GUI_INCLUDE_DIR} - ${QT_QTSCRIPT_INCLUDE_DIR} - ${QT_QTSCRIPTTOOLS_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${SHIBOKEN_INCLUDE_DIR} - ${libpyside_SOURCE_DIR} - ${QtCore_BINARY_DIR}/PySide/QtCore/ - ${QtGui_BINARY_DIR}/PySide/QtGui/ - ${QtScript_BINARY_DIR}/PySide/QtScript/ - ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools) +set(QtScriptTools_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_GUI_INCLUDE_DIR} + ${QT_QTSCRIPT_INCLUDE_DIR} + ${QT_QTSCRIPTTOOLS_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ${SHIBOKEN_INCLUDE_DIR} + ${libpyside_SOURCE_DIR} + ${QtCore_BINARY_DIR}/PySide/QtCore/ + ${QtGui_BINARY_DIR}/PySide/QtGui/ + ${QtScript_BINARY_DIR}/PySide/QtScript/ + ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools) -add_library(QtScriptTools MODULE ${QtScriptTools_SRC}) -set_target_properties(QtScriptTools PROPERTIES PREFIX "") -target_link_libraries(QtScriptTools - pyside - ${PYSIDE_PYTHON_LIBRARIES} - ${QT_QTCORE_LIBRARY} - ${QT_GUI_LIBRARY} - ${QT_QTSCRIPT_LIBRARY} - ${QT_QTSCRIPTTOOLS_LIBRARY}) - -add_dependencies(QtScriptTools QtCore QtScript QtGui) - -# install -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtScriptTools${CMAKE_DEBUG_POSTFIX}.so - DESTINATION ${SITE_PACKAGE}/PySide) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtScriptTools/pyside_qtscripttools_python.h - DESTINATION include/PySide/QtScriptTools/) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_scripttools.xml - DESTINATION share/PySide/typesystems) +set(QtScriptTools_libraries pyside + ${PYSIDE_PYTHON_LIBRARIES} + ${QT_QTCORE_LIBRARY} + ${QT_GUI_LIBRARY} + ${QT_QTSCRIPT_LIBRARY} + ${QT_QTSCRIPTTOOLS_LIBRARY}) +set(QtScriptTools_deps QtCore QtScript QtGui) +create_pyside_module(QtScriptTools + ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_scripttools.xml + QtScriptTools_include_dirs + QtScriptTools_libraries + QtScriptTools_deps + QtScriptTools_typesystem_path + QtScriptTools_SRC) diff --git a/PySide/QtSvg/CMakeLists.txt b/PySide/QtSvg/CMakeLists.txt index 4119512..a56ee33 100644 --- a/PySide/QtSvg/CMakeLists.txt +++ b/PySide/QtSvg/CMakeLists.txt @@ -1,17 +1,5 @@ project(QtSvg) -if(Q_WS_X11) - set(MODULE_NAME svg_x11) - set(SPECIFIC_OS_FILES - ) -elseif(Q_WS_MAC) - set(MODULE_NAME svg_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) set (QtSvg_46_SRC ) else () diff --git a/PySide/QtTest/CMakeLists.txt b/PySide/QtTest/CMakeLists.txt index def84db..4bf0bca 100644 --- a/PySide/QtTest/CMakeLists.txt +++ b/PySide/QtTest/CMakeLists.txt @@ -1,17 +1,5 @@ project(QtTest) -if(Q_WS_X11) - set(MODULE_NAME test_x11) - set(SPECIFIC_OS_FILES - ) -elseif(Q_WS_MAC) - set(MODULE_NAME test_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - set(QtTest_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/qtest_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtTest/qttest_module_wrapper.cpp diff --git a/PySide/QtWebKit/CMakeLists.txt b/PySide/QtWebKit/CMakeLists.txt index 08e20be..9039835 100644 --- a/PySide/QtWebKit/CMakeLists.txt +++ b/PySide/QtWebKit/CMakeLists.txt @@ -1,17 +1,5 @@ project(QtWebKit) -if(Q_WS_X11) - set(MODULE_NAME webkit_x11) - set(SPECIFIC_OS_FILES - ) -elseif(Q_WS_MAC) - set(MODULE_NAME webkit_mac) - set(SPECIFIC_OS_FILES - ) -else() - message(FATAL_ERROR "OS not supported") -endif(Q_WS_X11) - if (${QT_VERSION_MAJOR} EQUAL 4 AND ${QT_VERSION_MINOR} LESS 6) set (QtWebKit_46_SRC ) else () From 2bdba4680c7ead9b3488a0dc01bf0945ae57c3a8 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 11:33:28 -0300 Subject: [PATCH 0144/1129] Fixed libshiboken classes visibility. Reviewer: Luciano Wolf Hugo Parente Lima --- libpyside/qsignal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libpyside/qsignal.h b/libpyside/qsignal.h index b208343..fe4d5ff 100644 --- a/libpyside/qsignal.h +++ b/libpyside/qsignal.h @@ -53,11 +53,11 @@ typedef struct { extern "C" { - PyAPI_DATA(PyTypeObject) Signal_Type; - PyAPI_DATA(PyTypeObject) SignalInstance_Type; + extern PYSIDE_API PyTypeObject Signal_Type; + extern PYSIDE_API PyTypeObject SignalInstance_Type; }; //extern "C" -PYSIDE_API PyAPI_FUNC(PyObject*) signalNew(const char* name, ...); +PYSIDE_API PyObject* signalNew(const char* name, ...); PYSIDE_API void signalUpdateSource(PyObject* source); PYSIDE_API bool signal_connect(PyObject* source, const char* signal, PyObject* callback); From 7b9a4707ce9f178bb3122444b16d7ad1e05a515c Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 13:20:34 -0300 Subject: [PATCH 0145/1129] Fixed typesystem for windows. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 1 + PySide/QtGui/CMakeLists.txt | 4 ++++ PySide/QtGui/typesystem_gui_win.xml | 6 ++++++ libpyside/qproperty.h | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 PySide/QtGui/typesystem_gui_win.xml diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 571cc91..c377c7f 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -36,6 +36,7 @@ + diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index 18ce256..9d2b897 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -52,6 +52,10 @@ elseif(ENABLE_MAC) set(MODULE_NAME "mac") set(SPECIFIC_OS_FILES ) +elseif(ENABLE_WIN) + set(MODULE_NAME "win") + set(SPECIFIC_OS_FILES + ) endif(ENABLE_X11) diff --git a/PySide/QtGui/typesystem_gui_win.xml b/PySide/QtGui/typesystem_gui_win.xml new file mode 100644 index 0000000..0dfb504 --- /dev/null +++ b/PySide/QtGui/typesystem_gui_win.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/libpyside/qproperty.h b/libpyside/qproperty.h index 7e0e1bc..f561d47 100644 --- a/libpyside/qproperty.h +++ b/libpyside/qproperty.h @@ -44,7 +44,7 @@ namespace PySide extern "C" { - PyAPI_DATA(PyTypeObject) QProperty_Type; + extern PYSIDE_API PyTypeObject QProperty_Type; }; //extern "C" PYSIDE_API bool isQPropertyType(PyObject* pyObj); From af8bf30d0636285c7f3f4fb957b8d368d7ff596c Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 13:36:02 -0300 Subject: [PATCH 0146/1129] Changed output dir for python modules to make the tests run in others platafforms. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/CMakeLists.txt | 10 ++++------ PySide/QtCore/typesystem_core.xml | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 25f267e..3e42c3c 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -21,7 +21,7 @@ macro(create_pyside_module module_name typesystem_file module_include_dir module include_directories(${module_name} ${${module_include_dir}}) add_library(${module_name} MODULE ${${module_sources}}) - set_target_properties(${module_name} PROPERTIES PREFIX "") + set_target_properties(${module_name} PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY ${pyside_BINARY_DIR}) if(WIN32) set_target_properties(${module_name} PROPERTIES SUFFIX ".pyd") endif() @@ -31,7 +31,7 @@ macro(create_pyside_module module_name typesystem_file module_include_dir module endif() # install - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${module_name}${CMAKE_DEBUG_POSTFIX}.so + install(FILES ${pyside_BINARY_DIR}/${module_name}${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module_name}/pyside_${module_name}_python.h DESTINATION include/PySide/${module_name}/) @@ -52,16 +52,14 @@ if (DISABLE_${name}) else() if (${var}) add_subdirectory(${name}) - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/${name}/${name}${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_MODULE_SUFFIX}" - "${CMAKE_BINARY_DIR}/PySide/${name}${CMAKE_SHARED_MODULE_SUFFIX}") else() message(STATUS "${name} NOT found. ${name} support disabled.") endif() endif() endmacro(HAS_QT_MODULE) -execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" - "${CMAKE_BINARY_DIR}/PySide/__init__.py") +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" + "${CMAKE_BINARY_DIR}/PySide/__init__.py") # Try to find QtMultimedia # TODO: Remove this hack when cmake support QtMultimedia module if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index c377c7f..571cc91 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -36,7 +36,6 @@ - From 35a5bad950bfa5082268a0f52be4d6e310678f8f Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 14:43:18 -0300 Subject: [PATCH 0147/1129] Fixed typestyste to windows. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 7 ++----- PySide/QtGui/typesystem_gui_win.xml | 2 +- PySide/global.h.in | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 571cc91..f1c4cf2 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -128,13 +128,10 @@ - - - - - + + diff --git a/PySide/QtGui/typesystem_gui_win.xml b/PySide/QtGui/typesystem_gui_win.xml index 0dfb504..f44d3d4 100644 --- a/PySide/QtGui/typesystem_gui_win.xml +++ b/PySide/QtGui/typesystem_gui_win.xml @@ -1,6 +1,6 @@ - + diff --git a/PySide/global.h.in b/PySide/global.h.in index c9c8ba8..cf21bd6 100644 --- a/PySide/global.h.in +++ b/PySide/global.h.in @@ -345,7 +345,7 @@ QT_END_HEADER #define QT_NO_DEBUG #include -#if @ENABLE_MAC@ +#if @ENABLE_MAC@ || @ENABLE_WIN@ #undef qdoc #endif #include From 0576d04403cd02e08bc6c8d71c30f4abc186f95e Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Fri, 20 Aug 2010 14:22:39 -0300 Subject: [PATCH 0148/1129] Fix install command to correct module name. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 3e42c3c..8f50ed4 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -33,7 +33,8 @@ macro(create_pyside_module module_name typesystem_file module_include_dir module # install install(FILES ${pyside_BINARY_DIR}/${module_name}${CMAKE_DEBUG_POSTFIX}.so DESTINATION ${SITE_PACKAGE}/PySide) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module_name}/pyside_${module_name}_python.h + string(TOLOWER ${module_name} lower_module_name) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module_name}/pyside_${lower_module_name}_python.h DESTINATION include/PySide/${module_name}/) install(FILES ${typesystem_file} DESTINATION share/PySide/typesystems) From 662800956b935bf344dfb8cbfb47f2c3b5717aec Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 16:37:41 -0300 Subject: [PATCH 0149/1129] Use AutoPointerArray to dynamic array creation. Reviewer: Luciano Wolf Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 6 ++- PySide/QtGui/typesystem_gui_common.xml | 9 ++-- libpyside/autoarraypointer.h | 58 ++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 libpyside/autoarraypointer.h diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index f1c4cf2..1e371f0 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -127,10 +127,12 @@ - - + + + + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 1110964..80122c2 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -2587,7 +2587,10 @@ - + + + + @@ -2599,7 +2602,7 @@ int numItems = PySequence_Size(%PYARG_1); - QGraphicsItem *%out[numItems]; + PySide::AutoArrayPointer<QGraphicsItem*> %out(numItems); for (int i=0; i < numItems; i++) { %out[i] = %CONVERTTOCPP[QGraphicsItem*](PySequence_Fast_GET_ITEM(%PYARG_1, i)); } @@ -2626,7 +2629,7 @@ int numOptions = PySequence_Size(%PYARG_2); - QStyleOptionGraphicsItem %out[numOptions]; + PySide::AutoArrayPointer<QStyleOptionGraphicsItem> %out(numOptions); for (int i=0; i < numOptions; i++) { %out[i] = %CONVERTTOCPP[QStyleOptionGraphicsItem](PySequence_Fast_GET_ITEM(%PYARG_1, i)); } diff --git a/libpyside/autoarraypointer.h b/libpyside/autoarraypointer.h new file mode 100644 index 0000000..433401c --- /dev/null +++ b/libpyside/autoarraypointer.h @@ -0,0 +1,58 @@ +/* + * This file is part of the Shiboken Python Bindings Generator project. + * + * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. Please + * review the following information to ensure the GNU Lesser General + * Public License version 2.1 requirements will be met: + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + * + * As a special exception to the GNU Lesser General Public License + * version 2.1, the object code form of a "work that uses the Library" + * may incorporate material from a header file that is part of the + * Library. You may distribute such object code under terms of your + * choice, provided that the incorporated material (i) does not exceed + * more than 5% of the total size of the Library; and (ii) is limited to + * numerical parameters, data structure layouts, accessors, macros, + * inline functions and templates. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef AUTOARRAYPOINTER_H +#define AUTOARRAYPOINTER_H + + +namespace PySide +{ + +template +class AutoArrayPointer +{ + public: + AutoArrayPointer(int size) { data = new T[size]; } + T& operator[](int pos) { return data[pos]; } + operator T*() const { return data; } + ~AutoArrayPointer() { delete[] data; } + private: + T* data; +}; + +} //namespace PySide + + +#endif // AUTOARRAYPOINTER_H + From 5a06e6f135aae65e314ab4c2002a5923e221a8ac Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Fri, 20 Aug 2010 17:25:30 -0300 Subject: [PATCH 0150/1129] Fixed QtNetwork typesystem to work on windows. Reviewer: Luciano Wolf Hugo Parente Lima --- .../glue/qudpsocket_read_datagram_glue.cpp | 2 +- PySide/QtNetwork/typesystem_network.xml | 13 +++++++++++++ PySide/typesystem_templates.xml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp b/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp index 95ece51..db38f45 100644 --- a/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp +++ b/PySide/QtNetwork/glue/qudpsocket_read_datagram_glue.cpp @@ -1,4 +1,4 @@ - char data[%ARGUMENT_NAMES]; + PySide::AutoArrayPointer data(%ARGUMENT_NAMES); QHostAddress ha; quint16 port; diff --git a/PySide/QtNetwork/typesystem_network.xml b/PySide/QtNetwork/typesystem_network.xml index 9a56b74..80a62a4 100644 --- a/PySide/QtNetwork/typesystem_network.xml +++ b/PySide/QtNetwork/typesystem_network.xml @@ -10,6 +10,7 @@ + @@ -53,6 +54,10 @@ + + + + @@ -81,6 +86,10 @@ + + + + @@ -115,6 +124,10 @@ + + + + diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 1de06a1..b8c43ee 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -121,7 +121,7 @@ %PYARG_0 = Shiboken::makeTuple(a, b, c, d, e); - + + + From 51dd97bebcf49c36402bd3401e5f8b1bf0d1de31 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Mon, 9 Aug 2010 17:55:05 -0300 Subject: [PATCH 0322/1129] Adding several __reduce__ methods in QtCore Add QColor.__reduce__ Adding QByteArray __reduce__ Reviewer: Luciano Wolf Renato Filho --- PySide/QtCore/typesystem_core.xml | 84 +++++++++++++++++++++++++- PySide/QtGui/typesystem_gui_common.xml | 8 +++ 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index db7777e..cd46325 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -727,6 +727,14 @@ + + + + args = Py_BuildValue("(iii)", %CPPSELF.year(), %CPPSELF.month(), + %CPPSELF.day()); + + + @@ -760,14 +768,35 @@ - + + + + + + + QDate date(%1, %2, %3); + QTime time(%4, %5, %6, %7); + %0 = new %TYPE(date, time, Qt::TimeSpec(%8)); + + + + + + QDate date = %CPPSELF.date(); + QTime time = %CPPSELF.time(); + args = Py_BuildValue("(iiiiiiii)", date.year(), date.month(), + date.day(), time.hour(), + time.minute(), time.second(), + time.msec(), (int)%CPPSELF.timeSpec()); + + + - @@ -803,6 +832,14 @@ + + + + args = Py_BuildValue("(iiii)", %CPPSELF.x(), %CPPSELF.y(), + %CPPSELF.width(), %CPPSELF.height()); + + + @@ -811,6 +848,16 @@ + + + + // FIXME These functions return qreal. Will convert to double (format + // string) mess things up in other architectures? + args = Py_BuildValue("(dddd)", %CPPSELF.x(), %CPPSELF.y(), + %CPPSELF.width(), %CPPSELF.height()); + + + @@ -823,10 +870,26 @@ + + + + args = Py_BuildValue("(ii)", %CPPSELF.width(), %CPPSELF.height()); + + + + + + + // FIXME These functions return qreal. Will convert to double (format + // string) mess things up in other architectures? + args = Py_BuildValue("(dd)", %CPPSELF.width(), %CPPSELF.height()); + + + @@ -834,6 +897,14 @@ + + + + args = Py_BuildValue("(iiii)", %CPPSELF.hour(), %CPPSELF.minute(), + %CPPSELF.second(), %CPPSELF.msec()); + + + @@ -1298,6 +1369,15 @@ Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; #endif + + + + + args = Py_BuildValue("(s)", %CPPSELF.constData()); + + + + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 68d5c0d..090778f 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -678,6 +678,14 @@ PyErr_SetString(PyExc_TypeError, "QVariant must be holding a QColor"); + + + + args = Py_BuildValue("(iiii)", %CPPSELF.red(), %CPPSELF.green(), + %CPPSELF.blue(), %CPPSELF.alpha()); + + + From a3b0314c58720194613a87623461abc93469a978 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Mon, 9 Aug 2010 18:03:24 -0300 Subject: [PATCH 0323/1129] Adding deepcopy test for QtCore classes. Reviewer: Luciano Wolf Renato Filho --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/deepcopy_test.py | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/QtCore/deepcopy_test.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 30f3ff6..7225da0 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -2,6 +2,7 @@ PYSIDE_TEST(bug_278_test.py) PYSIDE_TEST(bug_332.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) +PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(deletelater_test.py) PYSIDE_TEST(duck_punching_test.py) PYSIDE_TEST(hash_test.py) diff --git a/tests/QtCore/deepcopy_test.py b/tests/QtCore/deepcopy_test.py new file mode 100644 index 0000000..9c14272 --- /dev/null +++ b/tests/QtCore/deepcopy_test.py @@ -0,0 +1,56 @@ + +import unittest +from copy import deepcopy + +from PySide.QtCore import QByteArray, QDate, QDateTime, QTime +from PySide.QtCore import Qt, QSize, QSizeF, QRect, QRectF + +class DeepCopyHelper: + + def testCopy(self): + copy = deepcopy([self.original])[0] + self.assert_(copy is not self.original) + self.assertEqual(copy, self.original) + +class QByteArrayDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QByteArray('the quick brown fox jumps over the lazy dog') + + +class QDateDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QDate(2010, 11, 22) + + +class QTimeDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QTime(11, 37, 55, 692) + + +class QDateTimeDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QDateTime(2010, 5, 18, 10, 24, 45, 223, Qt.LocalTime) + + +class QSizeDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QSize(42, 190) + + +class QSizeFDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QSizeF(42.7, 190.2) + + +class QRectDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QRect(100, 200, 300, 400) + + +class QRectFDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QRectF(100.33, 200.254, 300.321, 400.123) + + +if __name__ == '__main__': + unittest.main() From eb9b436390a71327104a884afe09b566b0dc5fbd Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Wed, 6 Oct 2010 09:26:28 -0300 Subject: [PATCH 0324/1129] Adding extra check for QPoint as a dict key Reviewer: Luciano Wolf Renato Filho --- tests/QtCore/hash_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/QtCore/hash_test.py b/tests/QtCore/hash_test.py index 6ff24f3..bf02176 100644 --- a/tests/QtCore/hash_test.py +++ b/tests/QtCore/hash_test.py @@ -10,16 +10,19 @@ class HashTest(unittest.TestCase): qdatetime = QDateTime.currentDateTime() qtime = QTime.currentTime() qurl = QUrl("http://www.pyside.org") + qpoint = QPoint(12, 42) myHash[qdate] = "QDate" myHash[qdatetime] = "QDateTime" myHash[qtime] = "QTime" myHash[qurl] = "QUrl" + myHash[qpoint] = "QPoint" self.assertEqual(myHash[qdate], "QDate") self.assertEqual(myHash[qdatetime], "QDateTime") self.assertEqual(myHash[qtime], "QTime") self.assertEqual(myHash[qurl], "QUrl") + self.assertEqual(myHash[qpoint], "QPoint") def testQPointHash(self): p1 = QPoint(12, 34) From ce09bd623b678eefddbe848b5cb44533cc648ae9 Mon Sep 17 00:00:00 2001 From: renatofilho Date: Wed, 13 Oct 2010 12:53:10 -0300 Subject: [PATCH 0325/1129] Implemented support to deep copy on QtCore. Reviewer: Luciano Wolf Lauro Neto --- PySide/QtCore/typesystem_core.xml | 195 ++++++++++++++++++++---------- PySide/typesystem_templates.xml | 50 +++++++- tests/QtCore/deepcopy_test.py | 29 ++++- 3 files changed, 203 insertions(+), 71 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index cd46325..a72abce 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -671,6 +671,14 @@ + + + + + + + + namespace PySide { template<> inline uint hash(const QLine& v) { @@ -681,6 +689,14 @@ + + + + + + + + @@ -726,13 +742,12 @@ - - - args = Py_BuildValue("(iii)", %CPPSELF.year(), %CPPSELF.month(), - %CPPSELF.day()); - + + + + @@ -767,6 +782,7 @@ %PYARG_0 = Shiboken::makeTuple(week, yearNumber); + @@ -786,24 +802,36 @@ - - QDate date = %CPPSELF.date(); - QTime time = %CPPSELF.time(); - args = Py_BuildValue("(iiiiiiii)", date.year(), date.month(), - date.day(), time.hour(), - time.minute(), time.second(), - time.msec(), (int)%CPPSELF.timeSpec()); - + + + + + + + + + + + + + + + + + + + + namespace PySide { template<> inline uint hash(const QPoint& v) { @@ -815,10 +843,26 @@ + + + + + + + + + + + + + + + + namespace PySide { template<> inline uint hash(const QRect& v) { @@ -832,35 +876,32 @@ - - - - args = Py_BuildValue("(iiii)", %CPPSELF.x(), %CPPSELF.y(), - %CPPSELF.width(), %CPPSELF.height()); - - - - - - - - - + - - // FIXME These functions return qreal. Will convert to double (format - // string) mess things up in other architectures? - args = Py_BuildValue("(dddd)", %CPPSELF.x(), %CPPSELF.y(), - %CPPSELF.width(), %CPPSELF.height()); - + + + + + + - + + + + + + + + namespace PySide { template<> inline uint hash(const QSize& v) { @@ -870,41 +911,33 @@ - - - - args = Py_BuildValue("(ii)", %CPPSELF.width(), %CPPSELF.height()); - - - - - - - // FIXME These functions return qreal. Will convert to double (format - // string) mess things up in other architectures? - args = Py_BuildValue("(dd)", %CPPSELF.width(), %CPPSELF.height()); - + + + + + + + + + + + + + + - - - - args = Py_BuildValue("(iiii)", %CPPSELF.hour(), %CPPSELF.minute(), - %CPPSELF.second(), %CPPSELF.msec()); - - - @@ -913,6 +946,14 @@ + + + + + + + + @@ -1008,7 +1049,7 @@ - + return %CPPSELF.size(); @@ -1336,6 +1377,14 @@ + + + + + + + + @@ -1343,17 +1392,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1370,14 +1443,6 @@ #endif - - - - args = Py_BuildValue("(s)", %CPPSELF.constData()); - - - - diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index e9db328..5763434 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -187,12 +187,56 @@ Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); - From 2a4ee1675dd798d5a50363fb073e6801d45a8d17 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 10 Nov 2010 21:18:47 -0300 Subject: [PATCH 0394/1129] Removed unnecessary find_package statements from pysidetest's CMakeLists.txt Reviewed by Lauro Moura Reviewed by Luciano Wolf --- tests/pysidetest/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 875ff0c..176c8cd 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -2,11 +2,7 @@ project(pysidetest) project(testbinding) cmake_minimum_required(VERSION 2.6) -find_package(Qt4 4.5.0 REQUIRED) find_package(PythonLibs REQUIRED) -find_package(GeneratorRunner 0.6 REQUIRED) -find_package(Shiboken 0.5 REQUIRED) - set(QT_USE_QTCORE 1) include(${QT_USE_FILE}) From 7013bd760e1ad46b31c019e0a11df504d6e2563e Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 11 Nov 2010 14:04:06 -0200 Subject: [PATCH 0395/1129] Fix bug#455 - "QByteArray.data() cuts data to first '\x00' char" Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 6 ++++++ tests/QtCore/qbytearray_test.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index f521607..e542ea6 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1437,6 +1437,12 @@ #endif + + + %PYARG_0 = PyString_FromStringAndSize(%CPPSELF.%FUNCTION_NAME(), %CPPSELF.size()); + + + diff --git a/tests/QtCore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py index 1c425b8..2c0ee87 100644 --- a/tests/QtCore/qbytearray_test.py +++ b/tests/QtCore/qbytearray_test.py @@ -42,6 +42,12 @@ class QByteArrayData(unittest.TestCase): url = QByteArray("http://web.openbossa.org/") self.assertEqual(url.data(), "http://web.openbossa.org/") + def testDataWithZeros(self): + s1 = "123\000321" + ba = QByteArray(s1) + s2 = ba.data() + self.assertEqual(s1, s2) + class QByteArrayOperatorAtSetter(unittest.TestCase): '''Test case for operator QByteArray[] - __setitem__''' From 655219636b1500e82d543914045f4cc7ba7db95f Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 11 Nov 2010 17:45:16 -0200 Subject: [PATCH 0396/1129] Fix bug#436 - "Using a custom QValidator generates a segfault" Reviewer: Marcelo Lira Luciano Wolf --- PySide/QtGui/typesystem_gui_common.xml | 57 +++++++++++------ tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/qvalidator_test.py | 85 ++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 20 deletions(-) create mode 100644 tests/QtGui/qvalidator_test.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 7dd9aae..59b8aa1 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1588,16 +1588,7 @@ - - - - - - - - - - + @@ -1938,16 +1929,7 @@ - - - - - - - - - - + @@ -2287,6 +2269,41 @@ + + QValidator::State %out; + + if (PySequence_Check(%PYARG_0)) { + Shiboken::AutoDecRef seq(PySequence_Fast(%PYARG_0, 0)); + int size = PySequence_Fast_GET_SIZE(seq.object()); + + if (size > 1) { + if (Shiboken::Converter<QString>::isConvertible(PySequence_Fast_GET_ITEM(seq.object(), 1))) + %1 = %CONVERTTOCPP[QString](PySequence_Fast_GET_ITEM(seq.object(), 1)); + else + qWarning("%TYPE::%FUNCTION_NAME: Second tuple element is not convertible to unicode."); + } + + if (size > 2) { + if (Shiboken::Converter<int>::isConvertible(PySequence_Fast_GET_ITEM(seq.object(), 2))) + %2 = %CONVERTTOCPP[int](PySequence_Fast_GET_ITEM(seq.object(), 2)); + else + qWarning("%TYPE::%FUNCTION_NAME: Second tuple element is not convertible to int."); + } + %PYARG_0 = PySequence_Fast_GET_ITEM(seq.object(), 0); + Py_INCREF(%PYARG_0); // we need to incref, because "%PYARG_0 = ..." will decref the tuple and the tuple will be decrefed again at the end of this scope. + } + + // check retrun value + if (Shiboken::Converter<QValidator::State>::isConvertible(%PYARG_0)) { + %out = %CONVERTTOCPP[QValidator::State](%PYARG_0); + } else { + PyErr_Format(PyExc_TypeError, "Invalid return value in function %s, expected %s, got %s.", + "QValidator.validate", + "PySide.QtGui.QValidator.State, (PySide.QtGui.QValidator.State,), (PySide.QtGui.QValidator.State, unicode) or (PySide.QtGui.QValidator.State, unicode, int)", + pyResult->ob_type->tp_name); + return QValidator::State(); + } + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 7ff2f7e..9086829 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -71,6 +71,7 @@ PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) PYSIDE_TEST(qvariant_test.py) +PYSIDE_TEST(qvalidator_test.py) PYSIDE_TEST(qwidget_setlayout_test.py) PYSIDE_TEST(qwidget_test.py) PYSIDE_TEST(reference_count_test.py) diff --git a/tests/QtGui/qvalidator_test.py b/tests/QtGui/qvalidator_test.py new file mode 100644 index 0000000..52dbc8b --- /dev/null +++ b/tests/QtGui/qvalidator_test.py @@ -0,0 +1,85 @@ +from PySide.QtCore import * +from PySide.QtGui import * + +import unittest +from helper import UsesQApplication + +class MyValidator1(QValidator): + def fixUp(self, input): + return "fixed" + + def validate(self, input, pos): + return (QValidator.Acceptable, "fixed", 1) + +class MyValidator2(QValidator): + def fixUp(self, input): + return "fixed" + + def validate(self, input, pos): + return (QValidator.Acceptable, "fixed") + +class MyValidator3(QValidator): + def fixUp(self, input): + return "fixed" + + def validate(self, input, pos): + return (QValidator.Acceptable,) + +class MyValidator4(QValidator): + def fixUp(self, input): + return "fixed" + + def validate(self, input, pos): + return QValidator.Acceptable + +class QValidatorTest(UsesQApplication): + def testValidator1(self): + line = QLineEdit() + line.setValidator(MyValidator1()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "fixed") + self.assertEqual(line.cursorPosition(), 1) + + def testValidator2(self): + line = QLineEdit() + line.setValidator(MyValidator2()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "fixed") + self.assertEqual(line.cursorPosition(), 3) + + def testValidator3(self): + line = QLineEdit() + line.setValidator(MyValidator3()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "foo") + self.assertEqual(line.cursorPosition(), 3) + + def testValidator4(self): + line = QLineEdit() + line.setValidator(MyValidator4()) + line.show() + line.setText("foo") + + QTimer.singleShot(0, line.close) + self.app.exec_() + + self.assertEqual(line.text(), "foo") + self.assertEqual(line.cursorPosition(), 3) + +if __name__ == '__main__': + unittest.main() From 178f81aa70711876fe492431ae32afa3538cf460 Mon Sep 17 00:00:00 2001 From: renatofilho Date: Fri, 12 Nov 2010 08:52:09 -0300 Subject: [PATCH 0397/1129] Added PySide attributes to specify current version, and Qt version. Fixes bug: #454 Reviewer: Marcelo Lira Luciano Wolf --- PySide/CMakeLists.txt | 4 ++-- PySide/QtCore/glue/qt_version.cpp | 5 +++++ PySide/QtCore/typesystem_core.xml | 5 +---- PySide/__init__.py | 2 -- PySide/__init__.py.in | 5 +++++ tests/pysidetest/CMakeLists.txt | 1 + tests/pysidetest/version_test.py | 17 +++++++++++++++++ 7 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 PySide/QtCore/glue/qt_version.cpp delete mode 100644 PySide/__init__.py create mode 100644 PySide/__init__.py.in create mode 100644 tests/pysidetest/version_test.py diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index c4aaf64..d7030d8 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -8,8 +8,8 @@ include(PySideModules) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in" "${CMAKE_CURRENT_BINARY_DIR}/global.h" @ONLY) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" - "${CMAKE_BINARY_DIR}/PySide/__init__.py") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py.in" + "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" @ONLY) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/private.py" "${CMAKE_BINARY_DIR}/PySide/private.py") diff --git a/PySide/QtCore/glue/qt_version.cpp b/PySide/QtCore/glue/qt_version.cpp new file mode 100644 index 0000000..66f8c00 --- /dev/null +++ b/PySide/QtCore/glue/qt_version.cpp @@ -0,0 +1,5 @@ +QList version = QByteArray(qVersion()).split('.'); +PyObject *pyQtVersion = Shiboken::makeTuple(version[0].toInt(), version[1].toInt(), version[2].toInt()); + +PyModule_AddStringConstant(module, "__version__", qVersion()); +PyModule_AddObject(module, "__version_info__", pyQtVersion); diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index e542ea6..c5d3ac5 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -596,10 +596,7 @@ - - PyModule_AddIntConstant(module, "QT_VERSION", QT_VERSION); - PyModule_AddStringConstant(module, "QT_VERSION_STR", QT_VERSION_STR); - + diff --git a/PySide/__init__.py b/PySide/__init__.py deleted file mode 100644 index c93c5df..0000000 --- a/PySide/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript'] -import private diff --git a/PySide/__init__.py.in b/PySide/__init__.py.in new file mode 100644 index 0000000..f931fad --- /dev/null +++ b/PySide/__init__.py.in @@ -0,0 +1,5 @@ +__all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript'] +import private + +__version__ = "@BINDING_API_VERSION@" +__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@) diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 176c8cd..d983ef8 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -63,4 +63,5 @@ add_dependencies(testbinding pyside QtCore libpyside pysidetest) PYSIDE_TEST(homonymoussignalandmethod_test.py) +PYSIDE_TEST(version_test.py) diff --git a/tests/pysidetest/version_test.py b/tests/pysidetest/version_test.py new file mode 100644 index 0000000..cb2b399 --- /dev/null +++ b/tests/pysidetest/version_test.py @@ -0,0 +1,17 @@ +#!/usr/bin/python + +import unittest +from PySide import __version_info__, __version__, QtCore + +class CheckForVariablesTest(unittest.TestCase): + def testVesions(self): + self.assert_(__version_info__ >= (1, 0, 0)) + self.assert_(__version_info__ < (99, 99, 99)) + self.assert_(__version__) + + self.assert_(QtCore.__version_info__ >= (4, 5, 0)) + self.assert_(QtCore.__version__) + +if __name__ == '__main__': + unittest.main() + From 968d376c5dde8e93d59867070fb7fd250c59aad3 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Fri, 12 Nov 2010 18:50:40 -0300 Subject: [PATCH 0398/1129] Fix __init__.py and private.py install command. Reviewer: Luciano Wolf Reviewer: Renato Filho --- PySide/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index d7030d8..3b85e3d 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -1,5 +1,5 @@ project(pyside) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" "${CMAKE_CURRENT_SOURCE_DIR}/private.py" +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/__init__.py" "${CMAKE_CURRENT_BINARY_DIR}/private.py" DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside_SUFFIX}") include(PySideModules) From d2e204f3df1c80112cf42bb117db81299f93f8cf Mon Sep 17 00:00:00 2001 From: renatofilho Date: Fri, 12 Nov 2010 19:09:44 -0300 Subject: [PATCH 0399/1129] Removed invalid test. --- tests/QtCore/CMakeLists.txt | 1 - tests/QtCore/qqtversion_test.py | 18 ------------------ 2 files changed, 19 deletions(-) delete mode 100644 tests/QtCore/qqtversion_test.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index f4f38a6..53388d1 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -47,7 +47,6 @@ PYSIDE_TEST(qobject_timer_event_test.py) PYSIDE_TEST(qobject_tr_as_instance_test.py) PYSIDE_TEST(qpoint_test.py) PYSIDE_TEST(qprocess_test.py) -PYSIDE_TEST(qqtversion_test.py) PYSIDE_TEST(qrect_test.py) PYSIDE_TEST(qresource_test.py) PYSIDE_TEST(qsize_test.py) diff --git a/tests/QtCore/qqtversion_test.py b/tests/QtCore/qqtversion_test.py deleted file mode 100644 index 344de69..0000000 --- a/tests/QtCore/qqtversion_test.py +++ /dev/null @@ -1,18 +0,0 @@ - -import unittest - -from PySide import QtCore - - -class QQtVersionTest(unittest.TestCase): - '''Tests for QtCore.QT_VERSION and QT_VERSION_STR''' - - def testVersion(self): - self.assert_(hex(QtCore.QT_VERSION) > 0x40500) - - def testVersionStr(self): - self.assert_(QtCore.QT_VERSION_STR) - - -if __name__ == '__main__': - unittest.main() From bd3efd2a0f39c7f0ec7be88672e30c332ac1d1fe Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 16 Nov 2010 13:12:21 -0200 Subject: [PATCH 0400/1129] Fix bug#471 - "QtCore.QObject is missing 'thread' method" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Luciano Wolf Renato Araújo --- PySide/QtCore/typesystem_core.xml | 1 - tests/QtCore/qthread_test.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index c5d3ac5..b5243c6 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1167,7 +1167,6 @@ - diff --git a/tests/QtCore/qthread_test.py b/tests/QtCore/qthread_test.py index 410afb9..dc99c8e 100644 --- a/tests/QtCore/qthread_test.py +++ b/tests/QtCore/qthread_test.py @@ -17,6 +17,7 @@ class Dummy(QThread): def run(self): #Start-quit sequence + self.qobj = QObject() mutex.lock() self.called = True mutex.unlock() @@ -70,6 +71,7 @@ class QThreadSimpleCase(UsesQCoreApplication): QTimer.singleShot(1000, self.abort_application) self.app.exec_() + self.assertEqual(obj.qobj.thread(), obj) # test QObject.thread() method self.assert_(self.called) if __name__ == '__main__': From 5a8efeb9df4271b0e1ec47bf231d2f23141d2375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl?= Date: Tue, 16 Nov 2010 15:06:43 -0200 Subject: [PATCH 0401/1129] Fix bug#470 - "Object::connect: No such signal QTimer::"timeout()" when using QTimer::singleShot" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Hugo Parente Renato Araújo --- 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 b5243c6..b048bf0 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1944,7 +1944,7 @@ // invalidate to avoid use of python object Shiboken::BindingManager::instance().destroyWrapper((SbkObject*)pyTimer); timer->setSingleShot(true); - timer->connect(timer, SIGNAL("timeout()"), timer, SLOT("deleteLater()")); + timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); timer->start(%1); From 16913eedcec8c71b129dfcb029e0eb0fc50bb2a1 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Wed, 17 Nov 2010 18:58:39 -0300 Subject: [PATCH 0402/1129] Fix setLayout method that was causing segfault when itemAt wasn't implemented. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Hugo Parente Renato Araújo --- PySide/QtGui/glue/qlayout_help_functions.h | 8 ++++++-- PySide/QtGui/glue/qwidget_glue.h | 22 +++++++++++--------- PySide/QtGui/typesystem_gui_common.xml | 1 + tests/QtGui/qlayout_test.py | 24 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h index 0a6dd0e..452dbc1 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.h @@ -28,7 +28,7 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget) inline void addLayoutOwnership(QLayout* layout, QLayout* other) { - //transfer all children widgetes from other to layout parent widget + //transfer all children widgets from other to layout parent widget QWidget* parent = layout->parentWidget(); if (!parent) { //keep the reference while the layout is orphan @@ -39,7 +39,11 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other) } for (int i=0, i_max=other->count(); i < i_max; i++) { - addLayoutOwnership(layout, other->itemAt(i)); + QLayoutItem* item = layout->itemAt(i); + if (PyErr_Occurred()) + return; + + addLayoutOwnership(layout, item); } Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h index 0339e89..d067d9f 100644 --- a/PySide/QtGui/glue/qwidget_glue.h +++ b/PySide/QtGui/glue/qwidget_glue.h @@ -12,21 +12,20 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) { Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); - for (int i=0; i < layout->count(); i++) - { - QLayoutItem *item = layout->itemAt(i); - QWidget *w = item->widget(); - if (w) - { + for (int i=0; i < layout->count(); i++) { + QLayoutItem* item = layout->itemAt(i); + if (PyErr_Occurred()) + return; + + QWidget* w = item->widget(); + if (w) { QWidget* pw = w->parentWidget(); if (pw != parent) { Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(w)); Shiboken::setParent(pyParent, pyChild); } - } - else - { - QLayout *l = item->layout(); + } else { + QLayout* l = item->layout(); if (l) qwidgetReparentLayout(parent, l); } @@ -58,6 +57,9 @@ static inline void qwidgetSetLayout(QWidget *self, QLayout *layout) if (oldParent != self) { qwidgetReparentLayout(self, layout); + if (PyErr_Occurred()) + return; + self->setLayout(layout); } } diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 59b8aa1..04ad22a 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3371,6 +3371,7 @@ qwidgetSetLayout(%CPPSELF, %1); + // %FUNCTION_NAME() - disable generation of function call. diff --git a/tests/QtGui/qlayout_test.py b/tests/QtGui/qlayout_test.py index 88c37aa..72c6d17 100644 --- a/tests/QtGui/qlayout_test.py +++ b/tests/QtGui/qlayout_test.py @@ -27,7 +27,22 @@ class MyLayout(QLayout): def add(self, item): self._list.append(item) +class MissingItemAtLayout(QLayout): + def __init__(self, parent=None): + QLayout.__init__(self, parent) + self._list = [] + def addItem(self, item): + self.add(item) + + def addWidget(self, widget): + self.add(QWidgetItem(widget)) + + def count(self): + return len(self._list) + + def add(self, item): + self._list.append(item) #Test if a layout implemented in python, the QWidget.setLayout works #fine because this implement som layout functions used in glue code of @@ -71,5 +86,14 @@ class QLayoutTest(UsesQApplication): self.assertEqual(sys.getrefcount(b), 2) + def testMissingFunctions(self): + w = QWidget() + b = QPushButton("test") + l = MissingItemAtLayout() + + l.addWidget(b) + + self.assertRaises(RuntimeError, w.setLayout, l) + if __name__ == '__main__': unittest.main() From 090e4a6525c5469b2f257eb978ae74b1b8df5ffc Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 18 Nov 2010 17:38:43 -0200 Subject: [PATCH 0403/1129] Remove function deleteDynamicQMetaObject, use Shiboken::callCppDestructor instead. --- libpyside/dynamicqmetaobject.cpp | 5 ----- libpyside/dynamicqmetaobject.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp index e9a162d..adb05d7 100644 --- a/libpyside/dynamicqmetaobject.cpp +++ b/libpyside/dynamicqmetaobject.cpp @@ -578,8 +578,3 @@ void DynamicQMetaObject::DynamicQMetaObjectPrivate::updateMetaObject(QMetaObject metaObj->d.data = data; metaObj->d.stringdata = stringData; } - -void PySide::deleteDynamicQMetaObject(void* data) -{ - delete reinterpret_cast(data); -} diff --git a/libpyside/dynamicqmetaobject.h b/libpyside/dynamicqmetaobject.h index d61ecad..8bd0282 100644 --- a/libpyside/dynamicqmetaobject.h +++ b/libpyside/dynamicqmetaobject.h @@ -52,7 +52,5 @@ private: DynamicQMetaObjectPrivate* m_d; }; -PYSIDE_API void deleteDynamicQMetaObject(void* data); - } #endif From 71d279c0406030faa97927f510e2b2f802daf794 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 18 Nov 2010 17:42:00 -0200 Subject: [PATCH 0404/1129] Uses QByteArray instead of QString to avoid data copy. Reviewer: Luciano Wolf Lauro Moura --- libpyside/dynamicqmetaobject.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/libpyside/dynamicqmetaobject.cpp b/libpyside/dynamicqmetaobject.cpp index adb05d7..14fbe86 100644 --- a/libpyside/dynamicqmetaobject.cpp +++ b/libpyside/dynamicqmetaobject.cpp @@ -136,20 +136,14 @@ static bool isQRealType(const char *type) /* * Avoid API break keep this on cpp */ -static int maxSlotsCount(const QString& className) +static int maxSlotsCount(const QByteArray& className) { - int maxSlots = MAX_SLOTS_COUNT; - if (className == GLOBAL_RECEIVER_CLASS_NAME) - maxSlots = MAX_GLOBAL_SIGNALS_COUNT; - return maxSlots; + return className == GLOBAL_RECEIVER_CLASS_NAME ? MAX_GLOBAL_SIGNALS_COUNT : MAX_SLOTS_COUNT; } -static int maxSignalsCount(const QString& className) +static int maxSignalsCount(const QByteArray& className) { - int maxSignals = MAX_SIGNALS_COUNT; - if (className == GLOBAL_RECEIVER_CLASS_NAME) - maxSignals = MAX_GLOBAL_SIGNALS_COUNT; - return maxSignals; + return className == GLOBAL_RECEIVER_CLASS_NAME ? MAX_GLOBAL_SIGNALS_COUNT : MAX_SIGNALS_COUNT; } uint PropertyData::flags() const @@ -296,7 +290,7 @@ DynamicQMetaObject::DynamicQMetaObject(const char* className, const QMetaObject* d.stringdata = 0; d.data = 0; d.extradata = 0; - m_d->m_className = QByteArray(className); + m_d->m_className = className; m_d->updateMetaObject(this); } From dd8b0fcfe41222be0141e2b717bb6f6b4c6f7107 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Sun, 14 Nov 2010 21:02:34 -0300 Subject: [PATCH 0405/1129] Created unit test for bug 462. Reviewer: Hugo Parente Lima Luciano Wolf --- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_462.py | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/QtCore/bug_462.py diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 53388d1..b73a1ba 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -2,6 +2,7 @@ PYSIDE_TEST(bug_278_test.py) PYSIDE_TEST(bug_332.py) PYSIDE_TEST(bug_408.py) PYSIDE_TEST(bug_428.py) +PYSIDE_TEST(bug_462.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtCore/bug_462.py b/tests/QtCore/bug_462.py new file mode 100644 index 0000000..feb75c7 --- /dev/null +++ b/tests/QtCore/bug_462.py @@ -0,0 +1,43 @@ +import unittest +import sys + +from PySide.QtCore import QObject, QCoreApplication, QEvent, QThread + +class MyEvent(QEvent): + def __init__(self,i): + super(MyEvent,self).__init__(QEvent.Type(QEvent.User + 100 )) + self.i = i + +class MyThread (QThread): + def __init__(self,owner): + super(MyThread,self).__init__() + self.owner=owner; + + def run(self): + for i in xrange(3): + e=MyEvent(i); + QCoreApplication.postEvent(self.owner,e) + +class MyBaseObject(QObject): + def __init__(self): + QObject.__init__(self) + self.events = [] + self.t = MyThread(self) + self.t.start() + + def customEvent(self, event): + self.events.append(event) + if len(self.events) == 3: + self.app.quit() + + +class CheckForEventsTypes(unittest.TestCase): + def testTypes(self): + o = MyBaseObject() + o.app = QCoreApplication(sys.argv) + o.app.exec_() + for e in o.events: + self.assert_(isinstance(e, MyEvent)) + +if __name__ == '__main__': + unittest.main() From 43e499a4faf7c7cacdba026bc87eda24a7d02e23 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 17 Nov 2010 19:43:33 -0300 Subject: [PATCH 0406/1129] Fixed unit test to avoid exit with thread running. Reviewer: Hugo Parente Lima Luciano Wolf --- tests/QtCore/bug_462.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/QtCore/bug_462.py b/tests/QtCore/bug_462.py index feb75c7..44048bb 100644 --- a/tests/QtCore/bug_462.py +++ b/tests/QtCore/bug_462.py @@ -28,6 +28,7 @@ class MyBaseObject(QObject): def customEvent(self, event): self.events.append(event) if len(self.events) == 3: + self.t.wait() self.app.quit() @@ -38,6 +39,7 @@ class CheckForEventsTypes(unittest.TestCase): o.app.exec_() for e in o.events: self.assert_(isinstance(e, MyEvent)) + o.app = None if __name__ == '__main__': unittest.main() From 098946263932e115bdbca17eb51c3a27848435e2 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 17 Nov 2010 19:55:43 -0300 Subject: [PATCH 0407/1129] Fixed recursive call on duck punching test. Reviewer: Hugo Parente Lima Luciano Wolf --- tests/QtCore/duck_punching_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/QtCore/duck_punching_test.py b/tests/QtCore/duck_punching_test.py index 880a8e4..e1b9f7f 100644 --- a/tests/QtCore/duck_punching_test.py +++ b/tests/QtCore/duck_punching_test.py @@ -32,7 +32,6 @@ class TestDuckPunchingOnQObjectInstance(UsesQCoreApplication): parent = QObject() def childEvent(obj, event): self.duck_childEvent_called = True - QObject.childEvent(obj, event) parent.childEvent = types.MethodType(childEvent, parent, QObject) child = QObject() child.setParent(parent) From 5e0550446c3546beb4a7076a80a7475b394567f4 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 18 Nov 2010 11:02:03 -0300 Subject: [PATCH 0408/1129] Updated to new shiboken API. Reviewer: Hugo Parente Lima Luciano Wolf --- PySide/QtCore/typesystem_core.xml | 15 ++++++------- PySide/QtGui/glue/qlayout_help_functions.h | 6 ++--- PySide/QtGui/glue/qwidget_glue.h | 6 ++--- PySide/QtGui/typesystem_gui_common.xml | 26 +++++++++++----------- PySide/QtUiTools/glue/uitools_loadui.h | 2 +- PySide/QtWebKit/typesystem_webkit.xml | 2 +- PySide/typesystem_templates.xml | 6 ++--- libpyside/pyside.cpp | 4 +--- plugins/customwidget.cpp | 4 ++-- 9 files changed, 34 insertions(+), 37 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index b048bf0..83fd2ed 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1129,7 +1129,7 @@ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%CPPSELF.%FUNCTION_NAME()); - + @@ -1941,8 +1941,7 @@ %PYARG_2, %3) ); - // invalidate to avoid use of python object - Shiboken::BindingManager::instance().destroyWrapper((SbkObject*)pyTimer); + Shiboken::Wrapper::invalidate((SbkObject*)pyTimer); timer->setSingleShot(true); timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); timer->start(%1); @@ -1952,7 +1951,7 @@ // %FUNCTION_NAME() - disable generation of c++ function call Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); - PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + PyObject *pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); timer->setSingleShot(true); @@ -1980,7 +1979,7 @@ pyargs[1]) ); } - Shiboken::BindingManager::instance().destroyWrapper((SbkObject*)pyTimer); + Shiboken::Wrapper::invalidate((SbkObject*)pyTimer); timer->start(%1); @@ -2568,7 +2567,7 @@ for(int counter = 0; counter < %CPPSELF.animationCount(); ++counter ) { PyObject* obj = %CONVERTTOPYTHON[QAbstractAnimation*](%CPPSELF.animationAt(counter)); - Shiboken::setParent(NULL, obj); + Shiboken::Wrapper::setParent(NULL, obj); Py_DECREF(obj); } %CPPSELF.clear(); @@ -2722,7 +2721,7 @@ %PYARG_0 = PySet_New(0); foreach(QAbstractState* abs_state, %CPPSELF.configuration()) { Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractState*](abs_state)); - Shiboken::setParent(self, obj); + Shiboken::Wrapper::setParent(self, obj); PySet_Add(%PYARG_0, obj); } @@ -2733,7 +2732,7 @@ %PYARG_0 = PyList_New(0); foreach(QAbstractAnimation* abs_anim, %CPPSELF.defaultAnimations()) { Shiboken::AutoDecRef obj(%CONVERTTOPYTHON[QAbstractAnimation*](abs_anim)); - Shiboken::setParent(self, obj); + Shiboken::Wrapper::setParent(self, obj); PyList_Append(%PYARG_0, obj); } diff --git a/PySide/QtGui/glue/qlayout_help_functions.h b/PySide/QtGui/glue/qlayout_help_functions.h index 452dbc1..8d899ea 100644 --- a/PySide/QtGui/glue/qlayout_help_functions.h +++ b/PySide/QtGui/glue/qlayout_help_functions.h @@ -22,7 +22,7 @@ inline void addLayoutOwnership(QLayout* layout, QWidget* widget) } else { Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(parent)); Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(widget)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } } @@ -48,7 +48,7 @@ inline void addLayoutOwnership(QLayout* layout, QLayout* other) Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(other)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } @@ -65,7 +65,7 @@ inline void addLayoutOwnership(QLayout* layout, QLayoutItem* item) Shiboken::AutoDecRef pyParent(Shiboken::Converter::toPython(layout)); Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(item)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } #endif diff --git a/PySide/QtGui/glue/qwidget_glue.h b/PySide/QtGui/glue/qwidget_glue.h index d067d9f..33e8a7f 100644 --- a/PySide/QtGui/glue/qwidget_glue.h +++ b/PySide/QtGui/glue/qwidget_glue.h @@ -22,7 +22,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) QWidget* pw = w->parentWidget(); if (pw != parent) { Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(w)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); } } else { QLayout* l = item->layout(); @@ -32,7 +32,7 @@ static inline void qwidgetReparentLayout(QWidget *parent, QLayout *layout) } Shiboken::AutoDecRef pyChild(Shiboken::Converter::toPython(layout)); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); //remove previous references Shiboken::keepReference(reinterpret_cast(pyChild.object()), qPrintable(retrieveObjectName(pyChild)), Py_None); } @@ -47,7 +47,7 @@ static inline void qwidgetSetLayout(QWidget *self, QLayout *layout) if (oldParent->isWidgetType()) { // remove old parent policy Shiboken::AutoDecRef pyLayout(Shiboken::Converter::toPython(layout)); - Shiboken::setParent(Py_None, pyLayout); + Shiboken::Wrapper::setParent(Py_None, pyLayout); } else { PyErr_Format(PyExc_RuntimeError, "QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent", qPrintable(layout->objectName()), self->metaObject()->className(), qPrintable(self->objectName())); diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 04ad22a..ca7bc27 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1621,7 +1621,7 @@ - BindingManager::instance().transferOwnershipToCpp(%PYARG_2); + Shiboken::Wrapper::releaseOwnership(%PYARG_2); @@ -1955,7 +1955,7 @@ Shiboken::AutoDecRef result(PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(activated()), %PYARG_3)); if (!result.isNull()) - Shiboken::setParent(%PYARG_2, %PYSELF); + Shiboken::Wrapper::setParent(%PYARG_2, %PYSELF); @@ -2018,7 +2018,7 @@ QStandardItem* _i = %CPPSELF->child(%1, %2); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } @@ -2031,7 +2031,7 @@ QStandardItem* _i = %CPPSELF->child(%1); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } @@ -2170,7 +2170,7 @@ QWidget *_widget = %CPPSELF.widget(%1); if (_widget) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](_widget)); - Shiboken::setParent(0, pyWidget); + Shiboken::Wrapper::setParent(0, pyWidget); } @@ -3328,7 +3328,7 @@ QStyle *appStyle = qApp->style(); if (appStyle == myStyle) { Shiboken::AutoDecRef pyApp(%CONVERTTOPYTHON[QApplication*](qApp)); - Shiboken::setParent(pyApp, %PYARG_0); + Shiboken::Wrapper::setParent(pyApp, %PYARG_0); Shiboken::Wrapper::releaseOwnership(%PYARG_0); } else { Shiboken::keepReference(reinterpret_cast<SbkObject*>(%PYSELF), "__style__", %PYARG_0); @@ -3586,7 +3586,7 @@ QWidget* tab = %CPPSELF.widget(%1); if (tab) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](tab)); - Shiboken::setParent(0, pyWidget); + Shiboken::Wrapper::setParent(0, pyWidget); %CPPSELF.%FUNCTION_NAME(%1); } @@ -3595,7 +3595,7 @@ for (int i=0; i < %CPPSELF.count(); i++) { Shiboken::AutoDecRef pyWidget(%CONVERTTOPYTHON[QWidget*](%CPPSELF.widget(i))); - Shiboken::setParent(0, pyWidget); + Shiboken::Wrapper::setParent(0, pyWidget); } %CPPSELF.%FUNCTION_NAME(); @@ -3853,7 +3853,7 @@ QStandardItem* _i = %CPPSELF->item(%1, %2); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } @@ -3866,7 +3866,7 @@ QStandardItem* _i = %CPPSELF->item(%1); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } @@ -3885,7 +3885,7 @@ QStandardItem* _i = %CPPSELF->verticalHeaderItem(%1); if (_i) { PyObject* _pyI = %CONVERTTOPYTHON[QStandardItem*](_i); - Shiboken::setParent(0, _pyI); + Shiboken::Wrapper::setParent(0, _pyI); } @@ -3935,7 +3935,7 @@ QList<QStandardItem *> ri = %CPPSELF.takeRow(0); PyObject *pyResult = %CONVERTTOPYTHON[QList<QStandardItem * >](ri); - Shiboken::setParent(Py_None, pyResult); + Shiboken::Wrapper::setParent(Py_None, pyResult); Py_XDECREF(pyResult); } @@ -4554,7 +4554,7 @@ - Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1); + Shiboken::Wrapper::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_1); diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.h index 8f6df63..302c3e7 100644 --- a/PySide/QtUiTools/glue/uitools_loadui.h +++ b/PySide/QtUiTools/glue/uitools_loadui.h @@ -20,7 +20,7 @@ _populate_parent(PyObject* pyParent, QObject *parent) if (!has_attr) PyObject_SetAttrString(pyParent, qPrintable(name), pyChild); - Shiboken::setParent(pyParent, pyChild); + Shiboken::Wrapper::setParent(pyParent, pyChild); _populate_parent(pyChild, qobject_cast(child)); } } diff --git a/PySide/QtWebKit/typesystem_webkit.xml b/PySide/QtWebKit/typesystem_webkit.xml index b56a909..9ec7c75 100644 --- a/PySide/QtWebKit/typesystem_webkit.xml +++ b/PySide/QtWebKit/typesystem_webkit.xml @@ -41,7 +41,7 @@ SbkObject* _pyReturn = reinterpret_cast<SbkObject*>(%PYARG_0); if (!Shiboken::Wrapper::hasParentInfo(_pyReturn)) - Shiboken::setParent(%PYSELF, %PYARG_0); + Shiboken::Wrapper::setParent(%PYSELF, %PYARG_0); diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 968195f..6bc814d 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -23,9 +23,9 @@ $CHILD_TYPE* oldChild = %CPPSELF.$FUNCTION_GET_OLD(); if (oldChild) { Shiboken::AutoDecRef pyChild(%CONVERTTOPYTHON[$CHILD_TYPE*](oldChild)); - Shiboken::setParent(NULL, pyChild); + Shiboken::Wrapper::setParent(NULL, pyChild); } - Shiboken::setParent(%PYSELF, $PYARG); + Shiboken::Wrapper::setParent(%PYSELF, $PYARG); @@ -184,7 +184,7 @@ @@ -155,8 +155,8 @@ @@ -183,8 +183,8 @@ + + + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index b5bffe7..8ec3cdd 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -71,6 +71,7 @@ PYSIDE_TEST(setprop_on_ctor_test.py) PYSIDE_TEST(static_method_test.py) PYSIDE_TEST(static_protected_methods_test.py) PYSIDE_TEST(thread_signals_test.py) +PYSIDE_TEST(tr_noop_test.py) PYSIDE_TEST(translation_test.py) PYSIDE_TEST(unaryoperator_test.py) PYSIDE_TEST(unicode_test.py) diff --git a/tests/QtCore/tr_noop_test.py b/tests/QtCore/tr_noop_test.py new file mode 100644 index 0000000..92029e0 --- /dev/null +++ b/tests/QtCore/tr_noop_test.py @@ -0,0 +1,48 @@ +import unittest + +import sys +from PySide.QtCore import QT_TR_NOOP, QT_TR_NOOP_UTF8 +from PySide.QtCore import QT_TRANSLATE_NOOP, QT_TRANSLATE_NOOP3, QT_TRANSLATE_NOOP_UTF8 + +class QtTrNoopTest(unittest.TestCase): + + def setUp(self): + self.txt = 'Cthulhu fhtag!' + + def tearDown(self): + del self.txt + + def testQtTrNoop(self): + refcnt = sys.getrefcount(self.txt) + result = QT_TR_NOOP(self.txt) + self.assertEqual(result, self.txt) + self.assertEqual(sys.getrefcount(result), refcnt + 1) + + def testQtTrNoopUtf8(self): + refcnt = sys.getrefcount(self.txt) + result = QT_TR_NOOP_UTF8(self.txt) + self.assertEqual(result, self.txt) + self.assertEqual(sys.getrefcount(result), refcnt + 1) + + def testQtTranslateNoop(self): + refcnt = sys.getrefcount(self.txt) + result = QT_TRANSLATE_NOOP(None, self.txt) + self.assertEqual(result, self.txt) + self.assertEqual(sys.getrefcount(result), refcnt + 1) + + def testQtTranslateNoopUtf8(self): + refcnt = sys.getrefcount(self.txt) + result = QT_TRANSLATE_NOOP_UTF8(self.txt) + self.assertEqual(result, self.txt) + self.assertEqual(sys.getrefcount(result), refcnt + 1) + + def testQtTranslateNoop3(self): + refcnt = sys.getrefcount(self.txt) + result = QT_TRANSLATE_NOOP3(None, self.txt, None) + self.assertEqual(result, self.txt) + self.assertEqual(sys.getrefcount(result), refcnt + 1) + + +if __name__ == '__main__': + unittest.main() + From 3e66025bbb698ddd491d502bbb9f9483b17d82a0 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 20 Dec 2010 17:49:54 -0300 Subject: [PATCH 0475/1129] Fixed indentation mistakes. Reviewer: Marcelo Lira 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 639a0ab..060f4a6 100644 --- a/cmake/Macros/PySideModules.cmake +++ b/cmake/Macros/PySideModules.cmake @@ -77,7 +77,7 @@ macro(check_qt_class module class global_sources) file(WRITE ${SRC_FILE} "#include <${include_file}>\n" "#include \n" - "${NAMESPACE_USE}\n" + "${NAMESPACE_USE}\n" "int main() { typeid(${class}); }\n" ) try_compile(Q_WORKS ${CMAKE_BINARY_DIR} From 0d0cb0753edea1e209742c5777ca024b7a58b83a Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 20 Dec 2010 17:50:43 -0300 Subject: [PATCH 0476/1129] Added QSslCertificate to QtNetwork module. Reviewer: Marcelo Lira Hugo Parente Lima --- PySide/QtNetwork/CMakeLists.txt | 1 + PySide/QtNetwork/typesystem_network.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PySide/QtNetwork/CMakeLists.txt b/PySide/QtNetwork/CMakeLists.txt index 3afa0cf..0656c31 100644 --- a/PySide/QtNetwork/CMakeLists.txt +++ b/PySide/QtNetwork/CMakeLists.txt @@ -44,6 +44,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtNetwork/qurlinfo_wrapper.cpp ${QtNetwork_47_SRC} ) +check_qt_class(QtNetwork QSslCertificate QtNetwork_SRC) check_qt_class(QtNetwork QSslCipher QtNetwork_SRC) check_qt_class(QtNetwork QSslConfiguration QtNetwork_SRC) check_qt_class(QtNetwork QSslError QtNetwork_SRC) diff --git a/PySide/QtNetwork/typesystem_network.xml b/PySide/QtNetwork/typesystem_network.xml index e608786..69d1787 100644 --- a/PySide/QtNetwork/typesystem_network.xml +++ b/PySide/QtNetwork/typesystem_network.xml @@ -33,8 +33,8 @@ - + From ed10989ff23d95d20f361944a6deffbeced63a0d Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 20 Dec 2010 18:55:02 -0300 Subject: [PATCH 0477/1129] Fixed QtUiTools plugin. Removed use of static QString to store the class name. Fix bug #533. Reviewer: Marcelo Lira Hugo Parente Lima --- plugins/customwidget.cpp | 7 ++----- plugins/customwidget.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/plugins/customwidget.cpp b/plugins/customwidget.cpp index 74b07dc..9a3e6f2 100644 --- a/plugins/customwidget.cpp +++ b/plugins/customwidget.cpp @@ -35,6 +35,7 @@ PyCustomWidget::PyCustomWidget(PyObject* objectType) : m_data(new PyCustomWidgetPrivate()) { m_data->pyObject = objectType; + m_name = QString(reinterpret_cast(objectType)->tp_name); } PyCustomWidget::~PyCustomWidget() @@ -73,11 +74,7 @@ QString PyCustomWidget::includeFile() const QString PyCustomWidget::name() const { - static QString objectName; - if (objectName.isEmpty()) { - objectName = QString(reinterpret_cast(m_data->pyObject)->tp_name); - } - return objectName; + return m_name; } QString PyCustomWidget::toolTip() const diff --git a/plugins/customwidget.h b/plugins/customwidget.h index e4eb76d..00393a1 100644 --- a/plugins/customwidget.h +++ b/plugins/customwidget.h @@ -52,7 +52,7 @@ public: private: QScopedPointer m_data; - + QString m_name; }; #endif From 45edcc54a6215e161cc0c176daf5e3b4dc3aeaff Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 21 Dec 2010 17:26:50 -0300 Subject: [PATCH 0478/1129] Used argument '-a' during the call of xvfb command. This argument allow the xvfb to find a free server number during the execution. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db2bb3a..5209bab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ option(USE_XVFB "Uses xvfb-run with the unit tests to avoid QtGui tests popping if(USE_XVFB) find_program(XVFB_RUN NAMES xvfb-run) if (NOT ${XVFB_RUN} MATCHES "XVFB_RUN-NOTFOUND") - set(XVFB_EXEC ${XVFB_RUN}) + set(XVFB_EXEC ${XVFB_RUN} -a) message(STATUS "Using xvfb-run to perform QtGui tests.") endif() endif() From cebdd1f4dcb057436878b60295684c24cb09f1d9 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 22 Dec 2010 10:17:21 -0300 Subject: [PATCH 0479/1129] Avoid QMatrix test while gcc is broken. --- tests/QtGui/deepcopy_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/QtGui/deepcopy_test.py b/tests/QtGui/deepcopy_test.py index 2f8f7de..3e9f0f8 100644 --- a/tests/QtGui/deepcopy_test.py +++ b/tests/QtGui/deepcopy_test.py @@ -53,6 +53,10 @@ class QMatrixDeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QMatrix(1, 2, 3, 4, 5, 6) + +# Avoid these tests until get gcc fixed +# Related bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247 +""" class QMatrix2x2DeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QMatrix2x2([1, 2, 3, 4]) @@ -88,6 +92,7 @@ class QMatrix4x3DeepCopy(DeepCopyHelper, unittest.TestCase): class QMatrix4x4DeepCopy(DeepCopyHelper, unittest.TestCase): def setUp(self): self.original = QMatrix4x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) +""" if __name__ == '__main__': unittest.main() From d3b630e1682c89ee427964d81c32219c14863b1d Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 22 Dec 2010 10:25:32 -0300 Subject: [PATCH 0480/1129] Fix the QtMultimedia/audio_test.py to accept computers with only null device. --- tests/QtMultimedia/audio_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/QtMultimedia/audio_test.py b/tests/QtMultimedia/audio_test.py index f3aa680..773524e 100644 --- a/tests/QtMultimedia/audio_test.py +++ b/tests/QtMultimedia/audio_test.py @@ -9,13 +9,19 @@ from PySide.QtMultimedia import * class testAudioDevices(unittest.TestCase): def testListDevices(self): + valid = False devices = QAudioDeviceInfo.availableDevices(QAudio.AudioOutput) if not len(devices): return + valid = True for devInfo in devices: if devInfo.deviceName() == 'null': - continue + # skip the test if the only device found is a invalid device + if len(devices) == 1: + return + else: + continue fmt = QAudioFormat() for codec in devInfo.supportedCodecs(): fmt.setCodec(codec) From 2734efb6b704c53bab64168be49ce06d6b5a03da Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 22 Dec 2010 16:14:47 -0300 Subject: [PATCH 0481/1129] Moved list_signal_test to pysidetest library. This isolate the test case, and avoid other problems with X during the buildbot compilation. Reviewer: Lauro Moura Hugo Parente Lima --- tests/pysidetest/CMakeLists.txt | 1 + tests/pysidetest/list_signal_test.py | 23 ++++++++++++++++++ tests/pysidetest/testobject.h | 3 +++ tests/signals/CMakeLists.txt | 1 - tests/signals/list_signal_test.py | 35 ---------------------------- 5 files changed, 27 insertions(+), 36 deletions(-) create mode 100644 tests/pysidetest/list_signal_test.py delete mode 100644 tests/signals/list_signal_test.py diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 4a4c27a..b3215bc 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -76,4 +76,5 @@ PYSIDE_TEST(homonymoussignalandmethod_test.py) PYSIDE_TEST(delegatecreateseditor_test.py) PYSIDE_TEST(modelview_test.py) PYSIDE_TEST(version_test.py) +PYSIDE_TEST(list_signal_test.py) diff --git a/tests/pysidetest/list_signal_test.py b/tests/pysidetest/list_signal_test.py new file mode 100644 index 0000000..36d3c21 --- /dev/null +++ b/tests/pysidetest/list_signal_test.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import unittest +from testbinding import TestObject +from PySide.QtCore import QObject + +class ListConnectionTest(unittest.TestCase): + + def childrenChanged(self, children): + self._child = children[0] + + def testConnection(self): + o = TestObject(0) + c = QObject() + c.setObjectName("child") + self._child = None + o.childrenChanged.connect(self.childrenChanged) + o.addChild(c) + self.assertEquals(self._child.objectName(), "child") + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/pysidetest/testobject.h b/tests/pysidetest/testobject.h index 9012359..d882870 100644 --- a/tests/pysidetest/testobject.h +++ b/tests/pysidetest/testobject.h @@ -14,6 +14,7 @@ public: TestObject(int idValue, QObject* parent = 0) : QObject(parent), m_idValue(idValue) {} int idValue() const { return m_idValue; } static int staticMethodDouble(int value) { return value * 2; } + void addChild(QObject* c) { m_children.append(c); emit childrenChanged(m_children); } void emitIdValueSignal(); void emitStaticMethodDoubleSignal(); @@ -22,9 +23,11 @@ signals: void idValue(int newValue); void justASignal(); void staticMethodDouble(); + void childrenChanged(const QList); private: int m_idValue; + QList m_children; }; #endif // TESTOBJECT_H diff --git a/tests/signals/CMakeLists.txt b/tests/signals/CMakeLists.txt index cad84f1..c9ef33e 100644 --- a/tests/signals/CMakeLists.txt +++ b/tests/signals/CMakeLists.txt @@ -6,7 +6,6 @@ PYSIDE_TEST(decorators_test.py) PYSIDE_TEST(invalid_callback_test.py) PYSIDE_TEST(lambda_gui_test.py) PYSIDE_TEST(lambda_test.py) -PYSIDE_TEST(list_signal_test.py) PYSIDE_TEST(leaking_signal_test.py) PYSIDE_TEST(multiple_connections_gui_test.py) PYSIDE_TEST(multiple_connections_test.py) diff --git a/tests/signals/list_signal_test.py b/tests/signals/list_signal_test.py deleted file mode 100644 index c65eb11..0000000 --- a/tests/signals/list_signal_test.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- - -import unittest - -from PySide.QtCore import * -from PySide.QtGui import * - -class ListConnectionTest(unittest.TestCase): - - def modifyScene(self): - self.scene.addLine(0, 0, 10, 10) - - def sceneChanged(self, rects): - # Qt isn't so cute and sends this signal with empty lists and null rects sometimes. - if len(rects) > 0 and not rects[0].isNull(): - self.rects = rects - QApplication.quit() - - def testConnection(self): - app = QApplication([]) - - self.scene = QGraphicsScene() - QTimer.singleShot(0, self.modifyScene) - self.scene.changed.connect(self.sceneChanged) - - app.exec_() - self.assertEquals(len(self.rects), 1) - self.assertEquals(self.rects[0].x(), 0) - self.assertEquals(self.rects[0].y(), 0) - self.assertEquals(self.rects[0].width(), 10) - self.assertEquals(self.rects[0].height(), 10) - -if __name__ == '__main__': - unittest.main() - From af6514a1e81cadbad1ac754ea362ec24e107efb9 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Wed, 22 Dec 2010 18:11:26 -0300 Subject: [PATCH 0482/1129] Fix testbinding dependency Reviewer: Marcelo Lira Reviewer: Renato Araujo --- tests/pysidetest/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index b3215bc..83e9202 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -69,7 +69,7 @@ target_link_libraries(testbinding ${QT_QTGUI_LIBRARY} ${SBK_PYTHON_LIBRARIES}) -add_dependencies(testbinding pyside QtCore libpyside pysidetest) +add_dependencies(testbinding pyside QtCore QtGui libpyside pysidetest) PYSIDE_TEST(homonymoussignalandmethod_test.py) From 3468d8f78e1b0b54124adbe9d21d097c064bb85e Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 22 Dec 2010 19:12:42 -0300 Subject: [PATCH 0483/1129] Fixed variable scope. This keep the QByteArray live during the use of your content. Reviewer: Lauro Moura Hugo Parente Lima --- libpyside/pysidesignal.h | 1 + libpyside/signalmanager.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libpyside/pysidesignal.h b/libpyside/pysidesignal.h index fb7c8f9..443572c 100644 --- a/libpyside/pysidesignal.h +++ b/libpyside/pysidesignal.h @@ -138,6 +138,7 @@ PYSIDE_API QString getCallbackSignature(const char* signal, QObject* receiver, P * @param signature The signal signature * @param isShortCircuit If this is a shortCircuit(python<->python) signal * @return Return true if this is a Qt Signal of false if not + * @todo replace return type to QList **/ QStringList getArgsFromSignature(const char* signature, bool* isShortCircuit = 0); diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 31621a7..6cdc3e1 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -199,7 +199,7 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa int i; for (i = 0; i < argsGiven; ++i) { - const char* typeName = argTypes[i].toAscii().constData(); + QByteArray typeName = argTypes[i].toAscii(); Shiboken::TypeResolver* typeResolver = Shiboken::TypeResolver::get(typeName); if (typeResolver) { int typeId = QMetaType::type(typeName); From 09840da111e373ebde987cc5f34b89aa49ae3a55 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 23 Dec 2010 15:46:39 -0300 Subject: [PATCH 0484/1129] Used more common signature on function test to QList objects. Replaced "const QList" signature to "const QList&", more used on Qt code. --- tests/pysidetest/testobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pysidetest/testobject.h b/tests/pysidetest/testobject.h index d882870..65506b9 100644 --- a/tests/pysidetest/testobject.h +++ b/tests/pysidetest/testobject.h @@ -23,7 +23,7 @@ signals: void idValue(int newValue); void justASignal(); void staticMethodDouble(); - void childrenChanged(const QList); + void childrenChanged(const QList&); private: int m_idValue; From 85715f3fc3de87bfa4ac07f4d76f1b69bb012109 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 23 Dec 2010 16:59:33 -0200 Subject: [PATCH 0485/1129] Fix bug#549 - "QGraphicsWidget::getContentsMargins() and QGraphicsWidget::getWindowFrameMargins() not available" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 46 +++++++++++++++++++++++--- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_549.py | 16 +++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 tests/QtGui/bug_549.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 940f730..0994331 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -4834,10 +4834,48 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 7cde60f..fe62e8e 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -21,6 +21,7 @@ PYSIDE_TEST(bug_480.py) PYSIDE_TEST(bug_500.py) PYSIDE_TEST(bug_512.py) PYSIDE_TEST(bug_525.py) +PYSIDE_TEST(bug_549.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_549.py b/tests/QtGui/bug_549.py new file mode 100644 index 0000000..6d07899 --- /dev/null +++ b/tests/QtGui/bug_549.py @@ -0,0 +1,16 @@ +import unittest + +from PySide.QtGui import * + +class TestBug549(unittest.TestCase): + def testBug(self): + app = QApplication([]) + w = QGraphicsWidget() + w.setContentsMargins(1, 2, 3, 4) + self.assertEquals(w.getContentsMargins(), (1, 2, 3, 4)) + w.setWindowFrameMargins(5, 6, 7, 8) + self.assertEquals(w.getWindowFrameMargins(), (5, 6, 7, 8)) + +if __name__ == '__main__': + unittest.main() + From 949f6b52558e150f8727c1496167d67c1c0799ef Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 27 Dec 2010 13:20:43 -0300 Subject: [PATCH 0486/1129] Removed some float comparisons from QColor test to avoid armel problems. Reviewed by Hugo Parente --- tests/QtGui/qcolor_test.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/QtGui/qcolor_test.py b/tests/QtGui/qcolor_test.py index a636ad6..1a94728 100644 --- a/tests/QtGui/qcolor_test.py +++ b/tests/QtGui/qcolor_test.py @@ -2,7 +2,7 @@ import unittest import colorsys -from PySide.QtCore import Qt +from PySide.QtCore import Qt, qFuzzyCompare from PySide.QtGui import QColor @@ -14,12 +14,6 @@ class QColorGetTest(unittest.TestCase): def testGetRgb(self): self.assertEqual(self.color.getRgb(), (20, 40, 60, 80)) - def testGetRgbF(self): - self.assertEqual(self.color.getRgbF(), (20.0/255, 40.0/255, 60.0/255, 80.0/255)) - - def testGetHsl(self): - self.assertEqual(self.color.getHsl(), (210, 128, 40, self.color.alpha())) - def testGetHslF(self): hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255) hsla = hls[0], hls[2], hls[1], self.color.alphaF() @@ -31,11 +25,6 @@ class QColorGetTest(unittest.TestCase): hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha() self.assertEqual(self.color.getHsv(), hsva) - def testGetHsvF(self): - hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) - hsva = hsv[0], hsv[1], hsv[2], self.color.alphaF() - self.assertEqual(self.color.getHsvF(), hsva) - def testGetCmyk(self): # not supported by colorsys self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80)) From 97875193524f407ec4594969041d84f7aa8ec546 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 27 Dec 2010 18:59:32 -0300 Subject: [PATCH 0487/1129] Fix QTreeWidget parent rules. QTreeWidget.clear() - remove all child ref from the current widget QTreeWidgetItem.parent() - use default policy for returned value Fix bug #547 Reviewer: Marcelo Lira Hugo Parente Lima --- PySide/QtGui/typesystem_gui_common.xml | 20 +++++++++++++ tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_547.py | 39 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 tests/QtGui/bug_547.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 0994331..c2b6343 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3030,6 +3030,18 @@ + + + QTreeWidgetItem *rootItem = %CPPSELF.invisibleRootItem(); + Shiboken::BindingManager &bm = Shiboken::BindingManager::instance(); + for (int i = 0; i < rootItem->childCount(); ++i) { + QTreeWidgetItem *item = rootItem->child(i); + SbkObject* wrapper = bm.retrieveWrapper(item); + if (wrapper) + Shiboken::Object::setParent(0, reinterpret_cast<PyObject*>(wrapper)); + } + + @@ -3228,6 +3240,14 @@ + + + + + + + + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index fe62e8e..93b9c07 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -21,6 +21,7 @@ PYSIDE_TEST(bug_480.py) PYSIDE_TEST(bug_500.py) PYSIDE_TEST(bug_512.py) PYSIDE_TEST(bug_525.py) +PYSIDE_TEST(bug_547.py) PYSIDE_TEST(bug_549.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtGui/bug_547.py b/tests/QtGui/bug_547.py new file mode 100644 index 0000000..5636fb6 --- /dev/null +++ b/tests/QtGui/bug_547.py @@ -0,0 +1,39 @@ +""" Unittest for bug #547 """ +""" http://bugs.openbossa.org/show_bug.cgi?id=547 """ + +from PySide import QtGui +import sys +import unittest + +class MyMainWindow(unittest.TestCase): + def testClearFunction(self): + app = QtGui.QApplication(sys.argv) + self._tree = QtGui.QTreeWidget() + self._tree.setColumnCount(2) + self._i1 = None + self._i11 = None + + self._updateTree() + self.assertEqual(sys.getrefcount(self._i1), 3) + self.assertEqual(sys.getrefcount(self._i11), 3) + + self._i11.parent().setExpanded(True) + self._i11.setExpanded(True) + + self._updateTree() + self.assertEqual(sys.getrefcount(self._i1), 3) + self.assertEqual(sys.getrefcount(self._i11), 3) + + + def _updateTree(self): + self._tree.clear() + if self._i1 and self._i11: + self.assertEqual(sys.getrefcount(self._i1), 2) + self.assertEqual(sys.getrefcount(self._i11), 2) + + self._i1 = QtGui.QTreeWidgetItem(self._tree, ['1', ]) + self._i11 = QtGui.QTreeWidgetItem(self._i1, ['11', ]) + +if __name__ == '__main__': + unittest.main() + From 0029d0ef7e85cde40b945d6a55c321f459acda09 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 28 Dec 2010 11:49:39 -0300 Subject: [PATCH 0488/1129] Test for QTDESIGNER before add QTUITOOLS. This test is necessary because the module QTUITOOLS uses some classes from QTDESIGNER. Reviewer: Marcelo Lira Bruno Araujo --- PySide/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 3b85e3d..35baf3c 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -23,7 +23,9 @@ HAS_QT_MODULE(QT_QTXML_FOUND QtXml) HAS_QT_MODULE(QT_QTTEST_FOUND QtTest) HAS_QT_MODULE(QT_QTOPENGL_FOUND QtOpenGL) HAS_QT_MODULE(QT_QTSQL_FOUND QtSql) -HAS_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) +if(QT_QTDESIGNER_FOUND) + HAS_QT_MODULE(QT_QTUITOOLS_FOUND QtUiTools) +endif() HAS_QT_MODULE(QT_QTHELP_FOUND QtHelp) HAS_QT_MODULE(QT_QTXMLPATTERNS_FOUND QtXmlPatterns) HAS_QT_MODULE(QT_QTMAEMO5_FOUND QtMaemo5) From d96649862fff5ee8e22ac3f48c9a96fea04238bf Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 28 Dec 2010 14:09:16 -0300 Subject: [PATCH 0489/1129] Appended QtGui library dependency on pysidetest library. --- tests/pysidetest/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 83e9202..4b94a2a 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -53,12 +53,12 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_INCLUDE_PATH}) add_library(pysidetest SHARED ${pysidetest_SRC} ${pysidetest_MOC_SRC}) -target_link_libraries(pysidetest ${QT_QTCORE_LIBRARY}) +target_link_libraries(pysidetest ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) add_library(testbinding MODULE ${testbinding_SRC}) set_property(TARGET testbinding PROPERTY PREFIX "") if(WIN32) - set_target_properties(testbinding PROPERTIES SUFFIX ".pyd") + set_target_properties(testbinding PROPERTIES SUFFIX ".pyd") endif() target_link_libraries(testbinding pysidetest From c406547057691d758de8324ffb6fabff93e7f1fa Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 28 Dec 2010 14:12:24 -0300 Subject: [PATCH 0490/1129] Appended ${QtGui_BINARY_DIR} on typesystem_path for QtMaemo5 module. --- PySide/QtMaemo5/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/QtMaemo5/CMakeLists.txt b/PySide/QtMaemo5/CMakeLists.txt index fadf91d..30bf15c 100644 --- a/PySide/QtMaemo5/CMakeLists.txt +++ b/PySide/QtMaemo5/CMakeLists.txt @@ -11,7 +11,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5/qmaemo5valuebutton_wrapper. ${CMAKE_CURRENT_BINARY_DIR}/${BINDING_NAME}/QtMaemo5/qtmaemo5_module_wrapper.cpp ) -set(QtMaemo5_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtMaemo5_SOURCE_DIR}") +set(QtMaemo5_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}${PATH_SEP}${QtMaemo5_SOURCE_DIR}${PATH_SEP}${QtGui_BINARY_DIR}") # QT_QTMAEMO5_* variables are not defined by CMake if(NOT QT_QTMAEMO5_INCLUDE_DIR) From 6849ba0864c245e15b5786d959b5afa730fb906b Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 28 Dec 2010 19:43:00 -0300 Subject: [PATCH 0491/1129] Fix test to avoid problems on slow computers. Reviewed by Hugo Parente --- tests/QtGui/virtual_protected_inheritance_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/QtGui/virtual_protected_inheritance_test.py b/tests/QtGui/virtual_protected_inheritance_test.py index 15de37d..be19952 100644 --- a/tests/QtGui/virtual_protected_inheritance_test.py +++ b/tests/QtGui/virtual_protected_inheritance_test.py @@ -57,7 +57,7 @@ class TimerEventTest(UsesQApplication): self.widget.killTimer(timer_id) - self.assertEqual(self.widget.runs, 5) + self.assert_(self.widget.runs >= self.widget.max_runs) if __name__ == '__main__': From 40f5c3ce0e88a54bf8b838b4951a23a3e147fd5a Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 28 Dec 2010 19:43:51 -0300 Subject: [PATCH 0492/1129] Fixed MetaObject creation based on typename. Reviewed by Hugo Parente --- libpyside/pyside.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp index da896ce..5cb107a 100644 --- a/libpyside/pyside.cpp +++ b/libpyside/pyside.cpp @@ -138,11 +138,7 @@ void destroyQCoreApplication() void initDynamicMetaObject(SbkObjectType* type, const QMetaObject* base) { - const char* typeName = type->super.ht_type.tp_name; - int len = strlen(typeName); - for (int i = len-1; i >= 0; --i) - if (typeName[i] == '.') - typeName += i + 1; + QByteArray typeName = QByteArray(type->super.ht_type.tp_name).split('.').last(); DynamicQMetaObject* mo = new PySide::DynamicQMetaObject(typeName, base); Shiboken::ObjectType::setTypeUserData(type, mo, &Shiboken::callCppDestructor); } From 6d18229268b42db54824cc277e339bac34ad3404 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 28 Dec 2010 12:21:50 -0200 Subject: [PATCH 0493/1129] Changes the arg name from p to parent to make parent heuristic work. --- PySide/QtDeclarative/typesystem_declarative.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PySide/QtDeclarative/typesystem_declarative.xml b/PySide/QtDeclarative/typesystem_declarative.xml index d4edee8..05d72e8 100644 --- a/PySide/QtDeclarative/typesystem_declarative.xml +++ b/PySide/QtDeclarative/typesystem_declarative.xml @@ -79,6 +79,11 @@ + + + + + From 92b893c53242a191b76291f8fb0ce68fd284c115 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 28 Dec 2010 14:50:46 -0200 Subject: [PATCH 0494/1129] Fix bug#563 - "Unhandled signal emitting with invalid signature (which leads to application crash)" --- libpyside/signalmanager.cpp | 2 +- tests/QtDeclarative/bug_456.py | 2 +- tests/QtDeclarative/bug_456.qml | 2 +- tests/QtDeclarative/connect_python_qml.py | 6 +++--- tests/QtDeclarative/connect_python_qml.qml | 20 ++++++++++---------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 6cdc3e1..75a0d19 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -188,7 +188,7 @@ static bool emitNormalSignal(QObject* source, int signalIndex, const char* signa Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0)); int argsGiven = PySequence_Fast_GET_SIZE(sequence.object()); - if (argsGiven > argTypes.count()) { + if (argsGiven != argTypes.count()) { PyErr_Format(PyExc_TypeError, "%s only accepts %d arguments, %d given!", signal, argTypes.count(), argsGiven); return false; } diff --git a/tests/QtDeclarative/bug_456.py b/tests/QtDeclarative/bug_456.py index 262b82e..9ed70c8 100644 --- a/tests/QtDeclarative/bug_456.py +++ b/tests/QtDeclarative/bug_456.py @@ -33,7 +33,7 @@ class TestConnectionWithInvalidSignature(TimedQApplication): root = view.rootObject() button = root.findChild(QtCore.QObject, "buttonMouseArea") view.show() - button.clicked.emit() + button.entered.emit() self.assertEqual(rotatevalue.rotation, 100) if __name__ == '__main__': diff --git a/tests/QtDeclarative/bug_456.qml b/tests/QtDeclarative/bug_456.qml index e4596fd..e8b220e 100644 --- a/tests/QtDeclarative/bug_456.qml +++ b/tests/QtDeclarative/bug_456.qml @@ -56,7 +56,7 @@ Rectangle { id: buttonMouseArea objectName: "buttonMouseArea" anchors.fill: parent - onClicked: { + onEntered: { rotatevalue.rotation = rotatevalue.val() } } diff --git a/tests/QtDeclarative/connect_python_qml.py b/tests/QtDeclarative/connect_python_qml.py index e8180f7..669eec6 100644 --- a/tests/QtDeclarative/connect_python_qml.py +++ b/tests/QtDeclarative/connect_python_qml.py @@ -19,9 +19,9 @@ class TestConnectionWithInvalidSignature(TimedQApplication): view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('connect_python_qml.qml', __file__))) root = view.rootObject() button = root.findChild(QtCore.QObject, "buttonMouseArea") - self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('clicked()'), self.onButtonFailClicked]) - button.clicked.connect(self.onButtonClicked) - button.clicked.emit() + self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('entered()'), self.onButtonFailClicked]) + button.entered.connect(self.onButtonClicked) + button.entered.emit() view.show() self.app.exec_() self.assert_(self.buttonClicked) diff --git a/tests/QtDeclarative/connect_python_qml.qml b/tests/QtDeclarative/connect_python_qml.qml index dbf890f..df55e1b 100644 --- a/tests/QtDeclarative/connect_python_qml.qml +++ b/tests/QtDeclarative/connect_python_qml.qml @@ -6,15 +6,15 @@ Rectangle { color: "lightgray" Rectangle { - id: button - width: 150; height: 40 - color: "darkgray" - anchors.horizontalCenter: page.horizontalCenter - y: 150 - MouseArea { - id: buttonMouseArea - objectName: "buttonMouseArea" - anchors.fill: parent - } + id: button + width: 150; height: 40 + color: "darkgray" + anchors.horizontalCenter: page.horizontalCenter + y: 150 + MouseArea { + id: buttonMouseArea + objectName: "buttonMouseArea" + anchors.fill: parent + } } } From d8f3b9629a6b1f1ab91516fdc144eb4fd80e5128 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 28 Dec 2010 18:53:06 -0200 Subject: [PATCH 0495/1129] Fix bug#569 - "QTableWidgetItem is missing binding of __lt__ to operator<" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 15 --------------- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_569.py | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 tests/QtGui/bug_569.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index c2b6343..2998c59 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3074,9 +3074,6 @@ - - - @@ -3085,8 +3082,6 @@ - - @@ -3110,9 +3105,6 @@ - - - @@ -3129,8 +3121,6 @@ - - @@ -3165,16 +3155,12 @@ - - - - @@ -3259,7 +3245,6 @@ - diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 93b9c07..0cd9ac2 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -23,6 +23,7 @@ PYSIDE_TEST(bug_512.py) PYSIDE_TEST(bug_525.py) PYSIDE_TEST(bug_547.py) PYSIDE_TEST(bug_549.py) +PYSIDE_TEST(bug_569.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_569.py b/tests/QtGui/bug_569.py new file mode 100644 index 0000000..00d92ed --- /dev/null +++ b/tests/QtGui/bug_569.py @@ -0,0 +1,19 @@ +from PySide.QtCore import * +from PySide.QtGui import * +import unittest + + +class TestBug569(unittest.TestCase): + + def testIt(self): + types = (QTableWidgetItem, QListWidgetItem, QTreeWidgetItem) + for t in types: + a = t() + a.__lt__ = lambda(other) : True + b = t() + b.__lt__ = lambda(other) : False + self.assertTrue(a < b) + self.assertFalse(b < a) + +if __name__ == '__main__': + unittest.main() From 1d05357e2657df96b16b5cb4f2e9cc2b6ca73d2b Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 29 Dec 2010 11:55:09 -0300 Subject: [PATCH 0496/1129] Changed api2 test to work on MacOS during a ssh session. --- tests/QtGui/api2_test.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/QtGui/api2_test.py b/tests/QtGui/api2_test.py index e458d8b..42edba0 100644 --- a/tests/QtGui/api2_test.py +++ b/tests/QtGui/api2_test.py @@ -2,6 +2,7 @@ import unittest +import sys from PySide.QtCore import QObject from PySide.QtGui import * @@ -38,23 +39,21 @@ class DoubleQObjectInheritanceTest(UsesQApplication): obj.setRange(1, 10) obj.setValue(0) - print "Value:", obj.value() + self.assertEqual(obj.value(), 1) class QClipboardTest(UsesQApplication): def testQClipboard(self): - clip = QClipboard() + #skip this test on MacOS because the clipboard is not available during the ssh session + #this cause problems in the buildbot + if sys.platform == 'darwin': + return + clip = QApplication.clipboard() clip.setText("Testing this thing!") text, subtype = clip.text("") self.assertEqual(subtype, "plain") self.assertEqual(text, "Testing this thing!") -#class QFileDialog(UsesQApplication): -# -# def testQFileDialog(self): -# string, filtr = QFileDialog.getOpenFileName() -# print string, filtr - if __name__ == '__main__': unittest.main() From ecb060f85c3de21b6f2e6ea94417685307252791 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Tue, 28 Dec 2010 21:18:26 -0300 Subject: [PATCH 0497/1129] Improve QtScriptEngineDebugger test behavior The extra ContinueAction after evaluate() was crashing on MacOS X. Reviewer: Hugo Lima Reviewer: Renato Araujo --- tests/QtScriptTools/debugger_test.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/QtScriptTools/debugger_test.py b/tests/QtScriptTools/debugger_test.py index e525361..5634824 100644 --- a/tests/QtScriptTools/debugger_test.py +++ b/tests/QtScriptTools/debugger_test.py @@ -1,7 +1,7 @@ import unittest -from PySide.QtCore import SIGNAL +from PySide.QtCore import SIGNAL, QTimer from PySide.QtScript import QScriptEngine from PySide.QtScriptTools import QScriptEngineDebugger @@ -13,29 +13,32 @@ class DebuggerTest(UsesQApplication): UsesQApplication.setUp(self) self.engine = QScriptEngine() self.debugger = QScriptEngineDebugger() - self.has_suspended = False - self.has_resumed = False + self.has_suspended = 0 + self.has_resumed = 0 + self.count = 3 def suspended(self): - self.has_suspended = True - self.debugger.action(QScriptEngineDebugger.ContinueAction).trigger() + self.has_suspended += 1 + # Will emit evaluationResumed until there are more instructions to be run + QTimer.singleShot(100, self.debugger.action(QScriptEngineDebugger.StepIntoAction).trigger) def resumed(self): - self.has_resumed = True + # Will be called when debugger.state() change from Suspended to Running + # except for the first time. + self.has_resumed += 1 def testBasic(self): '''Interrupt and resume evaluation with QScriptEngineDebugger''' + self.debugger.attachTo(self.engine) self.debugger.setAutoShowStandardWindow(False) self.debugger.connect(SIGNAL('evaluationSuspended()'), self.suspended) self.debugger.connect(SIGNAL('evaluationResumed()'), self.resumed) self.debugger.action(QScriptEngineDebugger.InterruptAction).trigger() - self.engine.evaluate("3+4") - self.debugger.action(QScriptEngineDebugger.ContinueAction).trigger() - self.assert_(self.has_resumed) - self.assert_(self.has_suspended) - + self.engine.evaluate("3+4\n2+1\n5+1") + self.assertEqual(self.has_resumed, 2) + self.assertEqual(self.has_suspended, 3) if __name__ == '__main__': unittest.main() From 9b02c46c03a3e246146ccd5b63fda8cb0335aac7 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 29 Dec 2010 18:57:58 -0200 Subject: [PATCH 0498/1129] Fix bug#493 - "__eq__ and friends not implemented for QKeyEvent == QKeySequence" Reviewer: Marcelo Lira Lauro Moura --- PySide/QtGui/typesystem_gui_common.xml | 9 +++++++-- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_493.py | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/QtGui/bug_493.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 2998c59..be38ca9 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -128,7 +128,6 @@ - @@ -2427,7 +2426,13 @@ - + + + + %PYARG_0 = %CONVERTTOPYTHON[bool](!(&%CPPSELF == %1)); + + + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 0cd9ac2..65b10e8 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -18,6 +18,7 @@ PYSIDE_TEST(bug_430.py) PYSIDE_TEST(bug_433.py) PYSIDE_TEST(bug_467.py) PYSIDE_TEST(bug_480.py) +PYSIDE_TEST(bug_493.py) PYSIDE_TEST(bug_500.py) PYSIDE_TEST(bug_512.py) PYSIDE_TEST(bug_525.py) diff --git a/tests/QtGui/bug_493.py b/tests/QtGui/bug_493.py new file mode 100644 index 0000000..bf19fa7 --- /dev/null +++ b/tests/QtGui/bug_493.py @@ -0,0 +1,21 @@ +from PySide.QtCore import * +from PySide.QtGui import * +import unittest + + +class TestBug569(unittest.TestCase): + + def testIt(self): + # We need a qapp otherwise Qt will crash when trying to detect the + # current platform + app = QApplication([]) + ev1 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Delete, Qt.NoModifier) + ev2 = QKeyEvent(QEvent.KeyRelease, Qt.Key_Copy, Qt.NoModifier) + ks = QKeySequence.Delete + self.assertEqual(ev1, ks) + self.assertEqual(ks, ev1) + self.assertNotEqual(ev2, ks) + self.assertNotEqual(ks, ev2) + +if __name__ == '__main__': + unittest.main() From 394cdb357d88e4c6968d3986ca7820756661fa35 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 30 Dec 2010 15:26:20 -0200 Subject: [PATCH 0499/1129] Fix bug 546 - "Python crash on exit" Reviewer: Marcelo Lira Lauro Moura --- PySide/QtGui/typesystem_gui_common.xml | 4 ++-- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_546.py | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/QtGui/bug_546.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index be38ca9..c7c8f17 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3152,8 +3152,8 @@ - - + + diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 65b10e8..4514731 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -22,6 +22,7 @@ PYSIDE_TEST(bug_493.py) PYSIDE_TEST(bug_500.py) PYSIDE_TEST(bug_512.py) PYSIDE_TEST(bug_525.py) +PYSIDE_TEST(bug_546.py) PYSIDE_TEST(bug_547.py) PYSIDE_TEST(bug_549.py) PYSIDE_TEST(bug_569.py) diff --git a/tests/QtGui/bug_546.py b/tests/QtGui/bug_546.py new file mode 100644 index 0000000..845b64e --- /dev/null +++ b/tests/QtGui/bug_546.py @@ -0,0 +1,14 @@ +import unittest +from PySide.QtGui import * + +class TestBug546(unittest.TestCase): + + """Test to check a crash at exit""" + def testIt(self): + app = QApplication([]) + textEdit = QPlainTextEdit() + completer = QCompleter(("foo", "bar"), textEdit) + completer.setWidget(textEdit) + +if __name__=='__main__': + unittest.main() From 9e6762eeb050496f74fdafa1325dd294bf564ce1 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 30 Dec 2010 16:36:23 -0200 Subject: [PATCH 0500/1129] Fix bug#514 - "Static method QByteArray.fromRawData is missing from QtCore" Reviewer: Marcelo Lira Lauro Moura --- PySide/QtCore/typesystem_core.xml | 10 +++++++++- tests/QtCore/qbytearray_test.py | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index e416e57..c785f79 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1734,7 +1734,15 @@ - + + + + + + // %FUNCTION_NAME() - avoid generation of default function call + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](QByteArray(%1)); + + diff --git a/tests/QtCore/qbytearray_test.py b/tests/QtCore/qbytearray_test.py index 2c0ee87..34dc42f 100644 --- a/tests/QtCore/qbytearray_test.py +++ b/tests/QtCore/qbytearray_test.py @@ -102,5 +102,12 @@ class QByteArrayOnQVariant(unittest.TestCase): a = QSettings().value("some_prop", QByteArray()) self.assertEqual(type(a), QByteArray) +class QByteArrayBug514(unittest.TestCase): + def testIt(self): + data = "foobar" + a = QByteArray.fromRawData(data) + self.assertEqual(type(a), QByteArray) + self.assertEqual(a.data(), data) + if __name__ == '__main__': unittest.main() From 814b80f42352199915a13a61280dfe62b8763670 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 3 Jan 2011 10:01:04 -0300 Subject: [PATCH 0501/1129] Fixed test to work in all platform. --- tests/QtScriptTools/debugger_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/QtScriptTools/debugger_test.py b/tests/QtScriptTools/debugger_test.py index 5634824..8805018 100644 --- a/tests/QtScriptTools/debugger_test.py +++ b/tests/QtScriptTools/debugger_test.py @@ -37,8 +37,8 @@ class DebuggerTest(UsesQApplication): self.debugger.action(QScriptEngineDebugger.InterruptAction).trigger() self.engine.evaluate("3+4\n2+1\n5+1") - self.assertEqual(self.has_resumed, 2) - self.assertEqual(self.has_suspended, 3) + self.assert_(self.has_resumed >= 1) + self.assert_(self.has_suspended >= 1) if __name__ == '__main__': unittest.main() From ba00068ce161bba9c62c0784876bcb38d252cd98 Mon Sep 17 00:00:00 2001 From: Lauro Neto Date: Mon, 3 Jan 2011 11:28:02 -0300 Subject: [PATCH 0502/1129] Avoid conflict in test case names Reviewer: Hugo Lima Reviewer: Marcelo Lira --- tests/QtCore/qdatastream_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py index 1a75f79..7ccc12e 100644 --- a/tests/QtCore/qdatastream_test.py +++ b/tests/QtCore/qdatastream_test.py @@ -308,7 +308,7 @@ class QDataStreamShiftBitArray(unittest.TestCase): self._check_bitarray(data) -class QDataStreamShiftBitArray(unittest.TestCase): +class QDataStreamRawData(unittest.TestCase): def testRawData(self): data = QDataStream() self.assertEqual(data.readRawData(4), '\x00\x00\x00\x00') From 1af0e9f4fe50537d18c07cfa05578d3242ce21c9 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 3 Jan 2011 13:43:29 -0300 Subject: [PATCH 0503/1129] Fixed QWidget.parent function. Create unit test for bug 576. Fixes bug #576. Reviewer: Marcelo Lira Lauro Moura --- PySide/QtGui/typesystem_gui_common.xml | 23 ++++++++++++++---- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_576.py | 32 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 tests/QtGui/bug_576.py diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index c7c8f17..8884c63 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3287,6 +3287,24 @@ + + + + + + + + + + + + + + + + + + @@ -3413,11 +3431,6 @@ - - - - - diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 4514731..8906a93 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -26,6 +26,7 @@ PYSIDE_TEST(bug_546.py) PYSIDE_TEST(bug_547.py) PYSIDE_TEST(bug_549.py) PYSIDE_TEST(bug_569.py) +PYSIDE_TEST(bug_576.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_576.py b/tests/QtGui/bug_576.py new file mode 100644 index 0000000..b3c11a3 --- /dev/null +++ b/tests/QtGui/bug_576.py @@ -0,0 +1,32 @@ +""" Unittest for bug #576 """ +""" http://bugs.openbossa.org/show_bug.cgi?id=576 """ + +from PySide import QtGui, QtCore +import sys +import unittest + +class Bug576(unittest.TestCase): + def onButtonDestroyed(self, button): + self._destroyed = True + + def testWidgetParent(self): + self._destroyed = False + app = QtGui.QApplication(sys.argv) + w = QtGui.QWidget() + + b = QtGui.QPushButton("test") + b.destroyed[QtCore.QObject].connect(self.onButtonDestroyed) + self.assertEqual(sys.getrefcount(b), 2) + b.setParent(w) + self.assertEqual(sys.getrefcount(b), 3) + b.parent() + self.assertEqual(sys.getrefcount(b), 3) + b.setParent(None) + self.assertEqual(sys.getrefcount(b), 2) + del b + self.assert_(self._destroyed) + + +if __name__ == '__main__': + unittest.main() + From 1ed2877743ce786e1d71f804f1b4aa4f433aa4be Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 3 Jan 2011 14:24:19 -0200 Subject: [PATCH 0504/1129] Fix bug#577 - "Reference to QString in docs" --- .../snippets/code/src_gui_itemviews_qstandarditemmodel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp index 8086919..b7f91e0 100644 --- a/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp +++ b/doc/codesnippets/doc/src/snippets/code/src_gui_itemviews_qstandarditemmodel.cpp @@ -2,7 +2,7 @@ model = QStandardItemModel (4, 4) for row in range(4): for column in range(4): - item = QStandardItem(QString("row %0, column %1").arg(row).arg(column)) + item = QStandardItem("row %d, column %d" % (row, column)) model.setItem(row, column, item) //! [0] @@ -11,7 +11,7 @@ for row in range(4): model = QStandardItemModel() parentItem = model.invisibleRootItem() for i in range(4): - item = QStandardItem(QString("item %0").arg(i)) + item = QStandardItem("item %d" % i) parentItem.appendRow(item) parentItem = item //! [1] @@ -20,8 +20,7 @@ for i in range(4): //! [2] treeView = QTreeView(self) treeView.setModel(myStandardItemModel) -connect(treeView, SIGNAL('clicked(QModelIndex)') - this, SLOT('clicked(QModelIndex)')) +treeView.clicked[QModelIndex].connect(self.clicked) //! [2] From 7a3e7b6f86a514c661bf61c65d1098339e4ffba3 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 3 Jan 2011 14:21:40 -0300 Subject: [PATCH 0505/1129] Fix QTreeWidgetItem.parent function. Create unit test for new use case. Fixes bug #547 Reviewer: Marcelo Lira Hugo Parente Lima --- PySide/QtGui/typesystem_gui_common.xml | 2 +- tests/QtGui/bug_547.py | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 8884c63..b6516ab 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3231,7 +3231,7 @@ - + diff --git a/tests/QtGui/bug_547.py b/tests/QtGui/bug_547.py index 5636fb6..6b65254 100644 --- a/tests/QtGui/bug_547.py +++ b/tests/QtGui/bug_547.py @@ -6,8 +6,8 @@ import sys import unittest class MyMainWindow(unittest.TestCase): - def testClearFunction(self): - app = QtGui.QApplication(sys.argv) + app = QtGui.QApplication(sys.argv) + def testCase1(self): self._tree = QtGui.QTreeWidget() self._tree.setColumnCount(2) self._i1 = None @@ -24,6 +24,21 @@ class MyMainWindow(unittest.TestCase): self.assertEqual(sys.getrefcount(self._i1), 3) self.assertEqual(sys.getrefcount(self._i11), 3) + def testCase2(self): + self._tree = QtGui.QTreeWidget() + self._tree.setColumnCount(2) + self._i1 = None + self._i11 = None + + self._updateTree() + self.assertEqual(sys.getrefcount(self._i1), 3) + self.assertEqual(sys.getrefcount(self._i11), 3) + + self._i11.parent().setExpanded(True) + self._i11.setExpanded(True) + + self.assertEqual(sys.getrefcount(self._i1), 3) + self.assertEqual(sys.getrefcount(self._i11), 3) def _updateTree(self): self._tree.clear() @@ -32,7 +47,9 @@ class MyMainWindow(unittest.TestCase): self.assertEqual(sys.getrefcount(self._i11), 2) self._i1 = QtGui.QTreeWidgetItem(self._tree, ['1', ]) + self.assertEqual(sys.getrefcount(self._i1), 3) self._i11 = QtGui.QTreeWidgetItem(self._i1, ['11', ]) + self.assertEqual(sys.getrefcount(self._i11), 3) if __name__ == '__main__': unittest.main() From 1f1f82d5827c3ec77fcd4ee6b6ab47afa0473007 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 3 Jan 2011 16:38:30 -0300 Subject: [PATCH 0506/1129] Added test case for Bug #572. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug #572: Giving unicode value as 'body' argument to WebView's load method crashes python. Reviewed by Hugo Parente Reviewed by Renato Araújo --- tests/QtWebKit/webview_test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/QtWebKit/webview_test.py b/tests/QtWebKit/webview_test.py index a6a40fd..ab81a30 100644 --- a/tests/QtWebKit/webview_test.py +++ b/tests/QtWebKit/webview_test.py @@ -6,6 +6,7 @@ import sys from PySide.QtCore import QObject, SIGNAL, QUrl from PySide.QtWebKit import * +from PySide.QtNetwork import QNetworkRequest from helper import adjust_filename, TimedQApplication @@ -61,5 +62,8 @@ class TestLoadFinished(TimedQApplication): if ok: self.called = True + def testNamedArgumentTypeChecking(self): + self.assertRaises(TypeError, self.view.load, QNetworkRequest(), body=unicode('foo')) + if __name__ == '__main__': unittest.main() From cc7d8dd1386138a5e88afe64664f51c33aad2f56 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 3 Jan 2011 19:54:40 -0300 Subject: [PATCH 0507/1129] Created support to function qAddPostRoutine. Created unit test for bug #515 Fixes bug #515 Reviewer: Marcelo Lira Lauro Moura --- PySide/QtCore/typesystem_core.xml | 31 +++++++++++++++++++++++++++++++ tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/bug_515.py | 18 ++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 tests/QtCore/bug_515.py diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index c785f79..df04ca9 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -596,6 +596,37 @@ + + namespace PySide { + static QStack<PyObject*> globalPostRoutineFunctions; + void globalPostRoutineCallback() + { + foreach(PyObject* callback, globalPostRoutineFunctions) { + Shiboken::AutoDecRef result(PyObject_CallObject(callback, NULL)); + Py_DECREF(callback); + } + globalPostRoutineFunctions.clear(); + } + void addPostRoutine(PyObject* callback) + { + if (PyCallable_Check(callback)) { + globalPostRoutineFunctions << callback; + Py_INCREF(callback); + } else { + PyErr_SetString(PyExc_TypeError, "qAddPostRoutine: The argument must be a callable object."); + } + } + } // namespace + + + + PySide::addPostRoutine(%1); + + + + qAddPostRoutine(PySide::globalPostRoutineCallback); + + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 8ec3cdd..6851915 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -4,6 +4,7 @@ PYSIDE_TEST(bug_408.py) PYSIDE_TEST(bug_428.py) PYSIDE_TEST(bug_462.py) PYSIDE_TEST(bug_505.py) +PYSIDE_TEST(bug_515.py) PYSIDE_TEST(blocking_signals_test.py) PYSIDE_TEST(child_event_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtCore/bug_515.py b/tests/QtCore/bug_515.py new file mode 100644 index 0000000..c2bd9c7 --- /dev/null +++ b/tests/QtCore/bug_515.py @@ -0,0 +1,18 @@ +""" Unittest for bug #515 """ +""" http://bugs.openbossa.org/show_bug.cgi?id=515 """ + +from PySide import QtCore + +callCleanup = False +def _cleanup(): + global callCleanup + callCleanup = True + +def _checkCleanup(): + global callCleanup + assert(callCleanup) + +app = QtCore.QCoreApplication([]) +QtCore.qAddPostRoutine(_cleanup) +QtCore.qAddPostRoutine(_checkCleanup) +del app From 4351b2e5133e89c02ff26ecbf0f7df6e902efc64 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 4 Jan 2011 13:25:05 -0200 Subject: [PATCH 0508/1129] New format for __version_info__. The new format follow the same rules used by sys.version_info(). Reviewer: Marcelo Lira Lauro Moura --- CMakeLists.txt | 11 ++++++++++- PySide/__init__.py.in | 4 ++-- doc/conf.py.in | 2 +- libpyside/pyside.pc.in | 2 +- tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/versioninfo_test.py | 20 ++++++++++++++++++++ 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 tests/QtCore/versioninfo_test.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 5209bab..33eda53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,16 @@ set(BINDING_NAME PySide) set(BINDING_API_MAJOR_VERSION "1") set(BINDING_API_MINOR_VERSION "0") set(BINDING_API_MICRO_VERSION "0") +set(BINDING_API_RELEASE_LEVEL "beta") # alpha, beta, candidate, or final +set(BINDING_API_SERIAL 3) # 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) +if (BINDING_API_RELEASE_LEVEL STREQUAL "final") + set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}" + CACHE STRING "PySide version [full]" FORCE) +else() + set(BINDING_API_VERSION_FULL "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}.${BINDING_API_MICRO_VERSION}~${BINDING_API_RELEASE_LEVEL}${BINDING_API_SERIAL}" + CACHE STRING "PySide version [full]" FORCE) +endif() set(PYSIDE_QT_VERSION "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" CACHE STRING "Qt version used to compile PySide" FORCE) if(ENABLE_VERSION_SUFFIX) set(pyside_SUFFIX "-${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}") @@ -123,7 +132,7 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") -set(ARCHIVE_NAME pyside-qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}+${BINDING_API_VERSION}) +set(ARCHIVE_NAME pyside-qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}+${BINDING_API_VERSION_FULL}) add_custom_target(dist COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" && git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" && diff --git a/PySide/__init__.py.in b/PySide/__init__.py.in index f931fad..40731a8 100644 --- a/PySide/__init__.py.in +++ b/PySide/__init__.py.in @@ -1,5 +1,5 @@ __all__ = ['QtCore', 'QtGui', 'QtNetwork', 'QtOpenGL', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKit', 'QtScript'] import private -__version__ = "@BINDING_API_VERSION@" -__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@) +__version__ = "@BINDING_API_VERSION_FULL@" +__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@, "@BINDING_API_RELEASE_LEVEL@", @BINDING_API_SERIAL@) diff --git a/doc/conf.py.in b/doc/conf.py.in index b9e7549..d2d7408 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -51,7 +51,7 @@ copyright = u'2009-2010, Nokia Corporation' # The short X.Y version. version = '@BINDING_API_VERSION@' # The full version, including alpha/beta/rc tags. -release = '@BINDING_API_VERSION@' +release = '@BINDING_API_VERSION_FULL@' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/libpyside/pyside.pc.in b/libpyside/pyside.pc.in index f7458a9..993e5a1 100644 --- a/libpyside/pyside.pc.in +++ b/libpyside/pyside.pc.in @@ -7,7 +7,7 @@ pythonpath=@SITE_PACKAGE@ Name: PySide@pyside_SUFFIX@ Description: Support library for Python bindings of Qt-based libraries. -Version: @BINDING_API_VERSION@ +Version: @BINDING_API_VERSION_FULL@ Libs: -L${libdir} -lpyside@pyside_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@ Cflags: -I${includedir} Requires: shiboken diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 6851915..7f8a773 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -76,6 +76,7 @@ PYSIDE_TEST(tr_noop_test.py) PYSIDE_TEST(translation_test.py) PYSIDE_TEST(unaryoperator_test.py) PYSIDE_TEST(unicode_test.py) +PYSIDE_TEST(versioninfo_test.py) if(X11) PYSIDE_TEST(qhandle_test.py) diff --git a/tests/QtCore/versioninfo_test.py b/tests/QtCore/versioninfo_test.py new file mode 100644 index 0000000..094d637 --- /dev/null +++ b/tests/QtCore/versioninfo_test.py @@ -0,0 +1,20 @@ +import unittest +import PySide + +class TestVersionInfo(unittest.TestCase): + def testIt(self): + + v = PySide.__version_info__ + self.assertEqual(type(v), tuple) + self.assertEqual(len(v), 5) + self.assertEqual(type(v[0]), int) + self.assertEqual(type(v[1]), int) + self.assertEqual(type(v[2]), int) + self.assertEqual(type(v[3]), str) + self.assertEqual(type(v[4]), int) + + self.assertEqual(type(PySide.__version__), str) + + +if __name__ == '__main__': + unittest.main() From f7fd9277f47359f8eb4490bcb8f5bdc84000035e Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 4 Jan 2011 18:32:24 -0300 Subject: [PATCH 0509/1129] Fixed function QDataStream.readRawData return value. The function readRawData now return None in case of error, otherwise a string with the read data. Reviewer: Marcelo Lira Hugo Parente Lima --- PySide/QtCore/typesystem_core.xml | 9 +++++++-- tests/QtCore/qdatastream_test.py | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index df04ca9..54513f9 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -2388,8 +2388,13 @@ QByteArray data; data.resize(%2); - %CPPSELF.%FUNCTION_NAME(data.data(), data.size()); - %PYARG_0 = PyString_FromStringAndSize(data.constData(), data.size()); + int result = %CPPSELF.%FUNCTION_NAME(data.data(), data.size()); + if (result == -1) { + Py_INCREF(Py_None); + %PYARG_0 = Py_None; + } else { + %PYARG_0 = PyString_FromStringAndSize(data.data(), result); + } diff --git a/tests/QtCore/qdatastream_test.py b/tests/QtCore/qdatastream_test.py index 7ccc12e..ad74457 100644 --- a/tests/QtCore/qdatastream_test.py +++ b/tests/QtCore/qdatastream_test.py @@ -311,15 +311,15 @@ class QDataStreamShiftBitArray(unittest.TestCase): class QDataStreamRawData(unittest.TestCase): def testRawData(self): data = QDataStream() - self.assertEqual(data.readRawData(4), '\x00\x00\x00\x00') + self.assertEqual(data.readRawData(4), None) ba = QByteArray() data = QDataStream(ba, QIODevice.WriteOnly) - data.writeRawData('ABC') - self.assertEqual(ba, 'ABC') + data.writeRawData('AB\x00C') + self.assertEqual(ba.data(), 'AB\x00C') data = QDataStream(ba) - self.assertEqual(data.readRawData(4), 'ABC\x00') + self.assertEqual(data.readRawData(4), 'AB\x00C') if __name__ == '__main__': unittest.main() From aa305dc5ae5f463c31938fb50cd92257b0fc7911 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 4 Jan 2011 18:46:40 -0200 Subject: [PATCH 0510/1129] Lock the gil on some hand written code to avoid crashes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- PySide/QtCore/typesystem_core.xml | 8 ++++---- PySide/QtDeclarative/pysideqmlregistertype.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 54513f9..f41acd5 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -650,13 +650,13 @@ // Define a global variable to handle qInstallMsgHandler callback static PyObject* qtmsghandler = 0; - void - msghandlercallback(QtMsgType type, const char* msg) + static void msgHandlerCallback(QtMsgType type, const char* msg) { + Shiboken::GilState state; Shiboken::AutoDecRef arglist(Shiboken::makeTuple(type, msg)); Shiboken::AutoDecRef ret(PyObject_CallObject(qtmsghandler, arglist)); } - void QtCoreModuleExit() + static void QtCoreModuleExit() { PySide::SignalManager::instance().clear(); } @@ -673,7 +673,7 @@ %PYARG_0 = qtmsghandler ? qtmsghandler : Py_None; Py_INCREF(%PYARG_1); qtmsghandler = %PYARG_1; - qInstallMsgHandler(msghandlercallback); + qInstallMsgHandler(msgHandlerCallback); } if (%PYARG_0 == Py_None) diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp index 362e56d..0b05758 100644 --- a/PySide/QtDeclarative/pysideqmlregistertype.cpp +++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp @@ -27,6 +27,7 @@ #include // shiboken #include +#include #include // pyside #include @@ -63,6 +64,7 @@ struct ElementFactoryBase { QMutexLocker locker(&nextQmlElementMutex); PySide::nextQmlElementMemoryAddr = memory; + Shiboken::GilState state; PyObject* obj = PyObject_CallObject(pyTypes[N], 0); if (!obj || PyErr_Occurred()) PyErr_Print(); @@ -246,6 +248,7 @@ PyTypeObject PropertyListType = { // Implementation of QDeclarativeListProperty::AppendFunction callback void propListAppender(QDeclarativeListProperty* propList, QDeclarativeItem* item) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, item)); DeclarativeListProperty* data = reinterpret_cast(propList->data); @@ -258,6 +261,7 @@ void propListAppender(QDeclarativeListProperty* propList, QDec // Implementation of QDeclarativeListProperty::CountFunction callback int propListCount(QDeclarativeListProperty* propList) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object)); DeclarativeListProperty* data = reinterpret_cast(propList->data); @@ -275,6 +279,7 @@ int propListCount(QDeclarativeListProperty* propList) // Implementation of QDeclarativeListProperty::AtFunction callback QDeclarativeItem* propListAt(QDeclarativeListProperty* propList, int index) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object, index)); DeclarativeListProperty* data = reinterpret_cast(propList->data); @@ -291,6 +296,7 @@ QDeclarativeItem* propListAt(QDeclarativeListProperty* propLis // Implementation of QDeclarativeListProperty::ClearFunction callback void propListClear(QDeclarativeListProperty* propList) { + Shiboken::GilState state; Shiboken::AutoDecRef args(Shiboken::makeTuple(propList->object)); DeclarativeListProperty* data = reinterpret_cast(propList->data); From bcb6a2eb75a85cba86c92ccb61ae6e34123758ee Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 5 Jan 2011 08:48:23 -0300 Subject: [PATCH 0511/1129] Fixed QWidget.setParent signature on typesystem. --- PySide/QtGui/typesystem_gui_common.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index b6516ab..9c8b06b 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3293,7 +3293,7 @@ - + From cfeea7ec045c1f9e7d4652ed2f672db2977de3a8 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 5 Jan 2011 14:10:38 -0200 Subject: [PATCH 0512/1129] Fix bug#557 - "Segmentation fault in QDeclarativeComponent.loadUrl()" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The signature QDeclarativeComponent(QObject*) should not exist, it's not documented and just creates a useless QDeclarativeComponent when used, useless in the sense that it will segfault when used. Reviewer: Marcelo Lira Renato Araújo --- PySide/QtDeclarative/typesystem_declarative.xml | 1 + tests/QtDeclarative/CMakeLists.txt | 1 + tests/QtDeclarative/bug_557.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/QtDeclarative/bug_557.py diff --git a/PySide/QtDeclarative/typesystem_declarative.xml b/PySide/QtDeclarative/typesystem_declarative.xml index 05d72e8..5649bf2 100644 --- a/PySide/QtDeclarative/typesystem_declarative.xml +++ b/PySide/QtDeclarative/typesystem_declarative.xml @@ -66,6 +66,7 @@ + diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt index 5cd53e9..84bc495 100644 --- a/tests/QtDeclarative/CMakeLists.txt +++ b/tests/QtDeclarative/CMakeLists.txt @@ -1,5 +1,6 @@ PYSIDE_TEST(bug_451.py) PYSIDE_TEST(bug_456.py) +PYSIDE_TEST(bug_557.py) PYSIDE_TEST(qdeclarativenetwork_test.py) PYSIDE_TEST(qdeclarativeview_test.py) PYSIDE_TEST(connect_python_qml.py) diff --git a/tests/QtDeclarative/bug_557.py b/tests/QtDeclarative/bug_557.py new file mode 100644 index 0000000..c78aaf1 --- /dev/null +++ b/tests/QtDeclarative/bug_557.py @@ -0,0 +1,14 @@ +from PySide.QtCore import * +from PySide.QtGui import * +from PySide.QtDeclarative import * + +import sys + +app = QApplication(sys.argv) + +engine = QDeclarativeEngine() +component = QDeclarativeComponent(engine) + +# This should segfault if the QDeclarativeComponent has not QDeclarativeEngine +component.loadUrl(QUrl.fromLocalFile('foo.qml')) + From e4eaf410aff780efc4e7f5bc693a7b031938d1c5 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 5 Jan 2011 14:42:39 -0300 Subject: [PATCH 0513/1129] Fixed QtNetwork test to use '127.0.0.1' instead of 'localhost' This is necessary to make all test to be able run on any buildbot machine. Fix Http server shutdown sequence to avoid deadlocks. Fixes bug #587 Reviewer: Hugo Parente Lima Marcelo Lira --- tests/QtNetwork/accessManager_test.py | 12 +++++++++--- tests/QtNetwork/basic_auth_test.py | 19 +++++++++++-------- tests/QtNetwork/http_test.py | 12 +++++++++--- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/tests/QtNetwork/accessManager_test.py b/tests/QtNetwork/accessManager_test.py index 172dab8..65a8480 100644 --- a/tests/QtNetwork/accessManager_test.py +++ b/tests/QtNetwork/accessManager_test.py @@ -19,20 +19,26 @@ class AccessManagerCase(UsesQCoreApplication): def tearDown(self): super(AccessManagerCase, self).tearDown() + if self.httpd: + self.httpd.shutdown() + self.httpd = None + + def goAway(self): self.httpd.shutdown() + self.app.quit() + self.httpd = None def slot_replyFinished(self, reply): self.assertEqual(type(reply), QNetworkReply) self.called = True - self.app.quit() + self.goAway() def testNetworkRequest(self): manager = QNetworkAccessManager() manager.finished.connect(self.slot_replyFinished) - manager.get(QNetworkRequest(QUrl("http://localhost:%s" % self.httpd.port()))) + manager.get(QNetworkRequest(QUrl("http://127.0.0.1:%s" % self.httpd.port()))) self.app.exec_() self.assert_(self.called) - self.httpd.shutdown() if __name__ == '__main__': unittest.main() diff --git a/tests/QtNetwork/basic_auth_test.py b/tests/QtNetwork/basic_auth_test.py index b095f09..bc41d65 100644 --- a/tests/QtNetwork/basic_auth_test.py +++ b/tests/QtNetwork/basic_auth_test.py @@ -15,19 +15,23 @@ class testAuthenticationSignal(UsesQCoreApplication): self._resultOk = False def tearDown(self): - self.httpd.shutdown() - del self.httpd + if self.httpd: + self.httpd.shutdown() + del self.httpd super(testAuthenticationSignal, self).tearDown() + def goAway(self): + self.httpd.shutdown() + self.app.quit() + self.httpd = None + def onAuthRequest(self, hostname, port, auth): self.assert_(isinstance(auth, QAuthenticator)) self._resultOk = True - self.app.quit() - + self.goAway() def testwaitSignal(self): - http = QHttp() - http.setHost("localhost", self.httpd.port()) + http = QHttp('127.0.0.1', self.httpd.port()) http.connect(SIGNAL("authenticationRequired(const QString&, quint16, QAuthenticator*)"), self.onAuthRequest) path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/") data = http.get(str(path)) @@ -35,8 +39,7 @@ class testAuthenticationSignal(UsesQCoreApplication): self.assert_(self._resultOk) def testwaitSignal2(self): - http = QHttp() - http.setHost("localhost", self.httpd.port()) + http = QHttp('127.0.0.1', self.httpd.port()) # Using new signal slot syntax causes a segfault http.authenticationRequired.connect(self.onAuthRequest) path = QUrl.toPercentEncoding("/index.html", "!$&'()*+,;=:@/") diff --git a/tests/QtNetwork/http_test.py b/tests/QtNetwork/http_test.py index ee6eeea..b6bfea5 100644 --- a/tests/QtNetwork/http_test.py +++ b/tests/QtNetwork/http_test.py @@ -16,18 +16,24 @@ class HttpSignalsCase(UsesQCoreApplication): super(HttpSignalsCase, self).setUp() self.httpd = TestServer() self.httpd.start() - self.http = QHttp('localhost' , self.httpd.port()) + self.http = QHttp("127.0.0.1" , self.httpd.port()) self.called = False def tearDown(self): - self.httpd.shutdown() + if self.httpd: + self.httpd.shutdown() + del self.httpd self.http = None self.httpd = None super(HttpSignalsCase, self).tearDown() + def goAway(self): + self.httpd.shutdown() + self.app.quit() + def callback(self, ident): self.called = True - self.app.quit() + self.goAway() def testDefaultArgs(self): #QHttp signal requestStarted signal From adb9268807aca51c9332e266d6649005c5e9577f Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 5 Jan 2011 19:11:53 -0200 Subject: [PATCH 0514/1129] Only try to play the ogg file if the system has the capability to do it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix a failing test on macosx. Reviewer: Marcelo Lira Renato Araújo --- tests/phonon/basic_playing_test.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/phonon/basic_playing_test.py b/tests/phonon/basic_playing_test.py index 45f6c12..4eb2ccd 100644 --- a/tests/phonon/basic_playing_test.py +++ b/tests/phonon/basic_playing_test.py @@ -38,9 +38,13 @@ class TestSimplePlaying(UsesQCoreApplication): del self.source def testFinishedSignal(self): - # Should pass if finished() is called - self.media.play() - self.app.exec_() + # Check for ogg support before playing it + if (phonon.Phonon.BackendCapabilities.isMimeTypeAvailable('audio/ogg')): + # Should pass if finished() is called + self.media.play() + self.app.exec_() + else: + print 'Ogg format not supported! Playback test skipped!' def testMediaSource(self): self.assertEqual(self.media.currentSource(), self.source) From 5985c015b2b7efe3dad01e37b869a765dd1b8588 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 6 Jan 2011 13:32:55 -0300 Subject: [PATCH 0515/1129] Fixed QTreeWidgetItem.parent function policy. Fixes bug #585 Reviewer: Hugo Parente Lima Marcelo Lira --- PySide/QtGui/typesystem_gui_common.xml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 9c8b06b..676829e 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3232,13 +3232,28 @@ - - - + + // Only call the parent function if this return some value + // the parent can be the TreeWidget + if (%0) + Shiboken::Object::setParent(%PYARG_0, %PYSELF); + + + + + + + // Only call the parent function if this return some value + // the parent can be the TreeWidgetItem + if (%0) + Shiboken::Object::setParent(%PYARG_0, %PYSELF); + + + From b6343a7674347d1ddae27f61965eb83dd5b2223b Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 6 Jan 2011 13:32:35 -0300 Subject: [PATCH 0516/1129] Created unit test for bug #585. Reviewer: Hugo Parente Lima Marcelo Lira --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_585.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/QtGui/bug_585.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 8906a93..6032808 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -27,6 +27,7 @@ PYSIDE_TEST(bug_547.py) PYSIDE_TEST(bug_549.py) PYSIDE_TEST(bug_569.py) PYSIDE_TEST(bug_576.py) +PYSIDE_TEST(bug_585.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_585.py b/tests/QtGui/bug_585.py new file mode 100644 index 0000000..7c37150 --- /dev/null +++ b/tests/QtGui/bug_585.py @@ -0,0 +1,26 @@ +'''Test bug 585: http://bugs.openbossa.org/show_bug.cgi?id=585''' + +from PySide import QtCore ,QtGui +import sys +import unittest + + +class Bug585(unittest.TestCase): + def testCase(self): + app = QtGui.QApplication([]) + self._tree = QtGui.QTreeWidget() + self._tree.setColumnCount(2) + i1 = QtGui.QTreeWidgetItem(self._tree, ['1', ]) + i2 = QtGui.QTreeWidgetItem(self._tree, ['2', ]) + refCount = sys.getrefcount(i1) + + # this function return None + # because the topLevelItem does not has a parent item + # but still have a TreeWidget as a parent + self._tree.topLevelItem(0).parent() + + self.assertEqual(refCount, sys.getrefcount(i1)) + +if __name__ == '__main__': + unittest.main() + From 44b71a0ff22cf724b394003131b344ff013a0886 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 5 Jan 2011 18:54:02 -0300 Subject: [PATCH 0517/1129] Fixed PATH variable for tests on win32 platform. --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f4c73b4..f12e62c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,7 @@ else() if(WIN32) set(TEST_PYTHONPATH "${CMAKE_BINARY_DIR};${CMAKE_SOURCE_DIR}/tests/util;${testbinding_BINARY_DIR}") - set(TEST_LIBRARY_PATH "${libpyside_BINARY_DIR};${pysidetest_BINARY_DIR};$ENV{PATH}") + 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}") string(REPLACE "\\" "/" TEST_LIBRARY_PATH "${TEST_LIBRARY_PATH}") From 42e52dec9cd5db837a9fda2663b9c873dac1cd7b Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 6 Jan 2011 16:23:16 -0300 Subject: [PATCH 0518/1129] Refactoring to Phonon basic playing test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also replaced the ogg audio tone file for a wav one. Reviewed by Hugo Parente Reviewed by Renato Araújo --- tests/phonon/basic_playing_test.py | 58 +++++++++++++---------------- tests/phonon/tone.ogg | Bin 4300 -> 0 bytes tests/phonon/tone.wav | Bin 0 -> 8942 bytes 3 files changed, 26 insertions(+), 32 deletions(-) delete mode 100644 tests/phonon/tone.ogg create mode 100644 tests/phonon/tone.wav diff --git a/tests/phonon/basic_playing_test.py b/tests/phonon/basic_playing_test.py index 4eb2ccd..49df7d5 100644 --- a/tests/phonon/basic_playing_test.py +++ b/tests/phonon/basic_playing_test.py @@ -1,34 +1,35 @@ import os import unittest - -from PySide import QtCore -from PySide import phonon - +from PySide.phonon import Phonon from helper import UsesQCoreApplication -# XXX Hack to get the correct filename -example_file = os.path.join(os.path.dirname(__file__),'tone.ogg') +sample_file = os.path.join(os.path.dirname(__file__), 'tone.wav') + +def checkBackendCapabilities(func): + def function(self, *args, **kw): + if Phonon.BackendCapabilities.isMimeTypeAvailable('audio/x-wav'): + func(self, *args, **kw) + else: + print 'Wav format not supported! Playback test skipped!' + return function + class TestSimplePlaying(UsesQCoreApplication): def setUp(self): super(TestSimplePlaying, self).setUp() self.app.setApplicationName('Dummy') - self.source = phonon.Phonon.MediaSource(example_file) - self.media = phonon.Phonon.MediaObject() + self.source = Phonon.MediaSource(sample_file) + self.media = Phonon.MediaObject() self.media.setCurrentSource(self.source) - QtCore.QObject.connect(self.media, - QtCore.SIGNAL('finished()'), - self.app, - QtCore.SLOT('quit()')) - + self.media.finished.connect(self.app.quit) self.called = False # prevent locking with: # request to play a stream, but no valid audio ... - self.output = phonon.Phonon.AudioOutput() - self.path = phonon.Phonon.createPath(self.media, self.output) + self.output = Phonon.AudioOutput() + self.path = Phonon.createPath(self.media, self.output) def tearDown(self): super(TestSimplePlaying, self).tearDown() @@ -37,14 +38,11 @@ class TestSimplePlaying(UsesQCoreApplication): del self.media del self.source + @checkBackendCapabilities def testFinishedSignal(self): - # Check for ogg support before playing it - if (phonon.Phonon.BackendCapabilities.isMimeTypeAvailable('audio/ogg')): - # Should pass if finished() is called - self.media.play() - self.app.exec_() - else: - print 'Ogg format not supported! Playback test skipped!' + # Should pass if finished() is called + self.media.play() + self.app.exec_() def testMediaSource(self): self.assertEqual(self.media.currentSource(), self.source) @@ -57,18 +55,14 @@ class TestSimplePlaying(UsesQCoreApplication): def state_cb(self, newState, OldState): self.called = True + @checkBackendCapabilities def testStateChanged(self): - # Check for ogg support before playing it - if (phonon.Phonon.BackendCapabilities.isMimeTypeAvailable('audio/ogg')): - QtCore.QObject.connect(self.media, - QtCore.SIGNAL('stateChanged(Phonon::State, Phonon::State)'), - self.state_cb) + self.media.stateChanged['Phonon::State', 'Phonon::State'].connect(self.state_cb) + self.media.play() + self.app.exec_() + self.assert_(self.called) - self.media.play() - self.app.exec_() - self.assert_(self.called) - else: - print 'Ogg format not supported! Playback test skipped!' if __name__ == '__main__': unittest.main() + diff --git a/tests/phonon/tone.ogg b/tests/phonon/tone.ogg deleted file mode 100644 index dc1a455d3bab7c403ce4e60717b157709d4cc479..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4300 zcmai24Ny~8_P?nJ2_TISX{fRP7Y&7nuq6oAuw|AHspdgI9trYMYzah!@F59d*JFrp z@=z-&%3k*76or_mP^HMA zt+j6zkBmy9Av*BzV==ROu12st3NFQc|&S(rN`$Y%T0Dq00OaXY#(r|N{80>*{!U(77%8tjr6%;4Vibt!8R z#36h)x12>%owSl$!G`Xy9K{5;yG7ybcc%4-bI=4<78~?sXG2`*muEU^L+|?z&PBQe z49*j={Kcfq-VYqp-%`#9R$3l+44WMo>?P9CD~lOPr^Hv{T}=uQWj6~$YA_S+I?fXI zv!?nvmoD?-zx7Y>2)Vp1I#Dc=z@tjvTOwO3Q7x5}rZknOohwZ_SDtpYJpEC52D{>M z`?2)KBdXa<$7rZ^i=goi-oE+y_S=H?HJXZ^XHXX95{yy58L#gUcJ0sY&1oJ!aCSI< zYQTSLz}3bA7;>O?gIaTRUH{egr!>m`cMCr-;fKP(m*Yj8@giO{$s1SrJJ~!ufgq;g zq`z4ayh|B8u6zaBuHu~+wXv7Ji+%P<5U8*t6wc?Ei#Qj-8)U$OB4n>JY)L6v0#{HT z`Tggx4KH8__tgHzTs3`LU53pqY7onAqer>gH336q+ZUK_PWSMVz)g3z)xc_A__#{k z>@#9$YPLl%Z^r8m#1fx8X>L6^r&G=dU3Gf<=#YD}lgTg-b6zVgZWgZ$;LDlUIT@}c z!`hTN-SU|c7L2O2%|1gTV!OP@urTavnfX|73szKp+AJSoq{HZ6SuOv##GvMW3!iX^ zTgFwk<Z%k@Ln)UA3gN#J^W zMnO=qthxwCFI$pSG$|(WZpezK1NRMYcKxQyPqo>9auVFVp@J9Cr^KAXm|ci<{YT*ZmRCC ztX`?C^{r~msnQuo+VduRS4aP6`z3RBDR|HzbD|Zzr!wa}pA!YyG~h3KXty!!GB~t2 z`njhAfYA9m*BIM5l0XJ5k|B#^fJ7Yj`xyh&#bD7wFgW%ELS6`Mfgo#`)rz{vg0N&d zf0?(oP2kw}30u?6+~z7+x4F13!YAxpytFhIt_#(8%6~dw02K-f8KW7hdetvSX@Gb-HI( znP3ref}cy^u#Ak-ouM(TM4TZXV>#HU!78ykk6~XIZi(57E+z;7h?F31Z2V zhh$MKx$Y^F410?_M56D+5|3!f2FXIBNHUZ^8!WpfmVE9hSsa#K_k4SAqw2;sQ3||T zfvQ?+EPdUYpWgIXl!#>$wOz6_9FkBhNs!1=#FCT}S;`~HUTbL#P!mPhHb^AHl55}R zOBzdW6-(0h%C0?s(fV{gyoz`JLA^Hzb{d&W56Z#4R!9q9SV=)XFA#yD!49O!HAJ-a&m zz-7#Tb@ZUIxA*M8R}^*Bv}!3@9SwY|3!mybdwh?$&42J7~y} zyTVFj`kAp}CV3z06!RUq$~eNz(e5E~x!Nm!7ED|#oM>rqCl27+dD5v(zlV^wX|1HZ zzw3(hYpm0g$O+KSr{)?gS5j-%XEK9UI;j}-P44)g_W2eV9{-{U?A!urQD|DZj%;7oh+*- z2-Asra=N8~5>-}92=U>1A{KT<5dGz3Y98O(Lgt0Qu0T{hkr!Y|O^Y2;F;iV^yD|+W z$#YE>Q0}c~#}NHPp7H|z^7BNFiBfJbd#2Tb@NO}_&5*THM+lX+5tZbOFo&s_7WgqDrv*L+MQkLFOQs{} z-a|7295-79bZ@<9j9-8`Nsi-SMF7+twzPE=Rhend>rxnKCuFe&gLB8xOV2KwV|TJL znVa=&h>M<;3BF}3-6H+GGG`)uam^mW4=-mDLT^13)Xp5J=kn&X$sE{_{TzA2RqD#G zz>38|e(N={gpc7cc+{i2wKt^A-{uA5%ncxDUTd)g){RRbci}L34v3a_Ep@1Y3oT)2PPR5uHZX!5=GFa zeuV)v@=(Dv>sBg{2=W>;Az^eraf)x(cwJ2+UElhqLL6!es zMi`*ZTAu`8YYTfL-CmWy>TY|@%zIp@XQz!x zyLRBuyZBQ!GT}DD9&3UfJ8sfc;P*N;5T3RuLg4ESD8X@n4`j49l{l#+Nk4CWBXx9K zNhJb6wv)HsO6G!=P`ZBb3Z?35#BN+~O+6X_DM!Gov?ip21QzpEX%D}1o`n2lXZAn> zrOILJ@&J6uDyqzzj1HkiXV0myu9BX1Zn>;;?+ zj2d?+<+LE#KBsjD9k%jLOHzmg*H8o-RBa;$mvWblnQLE5)q()gHPk7*wvKsxeZ6~whZf+A&`p~9S)}Hz zt*orvU)wQuXAN&>mZtNQFC4sWWU8an?N=2C+t_v?cL-f?CsP-4N=;Wr<%px_A9-7N zJpaGF{^on7haTJyw21!giPX2Jdj5e>s_=Bh2fPPIUwgx);{WVx;hO&NmD%N`1>s-5 znR@r5x4-$OSd6gmIEh<^mY@6Cd*8&^rSaad+q@4`_I=%bWjL90@OB~Xrzig+++3N( z5O(!&;>H&b($MLYeMh>#7*1x}dEgRFJ?gO-gvg1WvVRTI&|@)8G@t5M`d(5y+F9u)FC-un5E=szP4n?C>m diff --git a/tests/phonon/tone.wav b/tests/phonon/tone.wav new file mode 100644 index 0000000000000000000000000000000000000000..2fa06a72a996900a3991c639a1120497a4d02f0f GIT binary patch literal 8942 zcmXY$Wl$Vjw1puAcX!v|8r-GjTkYjA=Fd;MO$ zI)A!PovN;`I%|J>t?ldTY6ez;Lvx_cc3piGxo9u@$?IsNxqfOQ?1haYG7}gVl`vm>~i0;*=N}Q zMeuysMEFxoDeeovbb<3?%EgI`$rrgUGF|uzl;NIYrotD(UI!2Rcl$i>9CTT*ud;%f z<{OM@O{}Ii7pOJHIEGRiFdwf*83?{#`p=ZjFhu*I+FuH8 zQXC@5yf*BOXFQMkckt_MOU2V4Mj!W+JExm5KZUCJN*xPYvT5m6$(9NHvCdIL)B&;% z>4>O8tohOK!;r`e!bnGCPTKRRz}SxoGAZmC_BoveaitYilJ%)AkGif5d>iYYG5D3R zp|+QIY<0GQ!R^dJ_6{||5^ z{2;s_uoF~)F`PD59G!sd42=mA^*8h3@ciJ?U|(%@-*n%=Q5&Zgq@XV~FZ_{Lfj#?- z-j(3bU|)m7c4s)hAASs807PZO`iWk$p4LDVYpD^dyQ3VMJE z;4KnJ)}YGJuSLtpX(WD0amxtG$t-}EnpWX{)-pLc#W58PwK`2d+ar5l4JS=b%%5K+{pS7ioZ*<|5_h|xgak|utpd~J z)2A5kS#a7dIQ`{b%Pjgxdybvpt`KgqrepC1Cd4zd{O_1Y; ztA&@P@0`DNuyNQBQXIXHxs7{^w*X!M*MJ2)3qBjmhS>~%j>rso8^{bdgze7E_?o++PQi7!H=N@_-7Nv%Trs^N&Kq&2TYql>Pmw~v_rhoIz8 z0bwR6QXVX4!JEphxYh4fOY zI%SKbNvZ=IL46Vf*_hHnZKJEjOvn96#HVUxn&r|9?aBq7b|&QA`7t1;2t1 z2krq)q9@jt$H;4CQu3jk)B^npD#yj(C%pa(X&-hn!3*2Q5KK@CqnK zG9YJAKF~U%ZpU6vXiC19{wTXK|5Ax_<<+{5CUl2ZpY({?)b)kBRh4b<4;SMb)(!3u zp%{q)xiytuO;BISeN|mJijqHEy+a_Vf?2O#03jtQh^yJFsVHX7S*z6qJ=f%KfYIK+{!! z+}O@C%+AWW+g%hU2+s^W4w*;XN5x>S;@a_D0GjZf5I`sZGVrFj%NTVO89@#435@nj z_J+IHI1SsDS_B$b>FsJ9E6>SBi~9;rb6scII=y{xxEo#&ifA3E+aZI5mAtktUU zFRsgbl=UiYF)1oOFGeY9pQ=G=A~k@z;4#q%>;?Ntb`)NkZB$20MLb(_bQ+k|pNA_p zu5hmf8&%r}dg_OoC;rS?tbE@(+Q*;vGn;b#5Ev2Tk(E$p)@aa$oliIaX%ppW?Do{_ zp|5hlU%^+xIKpkwGT1M;7`zAY0k{Z^;+JqAuwCfva4m#)h(O>ozaQRc_hBbKI|j=F zV@>@C&Ce?D<$@(7gi5%BSZ5jT|6$+GS;Z_EO(~4%^*!jAYWh%jqw;IXnS#RXvUI_e zx`d`!!{}|A3^kq{Nm_#V@e}kSS(4vV9B7EB?wFML{v<@&`7BgkchSf4w>1q7=4}(* z*@J20KW9&VId4Yqv7F$~ws1)BV?{qo(-hyF^U|3#v^B$9yF0A9IC}c}aQfd4dK9XM ze1f`%VZ<5WH}Qdh8!(M$!*^lzFgmCX1V`vb-~)Iz?6Zfa%N_gYR_><51||>-FDiIQ zaf;OP2D0y*d3q$do4No$60Ome`XE2+h_o~2r(3|GjQyObfDnv?iFZaDf0{ULP` zQphBD16o}miPTCCp$5*>lx)^+?& z^P%AxI@>XikMKLmbon&Z|Fm=r5=`bS=j`H~B|U6mGVtiY&X5>{2ud9@f>p!w0-u0X zsA47KKjOHtI_O!XW0+m=qQ8l+k=LZFt0UUR!FnRdzM<^&E`J7TLD%okZMG-d=uN0mdQ9i2U#=bUIc9FAQV>vp^ak3~=F-u!HF2 za0!G)$V`BvpSL%U`xB=`+wT?@#(8>M8r+c5+r^&4F76@QA+`7+sZ>3=6{Cz!{^MO~qR6jib`=>cd40^l~dNphy}{~rrU@x4h` z)8JX}^F)eA%6Dpv8*AI{_XH1Jn)o<3ylk*V+UGib$h^$yC=e;uATy!VrT$e{^ZX0* zOquG;dE$)UcB7C|*s-cWK?=rfNhTRx-hVb}JJHIc=cshW|dzB8R6&4+c3l~X0g z1!LK5kU}yOVq$lq;%UVcJu)ZB8~j6L17Cn>QVKbMilO&J$HX-!`lc#o!gK2iUzfeE zZmD-~-RT+}7#(At_5KyNA+-1J@hQ_)j$uA6(VNnr6+fRN=x`YQZI*4F=n(8$;W_9- z_vZ>$4I4+Ap$)P1xC49@pg@o&WB@~WI_?m2g!+tZ4^0cw^T+sDdbYa=JBV73n4%2} zv`5u?6>_8qBK&-@?7B=PN7lQe>k&)lGeTqB1IAsiS_JC{s)kDy3$t^+XH=zlB&x>Y zqnYT36bxCBNMbE~bCR|A|&hXC3FSuA5QWg1=u_dYV@BWBU z`trTZtYS76Vv-vkL)d6vOGp$`EY|EOsF=Jj!MIX z;Ar?~zyZKb$OjJagE)6A7A+8t4+{<6@i+I?^6GX~b+ohLG0!k!*R@u+Q#vQJBntBD zaaN!8IO*TJyve&7A4EQi#l^DnFXmDNgHwEF(Ca3wSjzt^a4C2 zP7;;DesG0!iQ-KA5TzNblkg_lB;6+aQ@(zQNTo$xRMYtmroR1Q!70xL`YQAGUw_sZ zaI8JthC=^HWXsj7WN2Q|-!pczMA{iR7rP&M&-*`3TY3C z4BYn_q*@DBA`iN2Ag^rG< zYjt*&sFI5O3)#5ztYqH=|JanM%d~$ftmJh_=i5Xs@C*2a)JA?yrO+i~Hse&1a#O!# zHs;zFah40$AQ~oHKX>07d_0~uyYb6&vv5!QgnU+z^Co|zD3gq|lDPVe&I_XjGf5i; z$23=FFCpJ9fBj(luwO_!v@*63*Ncw?R)Ky10G{A&a9=V1qQsFdp-Mq?crz^4L)+!1 z{Y@)f(;@>-ZCy2O1s17#;mf@2>|f5DJIdODub(VdPA87W_YZa&v^4+xRux~mUGO<4 zBBLwjrx_0Cj9_SKqD{(@>6+aSE>&^BlQ);%z)6C`OM9w=5>wT$RjSM+w7CP>LNF!J}A6V!)vn`J~GX>O0~zkba<@8D&QtT z{-H9+r>NH$Ron%emFAfRT56yUu{?bV} zm#6q$8ZFAlpT*&DcJLV3W8F;ubz|0j+;#9;_s>?B2Cf>`a@V5%+~myORL>-Zc%PUF zdK*=i(oI@}NEiSng9uUt`Is_EQ;%+o?M~22nM$9{HY?~aDXE;SGi&ba_}2G!gfi8+ zAhq^zd*+W1V+E@s&tsu7i8;Atm1fPy`bWkNmY#OP&R^V{yi@&51Mh~oBf7$u&}rCH z+z$RR5D#F0VtfkD2#Y`~guf2^5^Ng)`qI4o-KretZJNz*ouAc}*DzI9mfaQ05P)$l zGDnam6wuSSQb>b!G|Y(~9p_yr>;(#I(!zvJHz&I?lgY`L*SBP=Bhy z62rA6;3|GY_Kos&4MV-E^WqjpwtP;}Zfjn%zHb7?g4@C_hSSiuv5UA3JPGIn(gA5e z1>Xeusrm45#Iq2az)Yy?ee2HbY+`rLa@aUfpQ>4^k}CI9!c1t0`!4GV!-qd|+ZC(V z7R;t(Ms)hH9i2^=>)b2RB`x{avu~%DCgT#Yv6WE~5DR6v z>Q$kDGlrVFD?8?BquHKf=dj4vjGPlCsoVbkc z6sJVxIPd6r+5kn1ybN-IKZtLLbHq5XhZIT)pv6apLw;&3IV!yJ}@ zA{o%q*bba5z(#mOh$X-YRH$YhVfipk;o=CPko17xzO!C0-9{WYZA#32&!_4Rs1GXT z%G?m+6Nu+jW==ghx1YP|zWjT(dOUitxO<}&*T7x#yG*|5W3GQDDzzo?Ra|tm6n&p! zNFD-biGD;q;!UD7s6$F3zo6F9FUR2GYm@G!-On1#yIG8`cvHLC7}<{P#SFikY?@bH z1%LDZ0U3l@LGEKgv_zy_xk@&qbYYXbmXUT3oVh$gU~u?;pi8I`vK_UDX~pRP`h*t3 zAHq+90znE$#SLKSC{`p-Xjvc+oEKK8zqIH!c1~P?Vd@BF6Cf zK>T;?iu*kC1d#IpF(E+_HCOUK-&J5eu?55aY!8$dBFF%ZI4N4_us9#V8ycb6G;CFGh*Rz^32{a&TrK^(U36g@sxjd$9wT$+MP1}gIvx{X@)R7;3 zjUCd>`E`#fKbFkq|DAm^JuTTK!7TP=lnKq5QV9`cg7}azMKjZ5DSq zaT#LBcFvu`^JNy*|J9#uE$E^R#EtdNNdJ1Yv9^mno@5H(sNs_l#Yn$ae0vV3!)^4` ztkgQ!f#BNZx#CmkuNLeWc8o-!{jtBHo3#nR2wsF4fEO5qYVUb;Cz2;@HRz6iyw7t_ z5!WyWjJ3R3njxc((m8p>eW@IgP`)Mh2TX@YFL%W^Dwgiec#Js@T<9uov93R@Ixe*@ zY|BZ_=t&7m)QP(oeL~x%z{rB6^I!w9oG1oPf$U@&^wEgv47 z6kE8sI{4e=Pd$S*Yc{u-5J7@2m!}e|iPQgW>}iRyvv6*3=Ybvh(E=wz+7JP#e=u&i zG<*tRLAXZHBzys$;e~P57&g=m#DfsEz$bqHcpJHsohodJ7M8{_dZQZi$}O^=#LWbI zxsWW=r-Xyet+y*i^T!htLmNGc?cW;pYK1Edis^ZNS%GPJNvQZ+F@y93YA+ceVZchL zVwDnoKz~vp`9Fvub}>5f5lNzH0$F}}OGVY?V>PCY&21lho(z#DI_8vD-fo@lKR(@O zzQ#2upe=q?_Ow68D67c&My$jPZZ8wyRe! zEvQa$kFfRGbdZ}2>o_XKOCs{6vPIHEl27CJVtk@FX$q7C(pzwV_=%WE)B`0*H_0kg zdwO*=DQ+MUlj@oIESIIIr);WPuc5g0Zg<$=&GD$&&0qeT^?SA_6=#h&`r(CIu~n=M+1t4n*;)+5O$yh$BR8iy+js; zz6d&jEBUN>JakF7PqGR%9WzkSwo}tlV3Nug_T!yl!=G6>yuQP{9={kqZ8oakAJ&=K zZ2t316X6{!rIc>DvtW+Ev8)}14?7wGo+=X^-H@;M>wWQb}zmhk$tIiikj#6p=pS@*<%*`jZ`yHF8WuCd7@sh#DZq~M24Kg)Muc@}K@W)+a&amoO|<@jG2HU5ouBiZy8%oY-VrDi%8vYwYQTKQ z?cYSn4tYVbuXQ#DHdj--lkGfybn4CA%Kz3oqH z=8Jn%qa(w8+?^MiPwHAKCrWe+`m)Q@nNofvyo()-dPVzA;Udp~N?~Vu#tq%fURXbH&~=UU%=UTczZ%36R*RH|x~y#60zMNEB?uCdfgXGel$@MJ6Om(~ zB|%R9_k2P;mt9O8Os&tDy)&HF<~+xyI3pD!;=(t@euZiO=wFD1HA|0Y0>}IZ9(J|1 zgw%^v%a?^0?&P#*Fs43F#KeKnd`gS@mh4Ts3$lYJL?oz8f|2JagEWKa#n?Yka-x>u zloMMJP-<88_~&%89C{`RXNNl_vk6 zoa_vXOt~(^ub$nG__M)qfpvh}ROppNkz9vLp5}dh29p5GOLo@IjqdEQeZS9veIca? zN7OZpF77-2H6TxLBk&L|0|@*oRtz&1?gFLOM*(m@e{Xj8n@*o?uUQBfKh(?9s8o)V zy(%s$n9F6wQhVxgFtBxdMRtB^qJ3zpN2L8#qk1hj#6n7*e-5=-nO-T<$WhRLziemXYBFP@rY0j1Ut@;HkZ%TH?%jmvFWJyAnN6KiueD~V8Y z^6iw9n|2R%eq(pXQpp6=AJP1+G9i~CffZul`N}E*u~2ur zWA(2Et0~11jXq3ALldUXrV?IKnvcvzrza=F61-xQqAt?@p>RSz#0LCL6a*u||47~B z57cWT}Qv)>2wvxLa4n7}GpWXZAx>>rX0wpILoLBhEMR%kH zl-Sg}b#55-nVncKJG^sU^xW~u@aGGb3Tr@$qE9gIaVhvKKo#U~jesCLH#7|iM6DrY zL-zyk!((BOJvdxo_Fh)PrX+*kT4HJ<3fqze!U*0Iwl`;Fq2vU%e!N&Woiv)&Ki+B6 z((^N}DzB8eFfr$SMr#Tp(KYT1q!1fw5;QMN1ARa*umU1T0~trf(d(oCiHnDnKAmxx zgD(^-FKh|!(i_ki^O$+FG`?=Pn|-9f^qGB+*F)r;RJuZz+H-AvL%QjtRlof= zmqQOlh#{AQ-i7)ii%?YX=H&c>71nYo@Clq4T-6H`l%ffVwI zM1|(iTSOCZ4%{W(pm@?=MXARsBs@q~Ojpdlmd{!;Q*pK~sA;V|xi=D;sCUoHtls=R Ga_~P Date: Thu, 6 Jan 2011 18:45:44 -0300 Subject: [PATCH 0519/1129] Fixes connecting signal to decorated slot. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decorated methods on classes derived from QObject are not called when connected to Qt signals because they get a name different from the decorated method. To solve this decorated methods are registered as global slots. An unit test was added. Reviewed by Hugo Parente Reviewed by Renato Araújo --- PySide/QtCore/glue/qobject_connect.cpp | 13 ++++++++- tests/pysidetest/CMakeLists.txt | 5 ++-- tests/pysidetest/decoratedslot_test.py | 39 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 tests/pysidetest/decoratedslot_test.py diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp index 91c830a..f6b0dce 100644 --- a/PySide/QtCore/glue/qobject_connect.cpp +++ b/PySide/QtCore/glue/qobject_connect.cpp @@ -1,9 +1,20 @@ +static bool isDecorator(PyObject* method, PyObject* self) +{ + Shiboken::AutoDecRef methodName(PyObject_GetAttrString(method, "__name__")); + if (!PyObject_HasAttr(self, methodName)) + return true; + Shiboken::AutoDecRef otherMethod(PyObject_GetAttr(self, methodName)); + return otherMethod.object() != method; +} + static bool getReceiver(PyObject* callback, QObject** receiver, PyObject** self) { + bool forceGlobalReceiver = false; if (PyMethod_Check(callback)) { *self = PyMethod_GET_SELF(callback); if (Shiboken::Converter::checkType(*self)) *receiver = Shiboken::Converter::toCpp(*self); + forceGlobalReceiver = isDecorator(callback, *self); } else if (PyCFunction_Check(callback)) { *self = PyCFunction_GET_SELF(callback); if (*self && Shiboken::Converter::checkType(*self)) @@ -14,7 +25,7 @@ static bool getReceiver(PyObject* callback, QObject** receiver, PyObject** self) *self = 0; } - bool usingGlobalReceiver = !*receiver; + bool usingGlobalReceiver = !*receiver || forceGlobalReceiver; if (usingGlobalReceiver) { PySide::SignalManager& signalManager = PySide::SignalManager::instance(); *receiver = signalManager.globalReceiver(); diff --git a/tests/pysidetest/CMakeLists.txt b/tests/pysidetest/CMakeLists.txt index 4b94a2a..61ee424 100644 --- a/tests/pysidetest/CMakeLists.txt +++ b/tests/pysidetest/CMakeLists.txt @@ -72,9 +72,10 @@ target_link_libraries(testbinding add_dependencies(testbinding pyside QtCore QtGui libpyside pysidetest) -PYSIDE_TEST(homonymoussignalandmethod_test.py) +PYSIDE_TEST(decoratedslot_test.py) PYSIDE_TEST(delegatecreateseditor_test.py) +PYSIDE_TEST(homonymoussignalandmethod_test.py) +PYSIDE_TEST(list_signal_test.py) PYSIDE_TEST(modelview_test.py) PYSIDE_TEST(version_test.py) -PYSIDE_TEST(list_signal_test.py) diff --git a/tests/pysidetest/decoratedslot_test.py b/tests/pysidetest/decoratedslot_test.py new file mode 100644 index 0000000..63a5be7 --- /dev/null +++ b/tests/pysidetest/decoratedslot_test.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + +import unittest +from PySide.QtCore import QObject +from testbinding import TestObject + +class Receiver(QObject): + def __init__(self): + QObject.__init__(self) + self.called = False + + def ReceiverDecorator(func): + def decoratedFunction(self, *args, **kw): + func(self, *args, **kw) + return decoratedFunction + + # This method with the same name of the internal decorated function + # is here to test the binding capabilities. + def decoratedFunction(self): + pass + + @ReceiverDecorator + def slot(self): + self.called = True + + +class DecoratedSlotTest(unittest.TestCase): + + def testCallingOfDecoratedSlot(self): + obj = TestObject(0) + receiver = Receiver() + obj.staticMethodDouble.connect(receiver.slot) + obj.emitStaticMethodDoubleSignal() + self.assert_(receiver.called) + + +if __name__ == '__main__': + unittest.main() + From 36b7f922b2de2bffc80b60e9a8e1536083c2cad6 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 6 Jan 2011 19:30:03 -0200 Subject: [PATCH 0520/1129] Fix bug#560 - "Lack of QtCore.Signal documentation" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewer: Renato Araújo Marcelo Lira --- doc/CMakeLists.txt | 1 + doc/conf.py.in | 4 +- doc/extras/PySide.QtCore.Signal.rst | 144 ++++++++++++++++++++++++++++ doc/extras/PySide.QtCore.Slot.rst | 95 ++++++++++++++++++ 4 files changed, 242 insertions(+), 2 deletions(-) create mode 100644 doc/extras/PySide.QtCore.Signal.rst create mode 100644 doc/extras/PySide.QtCore.Slot.rst diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 7f72f41..c460543 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -28,6 +28,7 @@ add_custom_target("docrsts" --documentation-data-dir=${DOC_DATA_DIR} --output-directory=${CMAKE_CURRENT_BINARY_DIR}/rst --documentation-code-snippets-dir=${CMAKE_CURRENT_SOURCE_DIR}/codesnippets + --documentation-extra-sections-dir=${CMAKE_CURRENT_SOURCE_DIR}/extras ${CMAKE_CURRENT_BINARY_DIR}/typesystem_doc.xml WORKING_DIRECTORY ${${module}_SOURCE_DIR} COMMENT "Running generator to generate documentation..." diff --git a/doc/conf.py.in b/doc/conf.py.in index d2d7408..b984126 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -42,7 +42,7 @@ master_doc = 'contents' # General information about the project. project = u'PySide' -copyright = u'2009-2010, Nokia Corporation' +copyright = u'2009-2011, Nokia Corporation' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -68,7 +68,7 @@ release = '@BINDING_API_VERSION_FULL@' # List of directories, relative to source directory, that shouldn't be searched # for source files. -exclude_trees = ['_build'] +exclude_trees = ['_build', 'extras'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None diff --git a/doc/extras/PySide.QtCore.Signal.rst b/doc/extras/PySide.QtCore.Signal.rst new file mode 100644 index 0000000..441473e --- /dev/null +++ b/doc/extras/PySide.QtCore.Signal.rst @@ -0,0 +1,144 @@ +.. module:: PySide.QtCore +.. _Signal: + +Signal +****** + +Synopsis +-------- + +Functions +^^^^^^^^^ + ++---------------------------------------------------------------------------------------------+ +|def :meth:`connect` (receiver) | ++---------------------------------------------------------------------------------------------+ +|def :meth:`disconnect` (receiver) | ++---------------------------------------------------------------------------------------------+ +|def :meth:`emit` (\*args) | ++---------------------------------------------------------------------------------------------+ + +Detailed Description +-------------------- + + The :class:`~.Signal` class provides a way to declare and connect Qt signals in a pythonic way. + + PySide adopt PyQt's new signal and slot syntax as-is. The PySide implementation is functionally compatible with the PyQt 4.5 one, with the exceptions listed bellow. + + .. note:: Parts of the documentation bellow are from the `PyQt4 documentation `_ public available on the internet Copyright (c) 2010 Riverbank Computing Limited just modified to fit the PySide implementation. + + +Defining New Signals with QtCore.Signal() +----------------------------------------- + + PySide automatically defines signals for all Qt's built-in signals. New signals can be defined as class attributes using the QtCore.Signal() factory. + + QtCore.Signal() takes a number of type arguments that corresponds to the signature of the signal. Each type may be a Python type object or a string that is the name of a C++ type. Alternatively each argument could be a sequence of type arguments. In this case each sequence defines the signature of a different signal overload. The first overload will be the default. + + QtCore.Signal() takes an optional name keyword argument that is the name of the signal. If it is omitted then the name of the class attribute is used. + + The following example shows the definition of a number of new signals: + + :: + + from PySide import QtCore + + class Foo(QtCore.QObject): + + # This defines a signal called 'closed' that takes no arguments. + closed = QtCore.Signal() + + # This defines a signal called 'rangeChanged' that takes two + # integer arguments. + range_changed = QtCore.Signal(int, int, name='rangeChanged') + + # This defines a signal called 'valueChanged' that has two overloads, + # one that takes an integer argument and one that takes a QString + # argument. + valueChanged = QtCore.Signal((int, ), (unicode, )) + + # The following will create exactly the same overloaded signal as + # above and demonstrates the use of C++ type names instead of Python + # type objects, and lists instead of tuples. + valueChanged = QtCore.pyqtSignal(['int'], ['unicode']) + + New signals should only be defined in sub-classes of QObject. + + New signals defined in this way will be automatically added to the class's QMetaObject. This means that they will appear in Qt Designer and can be introspected using the QMetaObject API. + +Connecting, Disconnecting and Emitting Signals +---------------------------------------------- + + Signals are connected and disconnected to slots using the :meth:`Signal.connect` and :meth:`Signal.disconnect` methods of a bound signal and emitted using the :meth:`Signal.emit` method. + + The following code demonstrates the definition, connection and emit of a signal without arguments: + + :: + + from PySide import QtCore + + class Foo(QtCore.QObject): + # Define a new signal called 'trigger' that has no arguments. + trigger = QtCore.pyqtSignal() + + def connect_and_emit_trigger(self): + # Connect the trigger signal to a slot. + self.trigger.connect(self.handle_trigger) + + # Emit the signal. + self.trigger.emit() + + def handle_trigger(self): + # Show that the slot has been called. + print "trigger signal received" + + The following code demonstrates the connection of overloaded signals: + + :: + + from PySide import QtGui + + class Bar(QtGui.QComboBox): + + def connect_activated(self): + # The PyQt documentation will define what the default overload is. + # In this case it is the overload with the single integer argument. + self.activated.connect(self.handle_int) + + # For non-default overloads we have to specify which we want to + # connect. In this case the one with the single string argument. + # (Note that we could also explicitly specify the default if we + # wanted to.) + self.activated[str].connect(self.handle_string) + + def handle_int(self, index): + print "activated signal passed integer", index + + def handle_string(self, text): + print "activated signal passed string", text + +Connecting Signals Using Keyword Arguments +------------------------------------------ + + It is also possible to connect signals by passing a slot as a keyword argument corresponding to the name of the signal when creating an object. For example the following three fragments are equivalent: + + :: + + act = QtGui.QAction("Action", self) + act.triggered.connect(self.on_triggered) + + act = QtGui.QAction("Action", self, triggered=self.on_triggered) + + +.. method:: Signal.connect(receiver[, type=Qt.AutoConnection]) + + Create a connection between this signal and a `receiver`, the `receiver` can be a Python callable, a :class:`Slot` or a :class:`Signal`. + +.. method:: Signal.disconnect(receiver) + + Disconnect this signal from a `receiver`, the `receiver` can be a Python callable, a :class:`Slot` or a :class:`Signal`. + +.. method:: Signal.emit(*args) + + `args` is the optional sequence of arguments to pass to any connected slots. + diff --git a/doc/extras/PySide.QtCore.Slot.rst b/doc/extras/PySide.QtCore.Slot.rst new file mode 100644 index 0000000..27791d0 --- /dev/null +++ b/doc/extras/PySide.QtCore.Slot.rst @@ -0,0 +1,95 @@ +.. module:: PySide.QtCore +.. _Slot: + +Slot +**** + +Detailed Description +-------------------- + + PySide adopt PyQt's new signal and slot syntax as-is. The PySide implementation is functionally compatible with the PyQt 4.5 one, with the exceptions listed bellow. + + .. note:: Parts of the documentation bellow are from the `PyQt4 documentation `_ public available on the internet Copyright (c) 2010 Riverbank Computing Limited just modified to fit the PySide implementation. + + Although PySide allows any Python callable to be used as a slot when connecting signals, it is sometimes necessary to explicitly mark a Python method as being a Qt slot and to provide a C++ signature for it. PySide provides the QtCore.Slot() function decorator to do this. + + All of the non-keyword arguments to the decorator are interpreted as the types of the corresponding C++ arguments. A type is either a Python type object or a string that specifies a C++ type. The decorator also takes two optional keywords arguments: name and result. name is the name of the slot that will be seen by C++. If ommitted the name of the Python method being decorated will be used. result is the type of the result and may also be a Python type object or a string that specifies a C++ type. + + For example: + + :: + + @QtCore.Slot() + def foo(self): + """ C++: void foo() """ + + @QtCore.Slot(int, unicode) + def foo(self, arg1, arg2): + """ C++: void foo(int, QString) """ + + @QtCore.Slot(int, name='bar') + def foo(self, arg1): + """ C++: void bar(int) """ + + @QtCore.Slot(int, result=int) + def foo(self, arg1): + """ C++: int foo(int) """ + + @QtCore.Slot(int, QtGui.QWidget) + def foo(self, arg1): + """ C++: int foo(int, QWidget*) """ + + It is also possible to chain the decorators in order to define a Python method several times with different signatures. + + For example: + + :: + + @QtCore.Slot(int) + @QtCore.Slot('QString') + def valueChanged(self, value): + """ Two slots will be defined in the QMetaObject. """ + +Connecting Slots By Name +------------------------ + + PySide supports the QtCore.QMetaObject.connectSlotsByName() function that is most commonly used by pyside-uic generated Python code to automatically connect signals to slots that conform to a simple naming convention besides the QtCore.Slot decoration. + + For example the :class:`PySide.QtGui.QSpinBox` class has the following signals: + + :: + + void valueChanged(int i); + void valueChanged(const QString& text); + + For example, if you were interested in the integer variant of the signal then your slot definition would look like the following: + + :: + + @QtCore.Slot(int) + def on_spinbox_valueChanged(self, i): + # i will be an integer. + pass + + If you wanted to handle both variants of the signal, but with different Python methods, then your slot definitions might look like the following: + + :: + + @QtCore.Slot(int, name='on_spinbox_valueChanged') + def spinbox_int_value(self, i): + # i will be an integer. + pass + + @QtCore.Slot(unicode, name='on_spinbox_valueChanged') + def spinbox_qstring_value(self, s): + # s will be a Python unicode object. + pass + + The following shows an example using a button when you are not interested in the optional argument: + + :: + + @QtCore.Slot() + def on_button_clicked(self): + pass + From 4c79d1e8cd54b3bf7dc0d2ea3d5f5b000a862fc7 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 6 Jan 2011 20:56:14 -0300 Subject: [PATCH 0521/1129] Fixes the fix in the commit a1cf8f03. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed by Hugo Parente Reviewed by Renato Araújo --- PySide/QtCore/glue/qobject_connect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PySide/QtCore/glue/qobject_connect.cpp b/PySide/QtCore/glue/qobject_connect.cpp index f6b0dce..91a272c 100644 --- a/PySide/QtCore/glue/qobject_connect.cpp +++ b/PySide/QtCore/glue/qobject_connect.cpp @@ -4,7 +4,8 @@ static bool isDecorator(PyObject* method, PyObject* self) if (!PyObject_HasAttr(self, methodName)) return true; Shiboken::AutoDecRef otherMethod(PyObject_GetAttr(self, methodName)); - return otherMethod.object() != method; + return reinterpret_cast(otherMethod.object())->im_func != \ + reinterpret_cast(method)->im_func; } static bool getReceiver(PyObject* callback, QObject** receiver, PyObject** self) From f4f48519ec2dade5a016b87bc089e90a0caf71a4 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Fri, 7 Jan 2011 18:58:15 -0300 Subject: [PATCH 0522/1129] Fix Qvariant to Cpp conversion. Fixes bug #589 Reviewer: Hugo Parente Lima Marcelo Lira --- PySide/QtCore/qvariant_conversions.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PySide/QtCore/qvariant_conversions.h b/PySide/QtCore/qvariant_conversions.h index 0b89534..283cf4f 100644 --- a/PySide/QtCore/qvariant_conversions.h +++ b/PySide/QtCore/qvariant_conversions.h @@ -19,6 +19,8 @@ struct Converter if (PyObject_TypeCheck(type, &SbkObjectType_Type)) { SbkObjectType* sbkType = reinterpret_cast(type); const char* typeName = Shiboken::ObjectType::getOriginalName(sbkType); + if (!typeName) + return 0; bool valueType = '*' != typeName[qstrlen(typeName) - 1]; // Do not convert user type of value From 1caaffba59c8a6897d58e7682842f4b4a86405f2 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Fri, 7 Jan 2011 18:58:40 -0300 Subject: [PATCH 0523/1129] Created unit test for bug 589. Reviewer: Hugo Parente Lima Marcelo Lira --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/bug_589.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/QtGui/bug_589.py diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 6032808..e8d4804 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -28,6 +28,7 @@ PYSIDE_TEST(bug_549.py) PYSIDE_TEST(bug_569.py) PYSIDE_TEST(bug_576.py) PYSIDE_TEST(bug_585.py) +PYSIDE_TEST(bug_589.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/bug_589.py b/tests/QtGui/bug_589.py new file mode 100644 index 0000000..0c7cdec --- /dev/null +++ b/tests/QtGui/bug_589.py @@ -0,0 +1,19 @@ +# trimmed down diagramscene.py to demonstrate crash in sizeHint() + +import sys +from PySide import QtCore, QtGui +import unittest + +class CustomWidget(QtGui.QGraphicsProxyWidget): + def itemChange(self, eventType, value): + QtGui.QGraphicsProxyWidget.itemChange(self, eventType, value) + +class Bug589(unittest.TestCase): + def testCase(self): + widget = QtGui.QGraphicsProxyWidget() + custom = CustomWidget() + custom.setParentItem(widget) + +if __name__ == "__main__": + app = QtGui.QApplication(sys.argv) + unittest.main() From 64a35df0c16663bea2693701f576005e2f8ebb4c Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 10 Jan 2011 15:26:54 -0300 Subject: [PATCH 0524/1129] Added condition for a phonon test that fails on Win32 with Qt 4.7.1. This is due to a bug on Phonon::createPath that happens with the specific combination of Win32 platform and Qt 4.7.1. The bug is reported as fixed for Qt 4.7.2, but it wasn't released yet. For more details on the bug: http://bugreports.qt.nokia.com/browse/QTBUG-13062 Reviewed by Hugo Parente Reviewed by Lauro Moura --- tests/phonon/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/phonon/CMakeLists.txt b/tests/phonon/CMakeLists.txt index c2b939e..ee94c0b 100644 --- a/tests/phonon/CMakeLists.txt +++ b/tests/phonon/CMakeLists.txt @@ -1,3 +1,7 @@ -PYSIDE_TEST(basic_playing_test.py) +if (NOT WIN32 OR NOT ${QTVERSION} VERSION_EQUAL 4.7.1) + # Any usage of Phonon::createPath will fail on Win32 and Qt 4.7.1. + # Check: http://bugreports.qt.nokia.com/browse/QTBUG-13062 + PYSIDE_TEST(basic_playing_test.py) +endif() PYSIDE_TEST(bug_328.py) PYSIDE_TEST(capabilities_test.py) From 99cbdef40cda9379651951d0f187fbba6e829ae1 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Tue, 11 Jan 2011 18:53:06 -0300 Subject: [PATCH 0525/1129] Added test for QPainter.setPen() method. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calls it with enum, to call the setPen(Qt.PenStyle) signature, and with an integer, to call the setPen(QColor) signature (QColor is implicitly built from an unsigned int in C++). For more details see Bug #511: http://bugs.openbossa.org/show_bug.cgi?id=511 Reviewed by Luciano Wolf Reviewed by Renato Araújo --- tests/QtGui/qpen_test.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/QtGui/qpen_test.py b/tests/QtGui/qpen_test.py index f9e9b18..b1e0b7a 100644 --- a/tests/QtGui/qpen_test.py +++ b/tests/QtGui/qpen_test.py @@ -1,10 +1,25 @@ import unittest +from helper import UsesQApplication -from PySide.QtCore import Qt -from PySide.QtGui import QPen +from PySide.QtCore import Qt, QTimer +from PySide.QtGui import QPen, QPainter, QWidget -class QPenTest(unittest.TestCase): +class Painting(QWidget): + def __init__(self): + QWidget.__init__(self) + self.penFromEnum = None + self.penFromInteger = None + + def paintEvent(self, event): + painter = QPainter(self) + painter.setPen(Qt.NoPen) + self.penFromEnum = painter.pen() + painter.setPen(int(Qt.NoPen)) + self.penFromInteger = painter.pen() + + +class QPenTest(UsesQApplication): def testCtorWithCreatedEnums(self): '''A simple case of QPen creation using created enums.''' @@ -14,6 +29,15 @@ class QPenTest(unittest.TestCase): join = Qt.PenJoinStyle(0) pen = QPen(Qt.blue, width, style, cap, join) + def testSetPenWithPenStyleEnum(self): + '''Calls QPainter.setPen with both enum and integer. Bug #511.''' + w = Painting() + w.show() + QTimer.singleShot(1000, self.app.quit) + self.app.exec_() + self.assertEqual(w.penFromEnum.style(), Qt.NoPen) + self.assertEqual(w.penFromInteger.style(), Qt.SolidLine) + if __name__ == '__main__': unittest.main() From 7e667036d58a0549dd08a152149e1ba1f410bfb7 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 11 Jan 2011 17:58:52 -0300 Subject: [PATCH 0526/1129] Use python base name as library prefix. Use the same CMAKE_BUILD_TYPE as shiboken if none was specified. Append SHIBOKEN_PYTHON_BASENAME in the library suffix. Fix bug #509. Reviewer: Marcelo Lira Lauro Moura --- CMakeLists.txt | 2 +- libpyside/CMakeLists.txt | 5 ++++- libpyside/PySideConfig-spec.cmake.in | 9 +++++++++ libpyside/PySideConfig.cmake.in | 14 +++++--------- 4 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 libpyside/PySideConfig-spec.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 33eda53..856ed6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ else() endif() if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE ${SHIBOKEN_BUILD_TYPE}) endif() set(BINDING_NAME PySide) diff --git a/libpyside/CMakeLists.txt b/libpyside/CMakeLists.txt index 04bf0a7..6450045 100644 --- a/libpyside/CMakeLists.txt +++ b/libpyside/CMakeLists.txt @@ -24,7 +24,7 @@ target_link_libraries(pyside set_target_properties(pyside PROPERTIES VERSION ${BINDING_API_VERSION} SOVERSION "${BINDING_API_MAJOR_VERSION}.${BINDING_API_MINOR_VERSION}" - OUTPUT_NAME "pyside${pyside_SUFFIX}" + OUTPUT_NAME "pyside${pyside_SUFFIX}-${SHIBOKEN_PYTHON_BASENAME}" DEFINE_SYMBOL PYSIDE_EXPORTS) # @@ -54,6 +54,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pyside.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/pyside${pyside_SUFFIX}.pc" @ONLY) # create cmake-config files configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig.cmake" @ONLY) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideConfig-spec.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig-${SHIBOKEN_PYTHON_BASENAME}.cmake" @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/PySideConfigVersion.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/PySideConfigVersion.cmake" @ONLY) install(FILES ${libpyside_HEADERS} @@ -65,5 +66,7 @@ install(TARGETS pyside EXPORT pyside install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pyside${pyside_SUFFIX}.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig.cmake" DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide-${BINDING_API_VERSION}") +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideConfig-${SHIBOKEN_PYTHON_BASENAME}.cmake" + DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide-${BINDING_API_VERSION}") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PySideConfigVersion.cmake" DESTINATION "${LIB_INSTALL_DIR}/cmake/PySide-${BINDING_API_VERSION}") diff --git a/libpyside/PySideConfig-spec.cmake.in b/libpyside/PySideConfig-spec.cmake.in new file mode 100644 index 0000000..b5b73dc --- /dev/null +++ b/libpyside/PySideConfig-spec.cmake.in @@ -0,0 +1,9 @@ +# PYSIDE_INCLUDE_DIR - Directories to include to use PySide +# PYSIDE_LIBRARY - Files to link against to use PySide +# PYSIDE_PYTHONPATH - Path to where the PySide Python module files could be found +# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide + +SET(PYSIDE_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PySide@pyside_SUFFIX@") +SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside@pyside_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@") +SET(PYSIDE_PYTHONPATH "@SITE_PACKAGE@") +SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide@pyside_SUFFFIX@/typesystems") diff --git a/libpyside/PySideConfig.cmake.in b/libpyside/PySideConfig.cmake.in index b5b73dc..28203da 100644 --- a/libpyside/PySideConfig.cmake.in +++ b/libpyside/PySideConfig.cmake.in @@ -1,9 +1,5 @@ -# PYSIDE_INCLUDE_DIR - Directories to include to use PySide -# PYSIDE_LIBRARY - Files to link against to use PySide -# PYSIDE_PYTHONPATH - Path to where the PySide Python module files could be found -# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide - -SET(PYSIDE_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PySide@pyside_SUFFIX@") -SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside@pyside_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@") -SET(PYSIDE_PYTHONPATH "@SITE_PACKAGE@") -SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide@pyside_SUFFFIX@/typesystems") +if (NOT PYTHON_BASENAME) + message(STATUS "Using default python: @PYTHON_BASENAME@") + SET(PYTHON_BASENAME @PYTHON_BASENAME@) +endif() +include(@LIB_INSTALL_DIR@/cmake/PySide-@pyside_VERSION@/PySideConfig-${PYTHON_BASENAME}.cmake) From 3ac4080bfe3052b8ee805a0a983a68cf142241b2 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 12 Jan 2011 19:26:27 -0300 Subject: [PATCH 0527/1129] Create a new parent test. Check if the parent does not increase the reference if you set the parent twice. --- tests/QtCore/qobject_parent_test.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/QtCore/qobject_parent_test.py b/tests/QtCore/qobject_parent_test.py index eb8cae2..df81216 100644 --- a/tests/QtCore/qobject_parent_test.py +++ b/tests/QtCore/qobject_parent_test.py @@ -25,6 +25,13 @@ class ParentRefCountCase(unittest.TestCase): self.child.setParent(self.parent) self.assertEqual(getrefcount(self.child), 3) + def testSetParentTwice(self): + self.assertEqual(getrefcount(self.child), 2) + self.child.setParent(self.parent) + self.assertEqual(getrefcount(self.child), 3) + self.child.setParent(self.parent) + self.assertEqual(getrefcount(self.child), 3) + def testConstructor(self): #QObject(QObject) refcount changes child = QObject(self.parent) From f98566eebd41613236ad88b7aba676d4b081bb12 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 13 Jan 2011 10:29:49 -0300 Subject: [PATCH 0528/1129] Fixed path to include file used on cmake files. Reviewer: Bruno Araujo --- libpyside/PySideConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpyside/PySideConfig.cmake.in b/libpyside/PySideConfig.cmake.in index 28203da..f25487c 100644 --- a/libpyside/PySideConfig.cmake.in +++ b/libpyside/PySideConfig.cmake.in @@ -2,4 +2,4 @@ if (NOT PYTHON_BASENAME) message(STATUS "Using default python: @PYTHON_BASENAME@") SET(PYTHON_BASENAME @PYTHON_BASENAME@) endif() -include(@LIB_INSTALL_DIR@/cmake/PySide-@pyside_VERSION@/PySideConfig-${PYTHON_BASENAME}.cmake) +include(@LIB_INSTALL_DIR@/cmake/PySide-@BINDING_API_VERSION@/PySideConfig-${PYTHON_BASENAME}.cmake) From 67f0db5a2b6ad96d41bda2b96112bba3cba55862 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Mon, 10 Jan 2011 17:52:37 -0200 Subject: [PATCH 0529/1129] Add polymorphic-id-expression to QGraphicsObject and QDeclarativeItem. --- PySide/QtDeclarative/typesystem_declarative.xml | 2 +- PySide/QtGui/typesystem_gui_common.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PySide/QtDeclarative/typesystem_declarative.xml b/PySide/QtDeclarative/typesystem_declarative.xml index 5649bf2..e754006 100644 --- a/PySide/QtDeclarative/typesystem_declarative.xml +++ b/PySide/QtDeclarative/typesystem_declarative.xml @@ -97,7 +97,7 @@ - + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 676829e..1d1ea01 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -5584,7 +5584,7 @@ --> - + From a24e8ed2811a9d4f116d3c2e05721a4e47b7a09f Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Tue, 11 Jan 2011 15:17:56 -0200 Subject: [PATCH 0530/1129] Don't crash when a unknown type is given as a meta call argument. --- libpyside/signalmanager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp index 75a0d19..2581d71 100644 --- a/libpyside/signalmanager.cpp +++ b/libpyside/signalmanager.cpp @@ -324,8 +324,14 @@ static int PySide::callMethod(QObject* object, int id, void** args) void* data = args[i+1]; const char* dataType = paramTypes[i].constData(); - PyObject* arg = Shiboken::TypeResolver::get(dataType)->toPython(data); - PyTuple_SET_ITEM(preparedArgs, i, arg); + 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(); From bcad6d0392ace27a9a4acb0097f2e170cb5f6e21 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 12 Jan 2011 12:31:59 -0200 Subject: [PATCH 0531/1129] Fix documentation for QWidget.winId() --- PySide/QtGui/typesystem_gui_common.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 1d1ea01..37ffb89 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3475,6 +3475,19 @@ + + + Returns the window system identifier of the widget. + + Portable in principle, but if you use it you are probably about to do something non-portable. Be careful. + + If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. + + On X11 the type returned is long, on other platforms it's a PyCObject. + + This value may change at run-time. An event with type PySide.QtCore.QEvent.WinIdChange will be sent to the widget following a change in window system identifier. + + From 4587eec6cb142f4fd3d6f302b4ee840c3cc77886 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 12 Jan 2011 14:56:56 -0200 Subject: [PATCH 0532/1129] Remove protected fields of event classes. Event classes have a lot of non-documented protected fields, those fields are removed from PySide because they are Qt implementation details, besides the fact they are accessible by ordinary event methods. --- PySide/QtGui/typesystem_gui_common.xml | 78 +++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 37ffb89..61bf68d 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -71,11 +71,86 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -144,7 +219,6 @@ - From 776b41613d765bbeae21ff8626ebbccfbd1e35d3 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 12 Jan 2011 15:45:35 -0200 Subject: [PATCH 0533/1129] Removed useless rejections Reviewer: Marcelo Lira Lauro Moura --- PySide/QtCore/typesystem_core.xml | 287 +------------------------ PySide/QtGui/typesystem_gui_common.xml | 66 +----- 2 files changed, 11 insertions(+), 342 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index f41acd5..031244b 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -56,17 +56,6 @@ - - - - - - - - - - - @@ -88,9 +77,11 @@ + + @@ -182,26 +173,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -256,239 +227,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -506,7 +244,6 @@ - @@ -1369,12 +1106,6 @@ %PYARG_0 = %CONVERTTOPYTHON[bool](retval); - - - - @@ -2297,6 +2028,7 @@ + @@ -2608,6 +2340,7 @@ + @@ -2651,6 +2384,7 @@ + @@ -2759,8 +2493,6 @@ - - @@ -2801,8 +2533,6 @@ - - @@ -2997,10 +2727,6 @@ - - - - @@ -3016,8 +2742,6 @@ - - @@ -3025,6 +2749,7 @@ + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 61bf68d..e6dabc4 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -151,53 +151,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -561,7 +514,7 @@ - + @@ -570,7 +523,7 @@ - + @@ -2136,8 +2089,6 @@ - - @@ -3159,8 +3110,6 @@ - - @@ -3198,8 +3147,6 @@ - - @@ -3336,9 +3283,6 @@ - - - @@ -5760,11 +5704,11 @@ - - - + + + From d9940e55a41b83d30ce41e8002f614bfe16d54bf Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 13 Jan 2011 13:51:51 -0300 Subject: [PATCH 0534/1129] Fix typo on Cmake files. Reviewer: Bruno Araujo --- libpyside/PySideConfig-spec.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libpyside/PySideConfig-spec.cmake.in b/libpyside/PySideConfig-spec.cmake.in index b5b73dc..b017b9e 100644 --- a/libpyside/PySideConfig-spec.cmake.in +++ b/libpyside/PySideConfig-spec.cmake.in @@ -4,6 +4,6 @@ # PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide SET(PYSIDE_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include/PySide@pyside_SUFFIX@") -SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside@pyside_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@@CMAKE_SHARED_LIBRARY_SUFFIX@") +SET(PYSIDE_LIBRARY "@LIB_INSTALL_DIR@/@CMAKE_SHARED_LIBRARY_PREFIX@pyside@pyside_SUFFIX@@LIBRARY_OUTPUT_SUFFIX@-@SHIBOKEN_PYTHON_BASENAME@@CMAKE_SHARED_LIBRARY_SUFFIX@") SET(PYSIDE_PYTHONPATH "@SITE_PACKAGE@") -SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide@pyside_SUFFFIX@/typesystems") +SET(PYSIDE_TYPESYSTEMS "@CMAKE_INSTALL_PREFIX@/share/PySide@pyside_SUFFIX@/typesystems") From b57192c596230ef8fb6a9cb1fe51d3a72e719e4f Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 13 Jan 2011 17:51:14 -0200 Subject: [PATCH 0535/1129] Fix bug#584 - "python pickle module can't treat QByteArray object of PySide" Reviewer: Luciano Wolf Lauro Moura --- PySide/QtCore/typesystem_core.xml | 36 +++++++++++++------------- PySide/QtGui/typesystem_gui_common.xml | 6 ++--- PySide/typesystem_templates.xml | 5 +--- tests/QtCore/qbytearray_test.py | 11 ++++++++ 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 031244b..24ce91f 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -433,7 +433,7 @@ - + @@ -451,7 +451,7 @@ - + @@ -504,7 +504,7 @@ - + @@ -562,7 +562,7 @@ - + @@ -574,7 +574,7 @@ - + @@ -586,7 +586,7 @@ - + @@ -605,7 +605,7 @@ - + @@ -617,7 +617,7 @@ - + @@ -682,7 +682,7 @@ - + @@ -736,7 +736,7 @@ - + @@ -755,7 +755,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -788,7 +788,7 @@ - + @@ -1217,7 +1217,7 @@ - + @@ -1232,7 +1232,7 @@ - + @@ -1281,7 +1281,7 @@ - + @@ -1294,8 +1294,8 @@ - - + + diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index e6dabc4..50247c3 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -499,14 +499,14 @@ - PyObject *points = PyList_New(%CPPSELF.count()); - for (int i = 0; i < %CPPSELF.count(); ++i){ + PyObject* points = PyList_New(%CPPSELF.count()); + for (int i = 0, max = %CPPSELF.count(); i < max; ++i){ int x, y; %CPPSELF.point(i, &x, &y); PyList_SET_ITEM(points, i, %CONVERTTOPYTHON[QPoint](QPoint(x, y))); } - + diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 4604fda..dd07459 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -188,10 +188,7 @@ +