aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue/qtcore.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename PySide2 to PySide6Friedemann Kleint2020-11-021-1879/+0
| | | | | | | | Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>
* remove traces of Python2 from C codeChristian Tismer2020-10-271-34/+0
| | | | | | | | | | | | It will be assumed that Python is always Python 3. All checks for Python 2 are removed. This is the second part of cleaning up the C code from references to Python 2. Task-number: PYSIDE-904 Change-Id: I3006412c2a5bb65402101b0aac5a5f2fc79ce2f8 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Remove deprecated QVariant::TypeFriedemann Kleint2020-10-271-34/+0
| | | | | | | | | Usage of the enum causes deprecation warnings. In addition, it is not clear why the type was there given that QVariant is not exposed. Remove the converters. Change-Id: I5b1f12ee0f869a63e6b7d82afdcb58a5d7062ce6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide snippets: Fix deprecation warnings about constructing a QVariant from ↵Friedemann Kleint2020-10-271-34/+28
| | | | | | | | | a type id Rewrite the helper QVariant_resolveMetaType() to return a QMetaType. Change-Id: Ifa3994ea0c23149bd925e4a422f19e98e742d97f Reviewed-by: Christian Tismer <tismer@stackless.com>
* Adapt to recent changes in qtbaseFriedemann Kleint2020-10-021-11/+0
| | | | | | | | | | | | | | | | - Remove QProcess::pid(), adapt test (qtbase/0f8848b7e25e4d8fb9265ff6e0aa31946addd741) - Remove enum from QPrinter - Add enum GrabTransition to QPointingDevice - Remove deprecated functions from QByteArray, QXmlStreamAttributes - Adapt Qml tests - Remove fake property from QLayout Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I98cc90723cbeda15b23c5b22d026cb2ab9a358ff Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add QStringView/QByteArrayViewFriedemann Kleint2020-09-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | View types as function parameters cannot be converted in the standard way shiboken does it: QStringView cppArg0; pythonToCpp(pyArg, &cppArg0); since they reference some other data. Introduce a new "viewOn" member to type system entry for them. It causes the function arguments to be replaced by their viewed-on types (stringview->string) via metatype. Add a test in libsample and a test for QUuid::fromString(QStringView). Test returning QStringView via QRegularExpressionMatch::capturedView(). Task-number: QTBUG-84319 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Task-number: PYSIDE-487 Change-Id: Iddb4ea268a54928d290e29012e2738772fae83f0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-171-0/+6
|\ | | | | | | Change-Id: I8aa48d07067c45c888c73af87314f6a88c2a6e14
| * Fix slots being invoked from the wrong threadFriedemann Kleint2020-09-161-0/+6
| | | | | | | | | | | | | | | | | | | | In case the signal connections are routed via some GlobalReceiverV2 instance, it needs to be moved to the receiver's thread. Fixes: PYSIDE-1354 Change-Id: I85926efeab157e47ec42a830fda024d299807786 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Further cleanups of Python2 in C++ codeFriedemann Kleint2020-09-031-8/+0
| | | | | | | | | | | | | | Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I8b192651abe1344c1240b9867c82e558d952769f Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Remove Python2 from C++ codeFriedemann Kleint2020-09-031-70/+12
| | | | | | | | | | | | | | Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I7e4ffaeabb2ac8a5ffe165d43b3475a7e5d57447 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Adapt to recent Qt 6 changesFriedemann Kleint2020-09-011-6/+9
| | | | | | | | | | | | | | | | | | | | - Removal of the statemachine framework from QtCore - Addition of QAbstractFileIconProvider - Adapt some signatures - QMetaType deprecations Change-Id: Ia51354542ad1d2f0bb5530e45ebef0d6ccdb633d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Remove QStringRefFriedemann Kleint2020-08-201-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Port the remaining XML parser code in shiboken to QStringView. Remove the QStringRef type. The QStringView-related refactoring of QXmlStreamAttributes somehow exposed the value() methods of its base class (QList), which cause compilation errors. Remove them. Task-number: QTBUG-84319 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: If01516f962eddcc0591ccaff322843f2fc040549 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Fix build of qtbase modulesFriedemann Kleint2020-08-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Adapt to qtbase/2f9a294252ae44defd4d8ae1b3c09d8e36ee0612: - Removal of deprecated QSettings API - Changed signature of QLineF - Change of QVariant constructors - Introduction of new QIODeviceBase class Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: I834f535af3c977164def12fc86dfd87282c240aa Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-08-171-0/+4
|\| | | | | | | Change-Id: Icee2cd5a37181070d8ef50e7143868d4f126cea5
| * feature-select: optimize feature access to the feasible maximumChristian Tismer2020-07-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ** fix: MSVC needs extra sign bit in basewrapper_p.h! Buglet? ** The new feature selection has some tiny overhead. It is about two dict accesses plus a slot access for every tp_(get|set)attro call. The introduction of an explicit `__init_feature__` call allows to optimize this overhead very nicely, because this init is done for each __feature__ import: First, we can remove that tiny overhead completely by not initializing the feature_select module at all if no __feature__ import is used. Second, we can optimize this access further by caching the current module dict. If the dict is unchanged, then the last select_id can be used. This reduces the overhead of frequent calls to a single slot access. Third, we finally cache the select id in unused SbkObjectType bits. That removes the last structure where repeated attribute lookup is used. The overhead is therefore quite small when something is changed. But typically these changes are infrequent. The majority of accesses do change nothing, and this case is now quite much optimized. Change-Id: I7d1a4611a1c19216fd9be8f04457bb18ebd52ab1 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Initial port of Core,Gui,Widgets,Network,Qml,Quick to Qt 6Friedemann Kleint2020-07-031-9/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | Test failures: shiboken2:testmodifyfunction pyside2:QtCore::qbytearray_test pyside2:QtGui::bug_PYSIDE-41 pyside2:QtGui::deepcopy_test pyside2:QtGui::qfontmetrics_test pyside2:QtGui::qpixmapcache_test pyside2:QtWidgets::api2_test (QTBUG-85417) pyside2:QtWidgets::bug_632 pyside2:QtWidgets::bug_714 pyside2:QtWidgets::bug_785 pyside2:QtWidgets::qshortcut_test pyside2:QtQml::bug_825 pyside2:QtQml::bug_1029 pyside2:QtQml::registertype pyside2:QtQml::qqmlincubator_incubateWhile pyside2:QtQml::signal_arguments Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Ia43d7ed037dfdd07def0edd76bada2243e73d335 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Indicate limited API builds in QLibraryInfo::build()Friedemann Kleint2020-06-291-0/+10
| | | | | Change-Id: I55fe70da8adf6faba0f8099d4d127ae3963fa2c6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add QObject.findChildren(QRegularExpression)Friedemann Kleint2020-06-261-7/+7
| | | | | | | | | Replacing the deprecated QRegExp version in Qt 6. Merge identical code snippets. Task-number: PYSIDE-904 Change-Id: Id6f5c39379c65cf71fb6352531173d0fd7f2ae5e Reviewed-by: Christian Tismer <tismer@stackless.com>
* Change the return type of the hash functions to Py_ssize_tFriedemann Kleint2020-06-261-4/+4
| | | | | | | | | This is the proper type and makes it clear that it it is not related to Qt's hash type (uint in Qt 5, size_t in Qt 6). Task-number: PYSIDE-904 Change-Id: I4ce0f5c845c06e5dcd0ad9744a16a995017987ef Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-06-261-0/+28
|\ | | | | | | Change-Id: I75984f35bcdeeeb3b6004a00670f1582ab522c1b
| * pthreads: Try to abandon the GIL in case a thread was terminatedFriedemann Kleint2020-06-261-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | When terminating a thread using QThread::terminate() via (pthread_cancel(), QThread::run() is aborted and the lock is released, but ~GilState() is still executed for some reason. Add a cancel handler to the thread which tells GilState to abandon the lock. Fixes: PYSIDE-1282 Change-Id: I70abd42b5a2afd49aaa8cc5e8be0a92ed63f49d3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Implement the QEnum/QFlag decorator, V2Christian Tismer2020-06-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implementation allows module-level and scoped QEnums which are Python enum types. Scoped types are registered in Qt's meta object system. Usage of QEnum/QFlag with decorator or function call: from enum import Enum, Flag, auto from PySide2.QtCore import QEnum, QFlag, QObject class Compass(QObject): @QEnum class Orientation(Enum): North, East, South, West = range(4) class Color(Flag): RED = auto() BLUE = auto() GREEN = auto() WHITE = RED | BLUE | GREEN QFlag(Color) Fixes: PYSIDE-957 Change-Id: Ie15f45cbd932c816b50724a96eee0c14ae1fdee8 Task-number: PYSIDE-487 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Add QSocketDescriptor classCristian Maureira-Fredes2020-06-051-0/+8
| | | | | | | | | | | | | | | | | | | | This was required by the change in QSocketNotifier in 5.15. Additionally, an alias, DescriptorType, was required to make the constructor to work. Fixes: PYSIDE-1317 Change-Id: Ib75e6024e467eb72f374a1179cb7416b1ea8a853 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-05-261-0/+16
|\| | | | | | | Change-Id: I9c7163094bc934f481002adcea78ef4928ed26be
| * PySide2: Fix conversion of quintptrFriedemann Kleint2020-05-181-0/+16
| | | | | | | | | | | | | | | | Ensure it is 64bit for 64bit systems. Change-Id: I0b4d54f2568bd70288e184a5a2d8f31532fed157 Fixes: PYSIDE-1303 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | PySide2: Prepare for Qt 6Friedemann Kleint2020-05-191-4/+12
|/ | | | | | | | | | | | | | | - Change QBasicTimer to be an object type since its copy constructor and assignment were deleted in Qt 6. It probably was never intended to be a value type. - Remove the hash function of QItemSelectionRange which according to code comment is a dummy to get QItemSelectionRange::toSet() compiled with MSVC. There is no need for it to have it in Python - Adapt the underlying string types for QString conversion Task-number: PYSIDE-904 Change-Id: Idb60b95b6bc0ce3d1272862995f3247d2f191454 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Windows: Fix encoding in custom message handlerFriedemann Kleint2020-05-061-1/+1
| | | | | | | | | | The code snippet passing the message to the Python handler used QString::toLocal8Bit() to convert the message. This is wrong as Python always requires UTF-8. Fixes: PYSIDE-1293 Change-Id: I1f16dad970aaf0d776e748110fc2054269412047 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Update sbkstring to use PyUnicode_GetLengthChristian Tismer2020-03-301-1/+1
| | | | | | | | | | | | | | | | | | | | The unicode implementation has changed very much. PyUnicode_GET_SIZE has been used all the time, although this macro is already a quite expensive real function since Python 3.3 . The function is deprecated, and the macro PyUnicode_GET_LENGTH should be used, instead. This is relevant for cleaning things up, because in the course of fixing PYSIDE-813 we work with debug Python, which then complains that Python memory is used without holding the GIL. The usage of the right implementation was ensured by a function PepUnicode_GetLength and removing all traces of the former version. Task-number: PYSIDE-813 Change-Id: I62e94e10e14975dac3dad0ed1fffec8a1b54a0d5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide2: Use int for QVariant conversion when possibleFriedemann Kleint2020-03-251-1/+5
| | | | | | | | | | | Check using the init limits in the QVariant long long conversion and create an int if possible. This works more smoothly with Qt and for example ensures that the correct editor is created in item views. Change-Id: I0ca2e5e7b91f309deaa81a25e70a5f894f43f841 Fixes: PYSIDE-1250 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Adjust the allow-thread behaviorCristián Maureira-Fredes2020-03-131-14/+25
| | | | | | | | | | | | | | | | | This adds and remove the usage of: allow-thread="yes" in some typesystem entries. This also adapt the usage of the Py_BEGIN/END_ALLOW_THREAD macro inside the snippets used by other typesystem entries. The main reason is that in some cases not the whole snippet requires to be inside such state, but only when calling the C++ equivalent function. Task-number: PYSIDE-803 Change-Id: Ifa9c8cee2713c453e4d5c624aaa862e75559180c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Turn qApp into a normal Python variable, finallyChristian Tismer2020-02-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a long odyssey of more or less unpythonic compromizes, the qApp "macro" would finally be moved into a normal variable without surprizes. This was only possible since we removed qApp from QtWidgets and other modules. Otherwise, from PySide2.QtWidgets import * would pull qApp, being the constant "None", into main and shadow the true qApp variable in the builtins. By inserting qApp into the builtins, only, we make sure that this variable is always freshly looked up, without making it change its contents. DONE... + change the singleton code to normal + rename to MakeQAppWrapper + simplify the implementation + fix new bug concerning duplicate applications + check very much for refcounting bugs + review the rest of the implementation and further simplify Note... The Q*Application variable will not be turned back into a GC variable. This is not worth the effort. Fixes: PYSIDE-571 Change-Id: Idbd158c083318e6b0dfe48d62485c68c90e944de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix PyBuffer interface for QByteArrayCristián Maureira-Fredes2020-02-051-1/+9
| | | | | | | | | | | | | For the limited API, properly implement the PyBUF_ND flag (shape requested). Otherwise, use the convenience function PyBuffer_FillInfo() to properly populate the view. Fixes: PYSIDE-1204 Change-Id: I2a4c81885cf49b25c89823577c0d7ee2f2707b87 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix refcount issues with QSettings glue codeCristián Maureira-Fredes2019-11-281-4/+11
| | | | | | Task-number: PYSIDE-939 Change-Id: I5bda4e2025e31bf192bf0bf70c82aa626cd19714 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Merge remote-tracking branch 'origin/5.13' into 5.14Friedemann Kleint2019-10-311-13/+30
|\ | | | | | | Change-Id: I9f31a647fd9d4ad9c854a307f8b5df1be935354a
| * Fix booleans and empty list cases in QSettingsCristián Maureira-Fredes2019-10-281-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the fix for PYSIDE-1010 there were two things that were not properly understood: 1. A special case for booleans was required, 2. When a list was detected, the split was wrongly creating a list with a '0' instead of an empty one. Additonally, due to the wrong treatment we couldn't notice if the value 0 was None, the number zero, or even false, so this patch amends the previous implementation to properly treat these cases. New test cases were added. Change-Id: I41d5387bb835cfa96f94e5577e993a4b87b303f0 Fixes: PYSIDE-1130 Fixes: PYSIDE-820 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Speed: Avoid some repeated string constant initializationFriedemann Kleint2019-09-301-3/+3
|/ | | | | | | | | | | | | | | | | This patch introduces a basic concept to avoid the repetition of string constant creation in Python by using helper functions returning static instances. There is currently no real shiboken finalization, so we postpone finalization until shiboken has one: - call the finalize_strings() function - build finalization for other stuff (all signatures etc) Initial-patch-by: Christian Tismer <tismer@stackless.com> Task-number: PYSIDE-1087 Change-Id: If3483ba91f719ee0472eb53583460ba35163bc9d Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Allow for "auto" as target of type for CONVERTTOCPP in injected codeFriedemann Kleint2019-07-291-3/+2
| | | | | | Task-number: PYSIDE-1037 Change-Id: Idfc70fe571e4058d0c82db1bd0afea54436fe27c Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add optional support for types in QSettings::valueCristián Maureira-Fredes2019-07-171-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This add an optional named parameter to the function value() to automatically cast the type that is being returned by the function. An example of this situation could be an ini file that contains the value of a one-element list: settings.setValue('var', ['a']) The the ini file will be: [General] var=a # we cannot know that this is a list! Once we read it, we could specify if we want the default behavior, a str, or to cast the output to a list. settings.value('var') # Will get "a" settings.value('var', type=list) # Will get ["a"] The cppgenerator was modified to add a verification step before trying to get the named parameter, since it could be optional and having one named parameter was assumming that all of them were provided. Change-Id: I8f379debea86b42cf89019d432e990084c9e6614 Fixes: PYSIDE-1010 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Leave QVariantMap as a name, not a typeCristian Maureira-Fredes2019-07-021-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem happened on the QtLocation module, when the QVariantMap argument was being used in several functions, and this type was declared as a primitive-type in QtCore. An approach to change the type to a container-type failed, because since QVariantMap is a typedef, is was already registered as a name associated to the definition QMap<QString, QVariant>. The solution was to register the name at the beginning of the module (like QVariantList), and remove the type declaration, leaving it only as a name. Previously, the wrongly generated code looked like this: Shiboken::Conversions::PrimitiveTypeConverter<QVariantList>() but with this patch, it looks like: SbkPySide2_QtLocationTypeConverters[SBK_QTLOCATION_QMAP_QSTRING_QVARIANT_IDX] which is the proper name established by the code on glue/qtcore.cpp: Shiboken::Conversions::registerConverterName(SbkPySide2_QtCoreTypeConverters[SBK_QTCORE_QMAP_QSTRING_QVARIANT_IDX], "QVariantMap"); Change-Id: Id172cf5b1e3ac784bc9497359279e81fcba1d8ec Fixes: PYSIDE-1028 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Cleanup pointer whitespace everywhereChristian Tismer2019-06-241-101/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Support the qApp macro in "scriptable application"Christian Tismer2019-06-171-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed from "Fix scriptable application to support the qApp macro" because qApp was improved instead of scriptable application. The qApp macro needed some extra effort to support the qApp "macro" which is only defined in the Python wrappers. I took some generated code, created a QApplication instance in Python and used then reduced generated code to get at the object and adjust the refcount. This solution was then rejected, because I can do better, and in fact, scriptable application now has a correct qApp macro too, without any change to scriptable application. The central idea was to look into the module init function at import time and to see if a Q*Application already exists. I was not aware of that import. Many thanks for the rejection! :-) Update.. -------- After many attempts to make the qApp variable correctly behave like always, I recognized that pre-existing Q*Application instances have no wrappers or constructors at all! With that, it is not possible to create a sophisticated qApp macro as a singleton variable in the desired way. Fortunately, this is also not necessary, because a C++ Q*Application cannot be deleted from Python, and there is no point in supporting more that a simple variable. So in case of a pre-existing instance, the qApp variable now gets redirected to that instance. A small test was added to application_test.py that is triggered by an import. A weird effect when "qApp" was typed interactively before calling "QApplication()" was fixed, too. Change-Id: Ic69dd6a21c964838a90f63e316d299b62a54d612 Fixes: PYSIDE-571 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix negative refcount on QSocketNotifierChristian Tismer2019-06-101-2/+2
| | | | | | | | | | | | | | | Change 43451e3bc17467593df64cb73ce8c0bf9e60045f from 2018-05-09 introduced a refcount bug that was not caught because we do not build with debug Python. This also revealed an omission in the patch "PySide: Allow any existing attribute in the constructor" when debug Python is used. Change-Id: Idbcbbc87f0a83bb696d03e05af0cf616b21f7335 Fixes: PYSIDE-1027 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Make the PepType_AS_BUFFER definition completeChristian Tismer2019-04-161-4/+0
| | | | | | | | | | PepType_AS_BUFFER should also be defined for the non-Limited API version to avoid ugly #ifdef constructs. This patch augments the definition and simplifies qtcore.cpp . Change-Id: Iddfb39e8afaf992f4edf72d871eec1eaf85d5963 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add toBytes() and BufferProtocolCristian Maureira-Fredes2019-03-151-7/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | VoidPtr: Add toBytes() method that return a char* representation of the void* pointer. QByteArray: The current implementation only provided the Buffer Protocol for Python2, this patch includes the getbuffer implementation for Python3. Having a BufferProtocol implementation for Python3 allows the initialization of VoidPtr to get access to the internal content, so one can go back and forward with the representation of it: ba = QByteArray(b"Hello World") vp = VoidPtr(ba, ba.size()) vp.toBytes() # b"Hello World" The BufferProtocol was also changed for Python2 including the new buffer protocol (Py_TPFLAGS_HAVE_NEWBUFFER) function `bf_getbuffer`. A test case was included. Fixes: PYSIDE-934 Change-Id: I8936966da91b2dcc879c582cfc35e6a35f7a60b6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Return PyObject wrapper when not valid QVariantCristian Maureira-Fredes2019-02-081-6/+10
| | | | | | | | | | | | | | When resolving the meta type of QVariant we did not have a fallback case. So we had a NoneType when none of the converters worked. These changes allow to return a PyObjectWrapper of the object instead of NoneType. This allow users to use any type as QVariant. Change-Id: I18da3f10f6839975fdc0bf2ac62f6bd7063312df Fixes: PYSIDE-45 Reviewed-by: Christian Tismer <tismer@stackless.com>
* QtCore snippets: Fix warning about printf() format in generated codeFriedemann Kleint2019-01-301-1/+2
| | | | | | | | | | Add a cast to int for value_length and slicelength, fixing: qbytearray_wrapper.cpp:5288:158: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘Py_ssize_t {aka long int}’ [-Wformat=] PyErr_Format(PyExc_ValueError, "attempt to assign %s of size %d to extended slice of size %d",Py_TYPE(_value)->tp_name, value_length, slicelength); Change-Id: I4bd2e5d43a26c73c21a6121b469f5ec1c76994b2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Move code to snippets and templatesCristian Maureira-Fredes2018-11-301-0/+47
| | | | | | | | | | | There was still leftover code on the typesystems but not all could be translated to snippets, so it was replace by templates. Task-number: PYSIDE-834 Change-Id: I7dbe2f15171ce6a60137be970312dc80622219c9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Move old glue code to snippets filesCristian Maureira-Fredes2018-11-301-12/+466
| | | | | | | | | | | | | | | | | Most of the old glue code was directly injected into the typesystem, so it was possible to add them as snippets. There are still a couple of header files that will remain there, because the include tag does not have the file/snippet tags. A few lines of code were modified in favor of "modern" C++, and good practices. Task-number: PYSIDE-834 Change-Id: I3072298b16d7280550c6a7f6abae045250663ba6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Move add-conversion and native-to-target codeCristian Maureira-Fredes2018-11-291-0/+279
| | | | | | | | | | | Now we are able to include snippets for the previously mentioned typesystem's tags, so this patch removes the current C/C++ code from the typesystems. Task-number: PYSIDE-834 Change-Id: I2929020fa1dc0859db780dffb12fa292627697b0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Place templates per moduleCristian Maureira-Fredes2018-11-281-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | There is a main template file that hosts most of the code-templates we use in the typesystems, but there were still several templates written in each module-typesystem file. The templates that are used on different typesystem are now placed in: sources/pyside2/PySide2/templates/core_common.xml Additionally, the templates used only by a certain module, are placed next to it, e.g.: sources/pyside2/PySide2/templates/widgets_common.xml Some simple templates were moved to the snippets files too. Task-number: PYSIDE-799 Change-Id: I4f355cf2ae983aba9e85414e910550189cd18dcb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>