aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/PySide2/glue/qtcore.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix booleans and empty list cases in QSettings5.12Cristián Maureira-Fredes2020-06-121-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> (cherry picked from commit ba04613a65be7b50bbcc9dae8c18d195243513c3) 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>
* Move inject-code snippets to separate filesCristian Maureira-Fredes2018-11-221-0/+1010
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When code must be modified or added to certain functions, we currently have two options: * Write a template and include it into the typesystem, * inject code directly at a certain place of the function entry. The problem with injecting raw code is that since it is an XML file, one need to escape protected symbols, like "<" and "&". Thanks to a couple of complementary commits, now we can place this code snippets on a separate file without triggering a whole module compiling process, since the typesystem itself will not be alterered. All the injected code from the typesystem was removed and placed into a single file per module inside a top-level directory called glue. Some small fixes were included mainly regarding styling of the code. Task-number: PYSIDE-834 Change-Id: I823e92d241a528d75d5940090008db9bf297f49e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* remove pyside2 and shiboken2 submodules (dev edition)Oswald Buddenhagen2017-05-221-15/+0
| | | | to be replaced by a subtree merge.
* update: bring repositories back in syncChristian Tismer2017-02-151-6/+12
| | | | | | | From time to time, it is good to update the master project. Change-Id: I50c45caf7c37ebb4ea865b4e4f5896e5cd8915fd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Update the pyside-setup submodulesChristian Tismer2016-12-121-10/+6
| | | | | | | | | | From time to time, submodules need to be updated. Actually, I would even like to update the master module after every submodule checkin, but this seems to be not easy to do all the time. Change-Id: I52f266c58086186df05ddcc85085f35e2e28ead7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Accept more errors in "testrunner.py"Christian Tismer2016-11-031-25/+10
| | | | | | | | Testrunner has even more variable texts to recognize. We change the regex slightly so that it always succeeds. Change-Id: Iac156592aac48afb5aea522540ae63c92ca2572a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix OS/X inclusion of framework headers.Alexandru Croitor2016-06-161-6/+25
| | | | | | | | | | | | | | | | | | | | | The recent change that made use of framework headers on OS/X did not work with homebrew Qt, and it didn't work with official builds either, because neither of the chosen include folders contained all the necessary headers to lead to a successful build. Fortunately shiboken actually supports being passed multiple include locations, separated by a colon on OS/X, and a semicolon on Windows. This patch makes sure to always pass the Qt include folder, and in case if the Qt build is a framework build, also passes the root frameworks location, with headers found by shiboken under frameworkName.framewework/Headers. This works for homebrew builds, official builds and custom non-installed prefix / in-source builds of Qt. Change-Id: I47b24e197839883de2ab873461efc1f4d4d33743 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add option to link with libc++ on older OSX versions.Alexandru Croitor2016-05-111-5/+8
| | | | | | | | | | | | | | Versions of OSX lower than 10.9 link libstdc++ by default. Also libstdc++ is linked when the osx minimum deployment target is lower than 10.9. The new option allows explicitly linking libc++ in the cases mentioned above. It is not enabled by default, because most libraries and executables on versions lower than 10.9 are compiled with libstdc++, and mixing standard library versions can lead to crashes. Change-Id: I7397d2bbce2cfceaeb848f25e0bbf1a24ac9bde8 Reviewed-by: Christian Tismer <tismer@stackless.com>
* fix the name pyside2uicChristian Tismer2016-04-191-8/+5
| | | | This was modified, but not corrected in setup.py
* updateChristian Tismer2016-03-011-7/+7
|
* updateChristian Tismer2015-12-291-5/+8
|
* move other readme files from pyside2 into the wikiChristian Tismer2015-12-131-8/+5
|
* merge all PRs unto #44 with updated wiki statusChristian Tismer2015-12-131-5/+8
|
* add project status to the wikiChristian Tismer2015-11-241-8/+5
|
* merge all until #33 inclusiveChristian Tismer2015-11-231-6/+8
|
* merge #21 #22Christian Tismer2015-11-151-8/+6
|
* Merge pull request #20 from empyrical/ws_fix_2Christian Tismer2015-11-141-7/+7
| | | | Add forgotten files to WebSockets module
* Merge pull request #19 from empyrical/ws_fixChristian Tismer2015-11-141-7/+7
| | | | Fix up the QtWebSockets module
* merged PR #15 #16 #17 from empyricalChristian Tismer2015-11-141-5/+8
|
* Merge pull request #16 from empyrical/qmlChristian Tismer2015-11-131-5/+5
| | | | Add Qt5 QML modules
* some tests correctedChristian Tismer2015-11-121-10/+5
|
* Fix pysidetest. We are at 74% good tests.Christian Tismer2015-11-101-7/+9
| | | | | | | As Romain correctly told me, QtCore is needed to be included. The other small bug with huge effects was a forgotten rename of pyside2_global.h. The tests now run without segfaults!
* after signals were fixed, we have the first working alpha that is able to ↵Christian Tismer2015-11-071-7/+8
| | | | show windows!
* merge the new signal supportChristian Tismer2015-11-071-0/+8
|
* updateChristian Tismer2015-10-241-6/+0
|
* suppress another sys info warning on OS XChristian Tismer2015-10-021-5/+5
|
* enforce the minimum supported Qt5 version to be 5.3.0Christian Tismer2015-10-021-8/+5
|
* fixing the fix ;-)Christian Tismer2015-09-281-7/+7
| | | | | CMAKE is a nightmare. And if you don't read the meaning of every variable (like UNIX or CMAKE_HOST_UNIX, which _includes_ APPLE), then the empire strikes back. :-)
* updateChristian Tismer2015-09-281-7/+7
|
* sub-reposChristian Tismer2015-09-281-8/+7
|
* )small fixes (right wiki, name changesChristian Tismer2015-09-251-8/+8
|
* fix a problem with QSysInfo::WinVersionChristian Tismer2015-09-241-7/+8
| | | | | | This always refused to link on OS X. To circumvent this, I have split the QSysInfo entry in Mac and Win version files. The "other" file is always giving a warning, that I suppressed.
* finally, pyside needs to be renamed in the XML filesChristian Tismer2015-09-221-6/+8
| | | | | The XML names like "PySide.QtCore" go into the binaries for import, so it is necessary to change them all. There are also hundreds of Python files which must bechanged, as well.
* change all scripts to respect the new PySide2 module name.Christian Tismer2015-09-211-9/+6
| | | | still, there seem to be errors....
* not-so-small fix to the huge change.Christian Tismer2015-09-211-13/+8
| | | | | | I just understood what is needed to define a package: The files PySide2Config(...).cmake are crucial, the project names have little to do with that.
* huge change on project layout.Christian Tismer2015-09-211-7/+13
| | | | | | | | | | | The intention is to have PySide2 and Shiboken2 as project names, to allow for co-existence of PySide and PySide2. This is the first version that builds with these settings on OS X: $ python3 setup.py build --debug --no-examples --ignore-git --qmake=/usr/local/Cellar/qt5/5.5.0/bin/qmake --jobs=9 This is not yet tested.