aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-03-04482-435/+2559
|\ | | | | | | Change-Id: I7a94c67fdb9225edf4d605e67839a1f6f7375c2a
| * Fix running the PySide2 tests for Python 3.8/WindowsFriedemann Kleint2020-02-28479-332/+2512
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows, DLL directories can no longer be specified via the PATH environment variable. They need to be added via os.add_dll_directory(). In order to fix this, move the entire environment setup from CMake to a python helper and set the environment variables BUILD_DIR and QT_DIR pointing to the build directory and Qt directory, respectively, from CMake. In addition, this has a huge advantage: The tests can also be executed much more easily without ctest from the command line by just setting BUILD_DIR and QT_DIR instead of a complex manipulation of PATH/LD_LIBRARY_PATH. Change-Id: I7d518ccab19ca184c3112a126c779d4a6d7c6c5e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * Unify the py3kcompat.py test helpersFriedemann Kleint2020-02-273-103/+47
| | | | | | | | | | | | | | Put everything into a single file and mark them as copies. Change-Id: I782247520d6976695a14f762e8247e5c4eb46aac Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-02-271-6/+33
|\| | | | | | | Change-Id: I64cb93d53a2811ba695820501287902995140f9a
| * Fix web_engine_custom_scheme.pyFriedemann Kleint2020-02-241-6/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a flag to distinguish timeouts from successful loading. Register the scheme properly and set "Path" syntax, fixing the warning: Please register the custom scheme 'testpy' via QWebEngineUrlScheme::registerScheme() before installing the custom scheme handler. Add required initializations of QWebEngine and embed the view into a top level widget, as using a QWebEngineView as a top level on Windows hangs. Change-Id: Id39a6b14606795216994928ad82f60435f4caaca Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Friedemann Kleint2020-02-244-51/+6
|\| | | | | | | Change-Id: I587b40f07da85d431d4fdb6f98259a9be0bb73e5
| * Turn qApp into a normal Python variable, finallyChristian Tismer2020-02-214-51/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | shiboken: Add a test for smart pointers used in different librariesFriedemann Kleint2020-02-211-2/+2
|/ | | | | | | | Generate different instantiations in libsmart and libother. Task-number: PYSIDE-1024 Change-Id: Id29cea65e48209fa226ce3142f3af72b99bf4662 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Pyside2/tests: Split the helper moduleFriedemann Kleint2020-02-20205-373/+535
| | | | | | | | | | The classes of the helper module were defined in the __init__.py file with complicated logic to test for presence of the modules. Split the classes apart and empty the __init__.py file (still required for Python2). Change-Id: I4f4971f9a48e2961233da5585aa0df53bfbb9c7a Reviewed-by: Christian Tismer <tismer@stackless.com>
* Make PySide2 tests using the helper modules from 'util' self-containedFriedemann Kleint2020-02-19224-74/+1001
| | | | | | | | | | Add the relative import path to locate the modules "helper" and "py3kcompat". The tests can then be launched from the command line without the ctest environment. Change-Id: Ia50663d7381b52cb248de3e4d23002a195ca9139 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Improve the libdir for windowsCristián Maureira-Fredes2020-02-181-1/+8
| | | | | | | | | | | | | | | | | | With virtualenv 20 we have the case where the first path in the PYTHON_LIBRARIES cmake variable was wrong: a_virtual_env/libs/python3.lib so the python code inside the helper didn't have a proper check if the file was valid or it was just a wrong construct. Additionally, the 'prefix' variable will contain the virtual environment directory location, which will not contain the 'libs' directory, because that's included in the system's installation path. To solve this, we use the 'INCLUDEPY' directory, which is correct as a base to create the real 'libs' one. Task-number: PYSIDE-1231 Change-Id: Ifca08d74c49cd57572836a087edb96c089266dc7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix testrunner for Python 3.8/LinuxFriedemann Kleint2020-02-071-4/+18
| | | | | | | | | | | | | | | | | | | When running tests with Python 3.8/Linux, the existence_test fails: File "pyside-setup/sources/pyside2/tests/registry/existence_test.py", line 73 from init_platform import enum_all, generate_all File "pyside-setup/sources/pyside2/tests/registry/init_platform.py", line 59 from util import get_refpath, get_script_dir File "pyside-setup/sources/pyside2/tests/registry/util.py", line 113 platform_name = "".join(distro.linux_distribution()[:2]).lower() AttributeError module 'platform' has no attribute 'linux_distribution' since platform.linux_distribution() was removed in 3.8. Extract into a separate method and warn to install distro. Task-number: PYSIDE-939 Change-Id: I42d04830d51563cc3fbaddc3941c927402514480 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix PyBuffer interface for QByteArrayCristián Maureira-Fredes2020-02-051-0/+6
| | | | | | | | | | | | | 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>
* Let qApp be noApp instead of pretending to be NoneChristian Tismer2020-01-293-16/+9
| | | | | | | | | | | | | | | | | | | | qApp should stay almost as it is with only two cosmetic changes: When qApp's return value has Type(Py_None), the value now reports "noApp" instead of "None". Also the feature of "del __builtins__.qApp" is replaced by function qApp.shutdown() . This makes things easier to explain and avoids refcounting hacks. The embedding problem (Falkon browser) was too complicated. We finally solved it by disabling qApp in embedded mode. Change-Id: I0d99661137130684823aa3d1978b494d8ab08e59 Fixes: PYSIDE-1158 Fixes: PYSIDE-1178 Fixes: PYSIDE-1135 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix printer test in returnquadruplesofnumbers_test.py on some systemsFriedemann Kleint2020-01-241-0/+2
| | | | | | | | Setting the page margin used for comparing tuples requires a PDF printer. Ensure PDF format if no such printer can be found. Change-Id: Ie8509d4a336392cb711e210842664e238c487444 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix Python 3.8 problemsChristian Tismer2019-12-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | This patch fixes some refcounting problems with Python 3.8 . One incompatible change was announced in the what's new document, but actually there were two more problems which were not explicitly mentioned but took much time to sort out. The patch is compatible with the limited API changes (tested with debug build and API error disabled). It is also independent of the Python version which is full Limited API support. For more info, see the documentation mentioned below. The flag error is circumvented now! We either find a better solution or leave it as it is. For now this is ok. Fixes: PYSIDE-939 Change-Id: Iff4a9816857a6ebe86efd4b654d8921e4e464939 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Friedemann Kleint2019-11-284-4/+4
|\ | | | | | | Change-Id: I698090a9c9fdc995e00e39873aa35f8edda0f0b1
* | Replace imp by importlibCristián Maureira-Fredes2019-11-191-4/+4
| | | | | | | | | | | | | | | | Getting rid of the DeprecationWarning Change-Id: I86370c266d502fcd0fb61a9945770354b8f87142 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Simplify recreation of registry filesChristian Tismer2019-11-072-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The registry files were recreated when they do not exist. This was used to trigger recreation on a file. We now include a comment line on top of the files. #recreate # uncomment this to enforce generation By uncommenting this line, a NameError is provoked, which has the desired effect without creating huge deltas in the repository. Change-Id: Idcc1015abae504f111102e8c9851f8ef45dcbdff Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Update the registry files after merging 5.13 into 5.14Christian Tismer2019-11-014-0/+162439
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The merge of certain changes into 5.14 had quite a few side effects, because the registry files had not been generated for 5.13 at all. When a simplification had the effect of generating more registry entries, the merge broke because we did not have these entries in the registry. The "obvious" but wrong assumption was that the simplification gives a problem in 5.14. But the truth is that by generating the files before the merge created too few entries, and that made it complain. A simple reset was the solution. We will try to further simplify the generation of new registry files without creating huge deltas. Change-Id: I680b3a1d3eeb4b981736ff6fe46857ee3135b735 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Make the scrape script robust enough, againChristian Tismer2019-10-311-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The script scrape_testresults.py analyzes log files in order to find embedded script files for the registry. This script does not try to be absolute water-proof but handled the existing cases well. By chance, the text "BEGIN_FILE", which is used as an indicator, was found in a traceback from the generating script. We modified the search to ignore this text in single quotes, but also changed the originating file testing/runner.py to no longer contain this text in the future. Change-Id: I1fef1cf5e9b85fc94b7ee52edbdf4afa4bf4e35a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Friedemann Kleint2019-10-318-11/+200
|\| | | | | | | Change-Id: I9f31a647fd9d4ad9c854a307f8b5df1be935354a
| * Fix booleans and empty list cases in QSettingsCristián Maureira-Fredes2019-10-281-3/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Add support for __repr__ in QObject derived classesAndreas Beckermann2019-10-257-8/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently shiboken generates classes without __repr__ for QObject derived classes. However for all non-QObject classes that have an operator<<() for QDebug, it *does* add a valid repr implementation. Extend this behavior to QObject classes as well. In order for this to become more useful, also check for the indirection of operator<<(): If operator<<(QDebug, Foo*) is available, use the current non-value-type behavior, (i.e. provide cppSelf to operator<<()), but if operator<<(QDebug, const Foo&) is available instead, use the same behavior as for value-types, i.e. provide *cppSelf. This greatly increases the number of classes where operator<<() provides useful results. Also make sure to check for operator<<() in namespaces (recursively), not just at global scope. Change-Id: Ief9158455a25e332f07169f09692cafb8097078b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Fix the registry after mergingChristian Tismer2019-10-304-157295/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 5.13 we did not check the registry. By change https://codereview.qt-project.org/c/pyside/pyside-setup/+/278244 more functions are generated, which are not yet in 5.14 . By repeating the removal of that patch, together with the recreation of the registry files, we add by hand what the merge could not do automatically. This took quite a while to understand :-) "SharedPtr" and maybe other classes may create an infinite recursion via some "._gorg" property from the typing module for Python 2.7 . We simply skip that effect. Change-Id: I85568b08bb6ac87b5dbf6a2823e4a71f69f8b4ad Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Improve the NumPy Support by iterablesChristian Tismer2019-10-302-8/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Working example, by overriding cppgenerator: >>> from PySide2 import * >>> QtCore.QUrl.fromStringList(("asd", "def")) [PySide2.QtCore.QUrl('asd'), PySide2.QtCore.QUrl('def')] >>> def func(lis): ... for thing in lis: ... yield thing ... >>> QtCore.QUrl.fromStringList(func(["asd", "def"])) [PySide2.QtCore.QUrl('asd'), PySide2.QtCore.QUrl('def')] Also working, by overriding shibokengenerator >>> QtGui.QMatrix4x4(func(range(16))) And all other QMatrix sizes as well: >>> QtGui.QMatrix2x2(func(range(4))) >>> QtGui.QMatrix2x3(func(range(6))) The PySequence cases seem to be quite completely covered. Supporting lists and QVector is not yet clear and needs more research. Note.. QtOpenGLFunctions is not tested at all and nothing works on macOS, segfault. Ignored for now! A simple numpy test shows how versatile this solution is. We now need to improve signatures and error messages to optimize the experience. Task-number: PYSIDE-795 Change-Id: I195cd46cf47c2eb83276fe48fce8e6070cf30fda Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | init_platform.py: Add missing importFriedemann Kleint2019-10-291-1/+1
| | | | | | | | | | | | | | | | Amends ec1121a8768ccdba1788f09ad3147b36b73e5cc2. Task-number: PYSIDE-795 Change-Id: I957420f961b2c7c1349c32522543c0d31d2d504e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Make the function registry more usable in Python modulesChristian Tismer2019-10-283-65/+78
| | | | | | | | | | | | | | | | | | | | | | | | It was impossible to use the registry in other functions without many dependencies. The numpy support made it desirable to write new test functions which lead to this refactoring. Task-number: PYSIDE-795 Change-Id: I60bd78a8eaec95dcb4840645c76629b1ef2b50f9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Registry/init_platform.py: Output build informationFriedemann Kleint2019-10-241-4/+19
| | | | | | | | | | | | | | Add Python version/build and Qt build to the header. Change-Id: I1cf39c4cb3663511087af737bbe2257038e19fb6 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Update CI registries and URL for scrape scriptCristián Maureira-Fredes2019-10-245-442/+17
| | | | | | | | | | Change-Id: I0c2ebdfd91903f824851590112733025b93eb845 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Friedemann Kleint2019-10-081-0/+18
|\| | | | | | | Change-Id: Ibe15176ae36ea31bd1799d9bf8a39b57f9338ca0
| * Fix bad shutdown effect on QApplication.instance()Christian Tismer2019-09-301-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When app = QtWidgets.QApplication.instance() is used before a QApplication has been created, the qApp code sees no qApp instance in C++ and assumes a shutdown. This patch keeps track of QApplication being created and behaves correctly on that aspect. It is still unsolved that QtCore.QObject.staticMetaObject gets deleted on a qApp shutdown, which is too much. I think this can be handled in another patch if at all, since the shutdown / recreate feature is undocumented and of little use. Change-Id: I140b6dba45f7cd337580373dbf72bc6d0a625fea Fixes: PYSIDE-1093 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Enable the Function Registry for 5.14 finaleChristian Tismer2019-10-0119-287871/+157721
| | | | | | | | | | | | | | | | | | | | | | This concludes the registry start for 5.14 with improved files. Old versions are removed, since the format has changed quite much. Task-number: PYSIDE-795 Change-Id: I3c5dc1480d1eecce4018e4b6a5856d7961fbef86 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Enable the Function Registry for 5.14 augmentedChristian Tismer2019-09-302-10/+39
| | | | | | | | | | | | | | This patch fixes some small quirks and improves the scraping. Change-Id: Ia0366e2e29c833fe985353768de166fd538f0d24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Enable the Function Registry for 5.14Christian Tismer2019-09-283-19/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function registry was not enabled for versions greater than 5.12 . This is now needed, since the function registry will be used in the tests for the improved NumPy support. There were new cases of Python keywords touched by enums which had to be renamed. This was moved into the code generator instead of the runtime overhead. The formatting of the enums was rewritten and reports all enums now that can be found (also those which are copied into the parent class). The formatting of the function registry had not been used for a long time and had entries that showed the wrong number of subclasses. The usage of the registry was also simplified by using the full names of functions. They can now directly be accessed. Task-number: PYSIDE-795 Change-Id: I734f6811205f3c3528a911975677eb677fedd2dd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Add Qt Core bindings for Qt 5.14Friedemann Kleint2019-09-052-0/+50
| | | | | | | | | | | | | | | | | | | | | | Adding the new QCalendar class is required to unlock the branch since the rejected constructor QDate(int, int, int, QCalendar) causes test failures in of QDate. Task-number: PYSIDE-487 Change-Id: I2720b92f3356421065f539ea0eba75d3049b9702 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Friedemann Kleint2019-08-191-9/+5
|\| | | | | | | Change-Id: I56b8450c17fd83a24ee2ec9eb8f66f3530caba6c
| * simplify the qslot_object_test to use the qApp macroChristian Tismer2019-08-151-9/+5
| | | | | | | | | | | | | | | | | | The qslot_object_test needed an adjustment, because it uses the name "qApp" without being aware that a qApp builtin variable exists for exactly that purpose. Change-Id: Ic3df95ee33ece5de573b2dcc6ec2d6e2a1ffee73 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | PySide: Create a framework for deprecated functionsChristian Tismer2019-08-062-1/+20
|/ | | | | | | | | | | | | | | | | | | | | During development of the patch "Support Pointer Primitive Types by Arrays or Result Tuples" some functions in QtGui turned out to be removal candidates. The name "constData" should be deprecated in favor of the existing "data" function. Other implementation also do not have this. Instead of simply removing, we now create a surrogate function with the name "constData" in fure Python that gives a warning and calls the "data" function. This is now extracted into its own commit since the deprecation is a completely different and independent issue. The implementation does not do any extra imports in advance. and is easily extensible to more post-installation actions. Task-number: PYSIDE-795 Change-Id: I410c69a87d9f0df78f736991b2ee0a2747678911 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Change QtQml tests file permissions to 644Cristián Maureira-Fredes2019-07-1734-0/+0
| | | | | Change-Id: I0447da5e1ace3f6acc930aa4296576ec447f1be5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add optional support for types in QSettings::valueCristián Maureira-Fredes2019-07-173-0/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add support for parameterNames in SignalsCristian Maureira-Fredes2019-07-043-0/+127
| | | | | | | | | | | | | | | | | | | | | | There were many uses cases when a proper interaction between Python and Qml was needed, one of them was the case to emit signals from Python an get those values via an argument name in QML. A simple example describing this situation can be found in PYSIDE-634: Python: sumResult = Signal(int, arguments=["sum"]) sumResult.emit(42) Qml: onSumResult: console.log(sum) // will print 42 A test case based on the same example was added. Change-Id: I0908f97d88eaadc0c02d81bc4daca936f72f6c6a Fixes: PYSIDE-634 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Cleanup pointer and trailing whitespace (omissions)Christian Tismer2019-06-2516-46/+46
| | | | | | | | | | | | | | | | | The "Cleanup pointer whitespace" patch was augmented by some C++11 changes. Unfortunately, this was done in the same commit, and so some old whitespace that was removed could re-appear invisibly, since it was in the original version. This fix tries to remove all trailing whitespace and also adds a few " *" corrections that were lost. The "type *" entries in XML files were changed back to "type*". Change-Id: Ic5c945ad64a47455fb15eebdf184b126af5ecd1d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Cleanup pointer whitespace everywhereChristian Tismer2019-06-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* PySide: Allow any existing attribute in the constructorChristian Tismer2019-06-042-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are signals and properties which are correctly supported in PySide by the function "fillQtProperties". The structures are introspected by calling "QMetaObject::indexOfSignal" and "QMetaObject::indexOfProperty". By allowing any property, extending the above restriction, we break the Qt API slightly, but have the tremendous advantage of being able to write all needed properties into the constructor call. This approach is a compromize that keeps the attribute calls as they currently are. Supporting real properties where we actually have getter and setter functions would be possible as well, but that would break compatibility very much! It has to be discussed if we want to support a configuration switch that enables this incompatible change. If we would go this far, then I would do this together with changing mixedCase to lower_case. A simple test case has been added. Task-number: PYSIDE-1019 Change-Id: I8094df51d63aa767a5a9ec1c83bcf7db7b157a01 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* correct bool(qApp) on Python 2Christian Tismer2019-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | The idiom to create an application if none exists qApp or QApplication() did not work on Python 2. This was recognized when another unrelated test broke that tried to use the idiom. This patch adds the missing method to Py_TYPE(Py_None) which Python 3 already has. A test case was added. Side-effect.. The warning about missing braces is gone, after the "PYTHON_IS_PYTHON3" macro is defined. This was forgotten in the review when when the macro was moved out of signature.cpp . Task-number: PYSIDE-571 Change-Id: I9b9304f407cd4cafb3ba0945ffb045802503a343 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Implement the Buffer Protocol on VoidPtrRenaud Aubin2019-06-051-1/+6
| | | | | | | | | | Some use cases need direct data access for performance, e.g. initializing QPolygonF data with numpy.frombuffer. Implementing the Buffer Protocol as described in PEP3118 will allow direct data access. Change-Id: I13c46055b1cba115d099f1becb64c4cd04acdf0e Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Make it possible to extend namespacesFriedemann Kleint2019-05-222-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt has some modules, where functions and classes are added to namespaces of other modules. For example, QtGui adds the free functions mightBeRichText() and convertFromPlainText() to the "Qt" namespace and Qt3DQuick adds a namespace "Quick" to the namespace "Qt3DCore" started in Qt3DCore. Shiboken was unable to handle this since the name of the index constant was derived from the namespace name and would thus clash. Also, all code model items from the base module would be re-generated into the extended namespace. To fix this: - No longer join namespace code model items in clang builder. - Search for pre-existing namespaces in traverseNamespace() before creating a new one, continuing populating it. - Add a "files" attribute taking a regular expression to match header names to the namespace type entry, making it possible to restrict code model items by files when extending namespaces (as otherwise, all base items are again added). - Add "extends" attribute specifying the package name of the namespace to extend, which will be used as base type in CPython. - Disambiguate the SBK indexes of namespaces and the init_ functions by adding the module name. Change-Id: Ib552e878911942fa4d52d2bb0c6695e5b2c4c341 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add PySide2: Add OpenGL version functions as separate moduleFriedemann Kleint2019-05-021-0/+1
| | | | | | | | | The OpenGL version functions produce a lot of library code, so, add them as a separate module. Task-number: PYSIDE-955 Change-Id: I44737f4741f0a81f46a192961173e154ae66698e Reviewed-by: Christian Tismer <tismer@stackless.com>