aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtCore
Commit message (Collapse)AuthorAgeFilesLines
* Fix suppressed exceptions for 0-delay singleShotAdrian Herrmann7 days2-0/+38
| | | | | | | | | | | Fix an issue where exceptions were not shown when raised inside a slot called from a zero-delay singleshot timer, causing problems further down the line. Pick-to: 6.7 Fixes: PYSIDE-2745 Change-Id: Iab7696663e5dfa00d99d28ee21ac687fde4cf731 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Speed up test bug_927.pyFriedemann Kleint2024-05-141-4/+4
| | | | | | | | Bring the execution time from 4s to ~200ms on a normal machine. Pick-to: 6.7 6.5 Change-Id: If57aa5a73089f48cba1b7bcf6789864d8dfbb48c Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* Lazy Load: Fix polymorphic classes by identifying lazy groupsFriedemann Kleint2024-04-231-0/+16
| | | | | | | | | | | | | Classes with a polymorphicIdValue have an expression which may reference a related class. We use that to identify a lazy group, which has to be initialized at once. This is now completely solved. Pick-to: 6.7 Fixes: PYSIDE-2675 Change-Id: I957a1b2b95d37b96cc2e98082fc7f92e601322cb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Port the QtCore signals tests to modern syntaxFriedemann Kleint2024-04-096-43/+53
| | | | | | | | | | | Use the modern syntax where appropriate. Some tests are left unmodified to at least test the syntax. Pick-to: 6.7 Task-number: PYSIDE-2646 Change-Id: Idb16cda65ab1985f8be5fa5527b5a19e26fcec34 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Add QIOPipeAdrian Herrmann2024-03-131-0/+36
| | | | | | | | | | | | Add an implementation for a QIODevice that can be used to work with anonymous pipes. It needs to be able to emit the bytesWritten and readyRead signals. This implementation is lifted from the qt5 source tree (qtdeclarative/tests/auto/qmlls/lifecycle) and might be added to Qt in the future, at which point it will be removed from the PySide source tree. Change-Id: Iff1208a366dad747352e7507da0818934c26aa4f Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix a crash when using struct.unpack() on a QByteArray with Limited APIFriedemann Kleint2024-03-071-0/+8
| | | | | | | | | | | Unconditionally setting view->strides on the Py_Buffer causes a crash. Update the code in our copy of PyBuffer_FillInfo() from CPython. Fixes: PYSIDE-2628 Pick-to: 6.6 6.5 Change-Id: I6f244090a65442003cecfce70c6f8164b41ba99a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* signature: Add support for classmethodsCristián Maureira-Fredes2024-02-251-5/+4
| | | | | | | | | | | | | | | | | | | | Two tests were adapted, because now the missing signature error message: TypeError: xxx.__dict__['yyy'].fset(<class 'object'>) is wrong (missing signature) does not apply, and we get the usual message: TypeError: xxx.__dict__['yyy'].fset" called with wrong argument types: this comes from the fact that we are not getting the string representation of the signature, but the data type itself. Change-Id: Ib9c8b7f863063b384c41dea32e2b4b01f0695f82 Fixes: PYSIDE-1955 Pick-to: 6.6 6.5 6.2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Tests: Stop comparing QMimeType descriptionsFriedemann Kleint2024-02-161-4/+3
| | | | | | | | | Updates to freedesktop.org.xml in QMimeDatabase can break the test. Task-number: PYSIDE-2497 Change-Id: I812fafd37f98bd44f5b61c2c247eca34ebafa047 Reviewed-by: Christian Tismer <tismer@stackless.com>
* qmimedatabase_test.py: Fix for 6.7/WindowsFriedemann Kleint2024-02-151-2/+1
| | | | | | | | | | The mime type returns an upper case description on Windows. Task-number: PYSIDE-2497 Change-Id: I6d2254080d71feb9cd9a42c2f12c168ad3eae5e1 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* QTimer: Call C++ function for singleShot timersAdrian Herrmann2024-02-131-1/+63
| | | | | | | | | | | | | The current implementation of singleshot timers is very old and bypasses the C++ function. Instead, a timer object is manually created and started. This incurs a performance penalty, as this bypasses the optimized code path for 0 timers that eschews a timer object in favor of directly calling QMetaObject::invokeMethod. This is now fixed, and for 0 timers, the C++ function is called directly. Change-Id: Idfed06d60eb34355242818ac2df46f75dd27353c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* QTimer: Fix singleShot overload with contextAdrian Herrmann2024-02-071-0/+11
| | | | | | | | | | | The singleShot overload with context had a problem where if the functor was a slot of a QObject, it would not have a sender when it should. To fix this, the newly added QObject.connect() overload with context is used. Pick-to: 6.6 Change-Id: I654c09efb0d1b37ea0c014e9f17cd5e1913d1a96 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Change QObject.disconnect() to return False with warning on failureFriedemann Kleint2024-01-161-1/+1
| | | | | | | | | | [ChangeLog][PySide6] QObject.disconnect() now returns False instead of raising an exception for non-fatal cases. Fixes: PYSIDE-1275 Change-Id: I860b69e1a7055c38f903ffafd7f816575c0d1f7a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix qCompress/qUncompress() taking a PyBuffer/len argumentsFriedemann Kleint2024-01-051-1/+23
| | | | | | | | | | | | | | | | | | | | | | | The overloads taking a uchar * data argument were generated using the converter for uchar, causing warnings: qbytearray.h:639: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const uchar *' of argument 1 in function 'qCompress(const uchar * data, qsizetype nbytes, int compressionLevel)'. qbytearray.h:640: There's no user provided way (conversion rule, argument removal, custom code, etc) to handle the primitive type 'const uchar *' of argument 1 in function 'qUncompress(const uchar * data, qsizetype nbytes)'. This was never noticed since we have a conversion from PyBuffer to QByteArray and the overload decisor checks only whether the minimum argument is satifisfied, so, so qCompress(data,len,level) it called qCompress(bytearry,len), passing the length as level. To fix this, modify the argument to PyBuffer as is done for QImage and give it overload-number 0, so that PyBuffer is checked first without conversion to QByteArray. Add a test for both cases. Amends ae51319fa8a7c02642f5d35f5d613c22e9ce8ecb. Task-number: PYSIDE-838 Change-Id: Ib9b22a24257fcf93ce3458d8514cdda2e4843f64 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Implement QLockFile::getLockInfo()Friedemann Kleint2023-12-201-0/+3
| | | | | | Change-Id: Idd19498383f3a785a6a393ff8e9d07b6d45bb14e Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Avoid converting to string for calculating the hash valueFriedemann Kleint2023-12-191-2/+33
| | | | | | | | | | | | | | | Partially revert bf8a60db4cdbfc3e7c9c98778b219e9c83746d44, which introduced a helper function converting to QString for Q(Date)(Time) and QUrl. For these classes, the qHash() function should be found by the code model after 9c37876d6f649b3c9bd1411d3c7ffe620786f1a8. Extend the test accordingly. Deprecate the QString-helper. Task-number: PYSIDE-1906 Change-Id: Ia210a2210bc6a43991d5b26374039f4e86d0e71e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Tests: Fix some flake warningsFriedemann Kleint2023-11-289-13/+13
| | | | | | | | Mostly spacing related. Pick-to: 6.6 Change-Id: I748a8a06f456c5d4bafb94c397c43b3b2ee9e3e9 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* QTimer: Implement singleShot signatures w/ contextAdrian Herrmann2023-11-241-2/+28
| | | | | | | | | | | | On C++, it is possible to call singleShot timers with a context object as an argument. This allows posting events to the event loop of the given context object's thread, instead of the thread of the current thread. Implement corresponding signatures to add this capability to Qt for Python. Pick-to: 6.6 Change-Id: I0c4e3ef4b859cdfaac07415ff64c440821e7f442 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add QMetaMethod::invoke()Friedemann Kleint2023-11-011-0/+21
| | | | | | | | | | [ChangeLog][PySide6] QMetaMethod.invoke() has been added. Pick-to: 6.6 Fixes: PYSIDE-2500 Change-Id: I270489ec9372ddfee19e9342c1312d8c446ee5d9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* QIODevice: Implement buffered readsAdrian Herrmann2023-08-311-0/+78
| | | | | | | | | | | | Some users of QIODevice read functions (read, readLine and peek) might want to use fixed buffers to avoid reallocation, e.g., asyncio's buffered protocols. This adds overloads of said read functions that take an input buffer (as a bytearray) and return the number of read bytes. Pick-to: 6.5 Change-Id: I0c3678d3a87811029278c5ae8f829eef0432099a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PySide6: Fix up QDataStream.readRawData/writeRawData()Friedemann Kleint2023-08-291-0/+10
| | | | | | | | | | | writeRawData() was historically implemented to take a string. Fix the signature. Add an overload for PyBuffer/bytes. Fix the return type of readRawData() to be bytes. Fixes: PYSIDE-2442 Change-Id: I1684afd5aae2f8d118fa2fac87d916c23bd4a59e Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Brush up code related to pre-Jira bug 1019Friedemann Kleint2023-08-221-0/+1
| | | | | | | | | | Add explanatory comments; fix up the debug operator of GetReceiverResult. Task-number: PYSIDE-2418 Pick-to: 6.5 Change-Id: I77b9ad2d38a5bba1b78ffaf8835f20fbb93636d0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix QLocale.toLong return valueCristián Maureira-Fredes2023-08-151-0/+5
| | | | | | | | | | | | | | | | | | The currently implementation was using an inherited toLong function, not returning the Tuple[int, bool] that the docs described. This adds a modification to follow the same idea of all the other to*() methods. Additionally, we remove all the to*() methods that accept a QStringView, due to behaving the same with the QString variations. [ChangeLog][pyside6] QLocale.toLong now properly returns a (int, bool) rather than only int Fixes: PYSIDE-2226 Change-Id: I5634e4010982e115c8208fdb9b56cfc57960358b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix 3 strange cases in QSettings.value() round trips of a listFriedemann Kleint2023-07-071-0/+17
| | | | | | | | | | | | | | | | | | | - The "default value" parameter had an int 0 default value, which lead to strange behavior ['0'] being returned for string lists with missing keys. - QStringList was not converted when forcing the type to be list due to the QByteArray split mechanism. - String values could not be coerced to a list Fix the default value to have a default {}. Add a helper function checking whether a custom type conversion is actually needed or the default QVariant converter can handle it. Pick-to: 6.5 Task-number: PYSIDE-2381 Change-Id: I91b22c05f851c2dc8c3792bd9f1446cfc8ceba51 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyEnum: Remove the now unreachable test cases for old enumsChristian Tismer2023-06-196-69/+8
| | | | | | | Task-number: PYSIDE-1735 Change-Id: I51e68c50872f1d1254218ae7556ba607f73c4ea9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PyEnum: Update docs and rename the optionChristian Tismer2023-06-166-11/+11
| | | | | | | | | | | | | The new Enum implementation can no longer be switched off. Individual features can still be deselected with the environment variable PYSIDE6_OPTION_PYTHON_ENUM which had the name PYSIDE63_OPTION_PYTHON_ENUM before. This change is meant for PySide 6.6 . Task-number: PYSIDE-1735 Change-Id: Iae5b7a9d42a0d7b005dbba20201a80713ef79be9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide6: Fix connecting signals with arguments by constructor kwargsFriedemann Kleint2023-05-221-1/+29
| | | | | | | | | | | | The search was only implemented for signals without arguments by appending "()" to the signal name to form the search signature. Implement a search by signal name only. Fixes: PYSIDE-2329 Pick-to: 6.5 Change-Id: I295150cdebe60c886891553c9f31d14011a004d6 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Prevent crash when connecting to temporary signal sourcesFriedemann Kleint2023-05-171-1/+6
| | | | | | | | | Add a check to the connect function. Pick-to: 6.5 Fixes: PYSIDE-2328 Change-Id: I62a10ef5710487f8ab23cc46c1cc4a34fab5e2b1 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* testing: modernize UsesQApplication and remove other versionsChristian Tismer2023-03-1614-43/+43
| | | | | | | | | | | | The last change to UsesQApplication can be generalized to be able to remove the QtCore and QtGui versions. Instead, the module and class to use are computed from the content of sys.modules . Task-number: PYSIDE-1564 Change-Id: Iac1fe3a2d6bb5a9f7638eb889f55b079cb55c272 Pick-to: 6.4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide: Add QRunnable create()Shyamnath Premnadh2023-02-272-0/+46
| | | | | | Fixes: PYSIDE-2234 Change-Id: I3fc1c669c3985a8aad57785927fb4e48e69431a4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add QMetaMethod.fromSignal()Friedemann Kleint2023-02-271-2/+8
| | | | | | Fixes: PYSIDE-2236 Change-Id: Ibf516529799b35982c8c210f657983d511b622a0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add license headers to cmake filesFriedemann Kleint2023-02-161-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Task-number: QTBUG-105718 Task-number: QTBUG-88621 Change-Id: I98bd2e80f182d8bf7aef6b633f37a428e2dac69b Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* testing: make multiple_feature_test.py less verboseChristian Tismer2023-02-131-4/+8
| | | | | | | | | | | | The test writes out very much when there is any error happening in CI. With NoGIL, this becomes very boring. It now only prints if the "-v" flag is given. Task-number: PYSIDE-2221 Change-Id: I511b1fd56407a875797cfec958f5e0beff42f7a3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* signals: Introduce Weak Reference to protect lost SignalInstanceChristian Tismer2023-02-021-1/+26
| | | | | | | | | | | | | | | | This first solution detects the vanishing object and raises an exception. Trying to revive the object was unsuccessful. Since this happens only when no signals are connected, it is ok to leave it this way. Change-Id: Ib47f85657363b675cec3616b5550ce41d93fb4d3 Fixes: PYSIDE-2201 Pick-to: 6.4 Task-number: PYSIDE-79 Task-number: PYSIDE-68 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Add order depending on type range for C++ primitive types to the ↵Friedemann Kleint2023-01-091-0/+5
| | | | | | | | | | overload sorter Task-number: PYSIDE-2168 Task-number: PYSIDE-2133 Change-Id: I81e9d3369b1f4533239a172f48d11f52731f8484 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* PySide6: Fix negative values causing an error in QLocale.toString()Friedemann Kleint2023-01-091-0/+6
| | | | | | | | | | | Apply the same filtering as introduced for toCurrencyString() by 52e3b960b30950ac7bb59bb31e00d6d1038828f1 to prevent unsigned overloads from being generated. Fixes: PYSIDE-2168 Pick-to: 6.4 6.2 Change-Id: I3b74e9db238e9b4f34fd7bc1ff7a3a5ac7682d37 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix QObject::sender() for non-C++ slotsFriedemann Kleint2022-12-122-0/+64
| | | | | | | | | | | | | | | For non-C++ slots routed via GlobalReceiverV2, sender() of the receiving QObject returns 0. To fix this, store the sender obtained in GlobalReceiverV2::qt_metacall() temporarily in a special dynamic property of the receiver and inject code checking it into QObject::sender(). This fixes at least the synchronous calls. Fixes: PYSIDE-2144 Fixes: PYSIDE-1295 Change-Id: Ia111162eb1404914ecfb7f19fadb8a1b63ae8b4a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Fix float type overloads of QLocale.toCurrencyString()Friedemann Kleint2022-11-251-0/+6
| | | | | | | | | | | | | | | | | | | QLocale.toCurrencyString() has a plethora of overloads from short/ushort to long long and float types. Since the overload sorter currently has no rules for preferring float over unsigned integer types, an unsigned conversion was done for float types with decimals, resulting in decimals being lost. This could arguably be fixed by adding rules for preferring float over unsigned integer types. However, since Python only knows int and float, it does not really make sense to generate a complex overload logic. Remove the unsigned and short overloads instead. Fixes: PYSIDE-2133 Pick-to: 6.4 6.2 Change-Id: Id2ef2ec02f4f962606851faf237d80196872eed2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add .pyproject files for the testsFriedemann Kleint2022-11-111-0/+148
| | | | | | | | Makes navigation with Qt Creator easier. Change-Id: I40c6bc641faddcdbd265d6e886c2f3bd3b271be5 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix TypeError when comparing Qt.Flags and objectsAdrian Herrmann2022-09-081-0/+19
| | | | | | | | | | | | | Comparing a QtCore.Qt.Flags object with any other object calls the PySideQFlags_tp_richcompare() function. This function always threw a TypeError when comparing to a non-numerical object, causing undesired effects. Account for these cases now by returning True or False if the compare operator is != or ==, respectively. Pick-to: 6.3 6.2 Fixes: PYSIDE-2048 Change-Id: Ic81a65ace743b57e90ffe7883e42eb8330b78832 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Enable type strings in Q_ARG/Q_RETURN_ARG for QMetaObject.invokeMethod()Friedemann Kleint2022-09-061-1/+11
| | | | | | | | | | | | This enables using "QVariant", which is needed for QML. Amends aae2f599e8215e49747c9b5dce698d35b913c6c7. Remove a left-over qDebug(). Task-number: PYSIDE-1898 Change-Id: Ibbb543cfe582eba5d652dc180191c2741730c4e6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyEnum: Define a fixed list of Int(Enum|Flag) decisionsChristian Tismer2022-08-133-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | This was "PyEnum: Write a default Int decisor for Enum and Flag". Historically, C++ enums were all compatible with int. The new Python enums are more diverse here. There are the basic types Enum/IntEnum and Flag/IntFlag. We have tried a lot to come up with a sensible default heuristic computed from the data. In the end, this was reverted and replaced by a fixed list that was collected from similar implementations. By the move away from Int inheritance, a few classes needed extra support. Python 3.11.0b5 also required the Flag creation parameter "boundary=KEEP". It is not clear if this is correct, yet. [ChangeLog][shiboken6] Most former IntEnum/IntFlag are replaced by pure Enum/Flag classes in a generally compatible way to other implementations. Change-Id: I1dbe7b0556a3375df89eb40e9d9f495f14bf42b1 Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyEnum: Simplify the test-cases with the new forgiveness modeChristian Tismer2022-07-142-21/+15
| | | | | | | | | | | | | | | | | | | | | | With the new forgiveness, all the "normal" uses of old enums are working with the new enums, too. What does not work are range violations and inheritance of enums from other enums. Also, the implemented trick does not work for enums which do not belong to a class. The induced bugs are easy to find, because they should normally break at import time. [ChangeLog][PySide6] The new forgiveness mode of Python enums allows to use old enum code, most of the time. Much changed test code was reverted. Change-Id: I9c081831309f1b2358fe86e6107b0f4d78fd48cf Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyEnum: Increase compatibility by allowing defaults and old flag namesChristian Tismer2022-07-141-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch supports to write Qt.Alignment() instead of Qt.AlignmentFlag(0) Also supported is Qt.AlignmentFlag() which is mapped to Qt.AlignmentFlag(0) This trickery was quite involved since the Python opcodes needed to be analyzed if we have a parameterless call. Only in that case, we insert a partial object which supplies the missing value=0 default. Changing the implementation of PyEnum was not desired because this is highly complicated, not portable and even not possible. The change has been tested with Python 3.6 to 3.11.0b3 . [ChangeLog][shiboken6] The new Python enums are made as compatible to the old ones as possible. It is again allowed to use Qt.Alignment() instead of Qt.AlignmentFlag(0), and a default of 0 is always allowed. Change-Id: If6a93f8210ff6cae4e38251420e1ad5fffbe42cb Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Christian Tismer <tismer@stackless.com>
* PyEnum: make forgiving duplicates work with Python 3.11Christian Tismer2022-07-141-3/+4
| | | | | | | | | | | | | | | | | | | There was a silent change in PyEnums that turns Enum attributes into properties. This does not harm the Python interface but needed some change in the duplication emulation. Furthermore, new internal enums are created with an underscore name. The meta class was changed from EnumMeta to EnumType. [ChangeLog][shiboken6] The new Python Enums are now compatible with Python 3.11 Change-Id: I3b1ab63dc5eed15a75ebd0f42dddf4001f640c00 Pick-to: 6.3 Task-number: PYSIDE-1735 Fixes: PYSIDE-1960 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyEnum: Remove the old duplication of Enums in the enclosing scopeChristian Tismer2022-06-211-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When implementing Python enums, the behavior of old Qt enums was copied: Every enum was also inserted into the enclosing scope. This patch removes that for two reasons: - it is inconsequent to keep an old quirk when we have all enums renewed so much - It is more consistent compared to our competitor - it is a prerequisite to implement efficient lazy initialization PROBLEM: Many constants (about 110) are no longer recognized, for instance `Qt.AlignLeft` should be `Qt.AlignmentFlag.AlignLeft`. The question is if that can be fixed easily in C++, or if the file mapping.py should get ~100 new fixes? SOLUTION: We allow the old enums, but tell nobody that they continue to work. They also are not advertized in the PYI files. [ChangeLog][PySide6] The duplication of enum values into the enclosing scope, allowing to write Qt.AlignLeft instead of Qt.Alignment.AlignLeft, is still implemented but no longer advertized in PYI files or line completion. Task-number: PYSIDE-1735 Change-Id: I79a90d08f2a5a3a069fa551e60d609ecad718239 Pick-to: 6.3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QEnum: Adapt to the new enum implementationChristian Tismer2022-06-151-2/+0
| | | | | | | | | | | | | | | | | | QEnum was implemented with Python enums, as opposed to the old C++ enums. Now that support for Python enums is built into PySide, it is necessary to keep the implementing Python modules always the same. This patch prepares QEnum and PyEnum compatibility for the upcoming embedding of old enum implementations. As a side effect: Python 3.6 and 3.7 had a hard-to-find refcount error when creating new enums. Task-number: PYSIDE-1735 Change-Id: Ic44459c8e319d6d0308c7366beafa6fe7df41b79 Pick-to: 6.3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-27144-4054/+289
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: I065150015bdb84a3096b5b39c061cf0a20ab637d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyEnum: Prepare Enum tests for both old and new enums, amendedChristian Tismer2022-05-241-1/+1
| | | | | | | | | | | bug_462.py had a precedence bug that was fixed in 6.3, already. e must fix it here because the check-in was done already. Explicitly no pick-to. Task-number: PYSIDE-1735 Change-Id: Iaebd53e566bdfd73d2761268b3691f35c2f9de7c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PyEnum: Prepare Enum tests for both old and new enumsChristian Tismer2022-05-225-9/+21
| | | | | | | | | | | | | | | | | | These tests are now completely identical to the old tests and have an adapted Python Enum version if suitable. Both versions can be selected once at runtime. Having both test versions available as a runtime option is a nice feature that really helps understanding the consequences of the PyEnum move. [ChangeLog][PySide6] The QEnum tests are enabled for both the old Qt Enums and the new Python Enums. Change-Id: I78a7473f4a86f8d2115acc56e4ed11cf135eb000 Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Implement Q_ARG/Q_RETURN_ARG for QMetaObject.invokeMethod() with argumentsFriedemann Kleint2022-05-101-4/+80
| | | | | | | | | | | Introduce an internal type QGeneric(Return)ArgumentHolder which casts to QGeneric(Return)Argument and stores a QMetaType along with a data pointer. It is returned by Q_ARG/Q_RETURN_ARG and then handled in QMetaObject.invokeMethod(). Fixes: PYSIDE-1898 Change-Id: I229cb03d5d71c3b32a2e1eb4040f7641b8e49000 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>