aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside/dynamicqmetaobject.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Warn if signals and slots are out of orderChristian Tismer2017-02-141-20/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last improvement to signals and slots registration has removed the problem that mixin classes were not handled the same as other classes. The key idea was to use the MRO to inspect all involved classes at type parsing time. The signals and slots were then sorted in ‘updateMetaObject’. The current patch enhances this solution in the following way: In ‘parsePythonType’ we re-ordered the introspection loop in a way that now all signals are extracted first. This way, they are ordered before slots automatically, and a later sorting is not necessary. Furthermore, instead of using qStableSort in ‘updateMetaObject’, we now check the sorting only with ‘is_sorted’. If the sort order becomes invalid, it will issue a warning. The latest change removes quadratic time behavior from the warning output. Important notes and implications: It is no longer relevant if slots are decorated with @QtCore.Slot(). Signals will work in normally created classes of all shapes. If classes are modified later, they may grow an incompatibility when signals appear after slots. Then you get a warning. Adendum: It makes sense to use slots whenever possible. This way, constructions as in static_metaobject_test.py work. Now handling the warning correctly when it is turned into an error. Correction: We leave the warning as-is and ignore the error! Question: The static_metaobject_test.py passes its tests suddenly, when you use @Slot() ! Why? Should we open an extra issue for that? Task-number: PYSIDE-315 Change-Id: I75c9c88787cd93251b1439db0088cd66fc0c3c97 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Fix registration of signals and slots inherited from mixin classesAlexandru Croitor2017-01-191-47/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously when a python QObject-derived class was parsed, only signals and slots from the top-level class were added to the corresponding DynamicQMetaObject, and any signals or slots that were defined in an inherited mixin class were registered at signal connection time. This caused issues with already existing connections because registering new signals shifted all slot indices, thus breaking the connections (no methods were called, or a wrong method was called that caused a segmentation fault). Fix consists in collecting and registering all signals, slots and properties from a given class, including the mixin clases it derives from, at type parsing time. Important notes and implications: All slots _must_ be decorated with @QtCore.Slot(), otherwise they will not be registered at type parsing time, but at signal connection time, and this _will_ cause hard-to-debug issues. @QtCore.Slot() is not needed for lambdas or free functions, because those get their own DynamicQMetaObject / QObject pair (via a GlobalReceiver instance). Dynamic addition or removal of signals and slots in most situations will not work (e.g. existing connections will break, QML engine heavily caches all method indices, and thus will also break). Task-number: PYSIDE-315 Change-Id: I6213f53653566bde60a469cd239baf969b831560 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* libpyside: Remove some C-style castsFriedemann Kleint2017-01-121-2/+3
| | | | | | | Replace by C++ casts. Change-Id: I8f4fe35a4e1529be307728258acf302e1eb9dfe5 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Sanity check dynamically added signal and slotsAlexandru Croitor2016-11-111-0/+10
| | | | | | | | | | | | | | | | | | | | Whenever a connection is made to a valid method that was not yet defined as a slot, the method will be marked as a slot before the connection proceeds, thus the connection will succeed. However when connecting using old style SLOT("method()") syntax, it is possible to provide an invalid signature by specifying the method name, but forgetting the parentheses. In such a case, instead of failing and notifying the user, the connection erroneously succeeded, and on signal emission would not behave correctly. This change makes sure to sanity check that dynamically added signals and slots contain parentheses, thus not causing incorrect connection creation. Change-Id: Iaa1a85a2ce698ca31a99100e00b683cfa0cb33cc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Make QtQml / QtQuick workAlexandru Croitor2016-10-191-1/+1
| | | | | | Task-number: PYSIDE-355 Change-Id: I67366fb8ceacbcda80e7f17ad5e5ca80d6847902 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix property notify ids to be correctAlexandru Croitor2016-09-281-56/+67
| | | | | | | | | | | | | | | | | | When Python parses a class to find signals and slots, the resulting list contains the methods in the order they are defined in the source code. After that, properties are parsed, and the notify ids are set based on the relative order of the parsed methods. But because the methods are sorted before their details are put into the dynamic QMetaObject, the notify id of a property might point to a wrong method. This fix makes sure that the relative notify id of every property is recomputed before being written to the QMetaObject. This allows QML bindings to work correctly. Change-Id: I5e50970fee9a42ae8ea551b7891d396b8a6eda97 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Updated license headers of the runtime library (cpp)Friedemann Kleint2016-09-271-21/+38
| | | | | Change-Id: I02b7ff8c1b1dc1e5eac4f1d39b5dabc09143e27c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix foreach loopsFriedemann Kleint2016-09-211-2/+2
| | | | | | | | Use const reference and use iterators instead of looping over QMap::values(). Change-Id: I0ab2f1ac9255959c482697e832cea1b7d3c09a30 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* libpyside: Compile with QT_NO_CAST_FROM_ASCII, QT_NO_CAST_TO_ASCIIFriedemann Kleint2016-09-211-1/+1
| | | | | | | Add the define in CMakeLists.txt to enforce it in the module. Change-Id: I430f094400b5a0b6af4e0df564f903e767986b63 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix some compiler warningsFriedemann Kleint2016-07-251-6/+5
| | | | | | | | | | | | | | | | | | | pyside2/libpyside/dynamicqmetaobject_p.h: In constructor 'PySide::MethodData::MethodData(QMetaMethod::MethodType, const QByteArray&, const QByteArray&)': pyside2/libpyside/dynamicqmetaobject_p.h:60:33: warning: 'PySide::MethodData::m_mtype' will be initialized after [-Wreorder] pyside2/libpyside/dynamicqmetaobject_p.h:58:20: warning: 'QByteArray PySide::MethodData::m_signature' [-Wreorder] pyside2/libpyside/dynamicqmetaobject.cpp:277:1: warning: when initialized here [-Wreorder] pyside2/libpyside/dynamicqmetaobject.cpp: In member function 'int PySide::DynamicQMetaObject::DynamicQMetaObjectPrivate::createMetaData(QMetaObject*, QLinkedList<QByteArray>&)': pyside2/libpyside/dynamicqmetaobject.cpp:628:22: warning: narrowing conversion of 'n_info' from 'uint {aka unsigned int}' to 'int' inside { } is ill-formed in C++11 [-Wnarrowing] pyside2/libpyside/dynamicqmetaobject.cpp:628:22: warning: narrowing conversion of 'n_methods' from 'uint {aka unsigned int}' to 'int' inside { } is ill-formed in C++11 [-Wnarrowing] pyside2/libpyside/dynamicqmetaobject.cpp:628:22: warning: narrowing conversion of 'n_properties' from 'uint {aka unsigned int}' to 'int' inside { } is ill-formed in C++11 [-Wnarrowing] pyside2/libpyside/dynamicqmetaobject.cpp:618:10: warning: unused variable 'n_signal' [-Wunused-variable] pyside2/libpyside/pysideproperty.cpp:114:11: warning: enumeration value 'IndexOfMethod' not handled in switch [-Wswitch] pyside2/libpyside/pysideproperty.cpp:114:11: warning: enumeration value 'RegisterPropertyMetaType' not handled in switch [-Wswitch] pyside2/libpyside/pysideproperty.cpp:114:11: warning: enumeration value 'RegisterMethodArgumentMetaType' not handled in switch [-Wswitch] Task-number: PYSIDE-339 Change-Id: I9fa95e520574549cfa1cdb5215fea1b6669fddd6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix DynamicQMetaObject property type registrationAlexandru Croitor2016-07-121-1/+11
| | | | | | | | | | | | | | | | | | | Previously if a property was defined in python code, libPySide would register the wrong type id inside the QMetaObject.d.data struct, specifically it would straight away try to register the type as a *new* type, without checking if it is a built-in type. This led to setters not working on the respective property, because the QVariant which stored the new value, could not be converted to the type which QMetaObject reported. Fix consists in checking if the specified property type is a built-in one, and use it, or register the type as a new one, and make sure it is tagged as a so-far unresolved type, which will be resolved later upon access of the property. Change-Id: Ie5e78a5e760682ce5a98dea138b16354b51c17ae Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Merge commit 'refs/changes/52/84452/3' of ↵empyrical2015-12-121-1/+2
|\ | | | | | | | | | | | | https://codereview.qt-project.org/pyside/pyside into use-after-free From this Gerrit patch: https://codereview.qt-project.org/#/c/84452/
| * Fix use-after-free in QPropertyPankaj Pandey2014-07-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | PropertyData::type() returns a new QByteArray (whose `data` is a copy of the `char*` name of the property) However the use of `type().data()` on the stack without saving its reference means the `char*` returned by the `data()` method is immediately deallocated in the the `~QByteArray` destructor. (Detected by AddressSanitizer) The attached patch fixes it by holding a reference to the QByteArray returned by `type()` for the duration of the method call Change-Id: Ia794a1215da7ba4bada19091e6d6acf3e6584c70
* | fix metaobject and signal/slotsjumaroch2015-11-041-110/+205
| |
* | start fixing dynamicqmetaobject.cpp by first changing the revision from 3 to 7.Christian Tismer2015-09-011-1/+1
| | | | | | | | | | This drastic change is just the beginning of more changes. It shows the real problem, which was hidden due to the revision mismatch.
* | make libpyside compileChristian Tismer2015-06-091-4/+4
|/
* Avoid narrowing conversionMatthew Woehlke2014-04-151-8/+8
| | | | | | | | | Add explicit casts when initializing an int[] using {}'s, as required by C++11 to be "well formed". This fixes the only (current) -Wnarrowing warning. Change-Id: I7f190549a8a54a9061678a926d5478256c2084be Reviewed-by: John Ehresman <jpe@wingware.com>
* Replaced Nokia copyrights and contact detailsTeemu Kaukoranta2013-05-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced Nokia copyrights with correct Digia copyrights. Text in front of copyright is now retained: ** File is part of Foo, Copyright Nokia... -> ** File is part of Foo, Copyright Digia... Replaced Nokia contact details with Digia's. Removing "All Rights Reserved" no longer leaves an empty line. Used the following command: find . -path '*/3rdparty/*' -prune -o -exec grep -ilI -E '.*Copyright.*Nokia.*|.*Contact.*' {} \; | tee >(xargs sed -i -r '1,50 { /INdT|copy[a-z]*[ ]*=/ !{ s/(^[ \t:#*]*)([a-z ]*) (Copyright.*Nokia.*)/ \1\2Copyright \(C\) 2013 Digia Plc and\/or its subsidiary\(-ies\)\./I }}') >(xargs sed -i -r '1,50 s/(^[ \t:#*]*)(.*info@qt\.nokia\.com.* |.*INSERT EMAIL ADDRESS.*|.*qt-info@nokia\.com.* |.*qt-label1@nokia\.com.*|.*http:\/\/qt\.nokia\.com\/contact.* |.*qt-sales@nokia\.com.*|.*http:\/\/www\.qt-project\.org\/.*)/ \1Contact: http:\/\/www\.qt-project\.org\/legal/I') >(xargs sed -i -r '1,50{/(^[ \t:#*]*)(all rights reserved.*)/Id}') Command now finds command details that point to qt-project.org and changes them to qt-project.org/legal Also no longer wrongly replaces code snippet "copyright = ..". Need to fix these case-by-case later. Change-Id: I4456c00202c4a2264a400bdc18c19cd097876861 Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Bug pyside-35: GIL was not acquired in several important places.1.1.1Jason McCampbell (Enthought, Inc)2012-04-191-0/+1
| | | | | Change-Id: I876732f90690d9679537611e9a71e33aa3a4e4e3 Reviewed-by: Hugo Parente Lima <hugo.lima@openbossa.org>
* Fix bug 1013 - "connect to QSqlTableModel.primeInsert() causes crash"Hugo Parente Lima2012-03-081-1/+1
|
* Initia QtCore port to python3.Renato Filho2012-03-081-5/+5
|
* Avoid register property twice during the object instaciation.Renato Filho2012-03-081-1/+3
| | | | | Reviewed by: Hugo Parente <hugo.lima@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
* DynamicMetaObject optimizations.Renato Filho2012-03-081-58/+149
| | | | | Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
* Use linked lists instead of lists to speed up a bit.Hugo Parente Lima2012-03-081-7/+7
| | | | | | Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
* Small optimizations on libpyside.Hugo Parente Lima2012-03-081-27/+7
|
* Use realloc functions on MetaObject functions.Renato Filho2012-03-081-18/+19
| | | | | Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
* Implemented DynamicMetaObject optiomizations.Renato Filho2012-03-081-22/+50
| | | | | Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
* Implemented staticMetaObject property for QObjects.Renato Filho2012-03-081-1/+70
|
* Implemented PySide::ClassInfo Object.Renato Filho2012-03-081-9/+38
| | | | | | | | | | | | This class reproduce the Qt macro Q_CLASSINFO behavior. Eg.: @QtCore.ClassInfo(author='PySide', url='http://www.pyside.org') fixes bug #705. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
* Uses QMetaObject revision 3.Renato Filho2012-03-081-122/+69
| | | | | | | | | This allow to register signal and slot in any order. Fixes bug #312 Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
* Appended the metaclass data flags value on head.Renato Araujo Oliveira Filho2012-03-081-0/+1
| | | | | | | Fix bug #671. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
* Add support for extension into PySide properties.Hugo Parente Lima2012-03-081-5/+7
| | | | This is used by PySide implementation of QDeclarativeListProperty.
* Set the object meta object at the declaration time, not instanciation time.Hugo Parente Lima2012-03-081-58/+0
|
* Moved pyside slot attr name do pysideslot_p.h.Hugo Parente Lima2012-03-081-0/+1
|
* Fixed dynamic meta object to avoid empty meta method.Hugo Parente Lima2012-03-081-46/+47
| | | | | | Empty meta methods cause a assert failure on QtDeclarative module. Also removed the scoped pointer to avoid heap allocation when it's not needed, as QByteArray is already implicity shared.
* Fix generated property flags on metaobject.Renato Araujo Oliveira Filho2010-11-221-23/+24
| | | | | | | Fixes bug #478 Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
* Uses QByteArray instead of QString to avoid data copy.Hugo Parente Lima2010-11-181-11/+5
| | | | | Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
* Remove function deleteDynamicQMetaObject, use ↵Hugo Parente Lima2010-11-181-5/+0
| | | | Shiboken::callCppDestructor<DynamicQMetaObject> instead.
* Fixed slot registration during the meta object constructor.renatofilho2010-11-031-1/+1
| | | | | Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
* Renamed qsignal, qslot, qproperty files to pyside*.renatofilho2010-11-031-5/+5
| | | | | Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
* Created Singal/Slot/Property namespace for pure C structures.renatofilho2010-11-031-16/+16
| | | | | Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Lauro Neto <lauro.neto@openbossa.org>
* Put signals register before property registration.renatofilho2010-10-221-4/+12
| | | | | Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
* Implemented support to notify argument on Properties.renatofilho2010-10-211-28/+51
| | | | | Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
* Added d-pointer to PySideSignalInstanceData struct.Hugo Parente Lima2010-10-191-3/+3
|
* Don't export symbols that don't need to be exported and rename many functions.Hugo Parente Lima2010-10-071-3/+4
|
* Don't inline function deleteDynamicQMetaObject.Hugo Parente Lima2010-10-071-0/+5
| | | | It's used by address, so inline it is useless.
* Move structs tagged as "export C" outside C++ namespaces.Hugo Parente Lima2010-10-071-1/+1
| | | | Also don't export structs that don't need to be exported.
* Don't export functions not used outsise libpyside and move them to an ↵Hugo Parente Lima2010-10-071-0/+1
| | | | private header.
* Changed name of qproperty functionsHugo Parente Lima2010-10-071-10/+10
|
* Add a d-pointer to DynamicMetaObject.Hugo Parente Lima2010-10-071-48/+63
| | | | This break the ABI.