1
0
mirror of https://github.com/thp/pyotherside.git synced 2025-01-28 23:52:55 +08:00

101 Commits

Author SHA1 Message Date
Igor Malinovskiy
784851668b
Fix compilation on Windows with VS 2017
Remove usage of variable length array to fix compilation on Windows

Fix #93
2019-06-19 11:37:34 +03:00
Thomas Perl
ed279cb9db
Merge pull request #104 from uglide/allow_embedding_in_qt_app
Use python.h wrapping to allow embedding as-is in any Qt-based project
2019-06-06 17:59:33 +02:00
Igor Malinovskiy
4c2bc52fa0 Use python.h wrapping to allow embedding as-is in any Qt-based project 2019-06-05 17:46:35 +03:00
Igor Malinovskiy
b78f53b4e9 Add support for QByteArray
- Add converting from QByteArray to bytes
- Convert bytes to QByteArray instead of trying to parse it as UTF-8 string
2019-06-05 17:16:52 +03:00
Heiko Becker
4687c5bcb8 Include <dlfcn.h> (for RTLD_{GLOBAL,NOW})
Building against musl libc otherwise fails here with
"global_libpython_loader.cpp:44:47: error: 'RTLD_GLOBAL' was not
declared in this scope".
2019-02-07 19:51:04 +01:00
Thomas Perl
d8d0710e32 Update copyright years (2019) 2019-01-27 12:37:15 +01:00
Thomas Perl
dab1576bb1 Allow calling signals from Python (Fixes #98) 2019-01-27 12:31:27 +01:00
Martin Kampas
9f7db20aff Update plugins.qmltypes
Using QML2_IMPORT_PATH instead of command line argument to avoid
recording local path in the plugins.qmlypes file.
2018-08-24 07:25:45 +02:00
Martin Kampas
71caa2f837 Add qmltypes make target 2018-08-24 07:06:14 +02:00
Martin Kampas
80b1107b23 Remove unneeded _PRO_FILE_PWD_ use 2018-08-24 07:06:14 +02:00
Thomas Perl
747f6b2747 Initialize sys.argv (Fixes #77) 2017-10-30 13:01:51 +01:00
Thomas Perl
d1e329048a Do not decref PySys_GetObject return values (Fixes #84)
The function PySys_GetObject() returns a borrowed reference
only, so we must incref/decref the value accordingly, and
not take ownership of the returned value.

https://docs.python.org/3/c-api/sys.html#c.PySys_GetObject
2017-10-14 12:31:49 +02:00
Thomas Perl
57f484fdd6 Support 64-bit integers when converting from Python (Fixes #86) 2017-10-14 12:08:52 +02:00
Robie Basak
260c9c275c Fix call_sync when used with parameters
Factor out the unboxing in call() to a separate method.

To handle direct calls to call_sync(), rename the implementation of
call_sync() to call_internal() and add a call_sync() stub that calls
call_internal().

call_internal() can now takes a boolean "unbox" parameter without
impacting the formal interfaces that call() and call_sync() provide to
QML users. If the "unbox" parameter is true, it unboxes the arguments
first. If false, it doesn't.

Now call_sync() can call call_internal() requesting unboxing. call() can
also do the unboxing itself, and then later process() (the slot for
switching call() to a different thread) can call call_internal()
requesting no unboxing.

Since we now have and must keep track of two versions of the parameters
(boxed vs. unboxed), I also rename these parameters to keep things
explicit and clear.

Here's what was going wrong before:

call() was unboxing QJSValue elements inside the argument list into
plain QVariants, and then calling (indirectly, to switch threads)
call_sync().

call_sync() did no such unboxing. Since call_sync() is exposed directly
as an entry point, this meant that priv->call(), which appears to expect
unboxed argument lists, was failing in this case.

There is a comment noting that call() should do the unboxing in the GUI
thread so should not defer it. So the unboxing has to happen in two
different places depending on whether the user called call() or
call_sync().

Fixes: #49
2017-01-04 22:59:43 +00:00
Alex Toldaiev
8ad6d92bba importNames, import specific objects from a module to Python's global space
The importNames and importNames_sync adopt the protocol of importModule.

The importNames(module_name, [objects_names], callback) is asynchronous.
It calls the synchronous importNames_sync(module_name, [object_names]) via the signal import_names.

importNames_sync imports the module (with PyImport_ImportModule(moduleName)) and loops over the given names
trying to get the corresponding object from the module (by PyObject_GetAttrString).
On success the object is inserted into the global space of the Python interpreter.
(priv->globals.borrow() is the pointer to the corresponding Python dict.)
Each failed import separately emits the error message and continues to the next iteration.

 Changes to be committed:
	modified:   src/qpython.cpp
	modified:   src/qpython.h
	modified:   src/qpython_worker.cpp
	modified:   src/qpython_worker.h
2016-01-06 22:18:44 +00:00
Thomas Perl
dfa2cd0ab0 Add qmltypes generated via qmlplugindump (Fixes #57) 2016-01-03 11:34:08 +01:00
Igor Malinovskiy
74aac9e7e1 Add support for QVariantHash
Convert QVariantHash to python dict just like QVariantMap
2015-12-15 20:27:43 +02:00
Martin Kolman
5ed00137d9 Handle sourceSize not being set
If sourceSize is not set at all, use defaultSize() as returned
by the QSvgRenderer instance.
If only width or height is set, get the other value from defaultSize()
and scale it according to the set one to keep aspect ratio of the image.
2015-10-28 01:57:55 +01:00
Martin Kolman
57a6699727 Add support for rendering SVG data to the image provider
The image provider can already render SVG images supplied
as format_data due to using QImage as backend.
This unfortunately only works correctly as long as the SVG image is
not scaled, as the image provider ignores the requested_size parameter
for format_data, causing the SVG image to be first rendered at its default size
and then scaled at the bitmap level, resulting in a very blurry image.

As there does not appear to be any easy fix for this when working with
the format_data type add a new data type called format_svg_data that
properly renders the SVG image at requested size with QtSvgRenderer.

Also the documentation has been updated to include format_svg_data
and an example has been added.
2015-10-28 01:51:08 +01:00
Thomas Perl
6d7f526c23 Call PyDateTime_IMPORT as often as necessary (Fixes #46)
In some cases (e.g. release builds, see issue #46) it could be
that pyobject_converter.h is included in more than one compile
unit, which also creates two instances of the PyDateTimeAPI
static variable, defined in Python's datetime.h. For this reason,
we must not keep track of the initialization state manually, but
instead just initialize PyDateTimeAPI whenever it is NULL.
2015-06-13 22:46:22 +02:00
Thomas Perl
2378495fa9 Resolve full library path on Android 2015-03-05 20:40:48 +01:00
Thomas Perl
d931071fbd Prepend the PyOtherSide .so to the PYTHONPATH 2015-03-05 19:30:45 +01:00
Thomas Perl
ed58d65d6a QPython15 object 2015-02-21 20:45:53 +01:00
Thomas Perl
30c0247a80 pythonVersion: Return run-time Python version (Fixes #14) 2015-02-21 20:42:15 +01:00
Thomas Perl
84bc298b75 Fix documentation and OpenGL rendering support 2015-02-21 19:55:08 +01:00
Dennis Tomas
37ba99e0bf Fixed GIL API usage in renderer. 2015-02-21 13:17:07 +01:00
Dennis Tomas
72925419c2 Implemented PyObjectRef::operator==. 2015-02-21 13:16:03 +01:00
Dennis Tomas
77ecb76492 Unified renderer interface for PyFBO and PyGLArea. 2015-02-21 13:15:49 +01:00
Dennis Tomas
092370631a Use proper way of synchronizing PyFbo and PyFboRenderer. 2015-02-21 13:15:32 +01:00
Dennis Tomas
1ec78f422e Don't clean up an uninitialized renderer. 2015-02-21 13:15:19 +01:00
Dennis Tomas
2662c423b4 Clean up PyGLRenderers before replacing them. 2015-02-21 13:15:05 +01:00
Dennis Tomas
00abfc8570 No need for PyGLRenderer to subclass QObject. 2015-02-21 13:14:44 +01:00
Dennis Tomas
b1cd1781d3 Use static_cast. 2015-02-21 13:14:16 +01:00
Dennis Tomas
6209cec9f2 OpenGL rendering to FBO. 2015-02-21 13:14:00 +01:00
Dennis Tomas
0ab3edabc5 Only disable automatic clearing when rendering before QML. 2015-02-21 13:13:39 +01:00
Dennis Tomas
177c5203dc Removed property PyGLArea.t (leftover from Qt tutorial). 2015-02-21 13:13:24 +01:00
Dennis Tomas
eef5266555 Update PyGLArea when properties have changed. 2015-02-21 13:12:57 +01:00
Dennis Tomas
f08ab6be25 PyGLArea: Pass renderer object instead of function names. 2015-02-21 13:12:41 +01:00
Dennis Tomas
52e75e918f Added null-checks for callbacks. 2015-02-21 13:12:07 +01:00
Dennis Tomas
3e4ea6ee5f Recreate renderer when callbacks have been redefined. 2015-02-21 13:11:48 +01:00
Dennis Tomas
13d22c6e0f Print exceptions in renderer methods. 2015-02-21 13:11:19 +01:00
Dennis Tomas
e126e229e8 Removed some unused private members. 2015-02-21 13:10:59 +01:00
Dennis Tomas
f8de71d449 OpenGL rendering in python. 2015-02-21 13:10:38 +01:00
Daniel Vrátil
1c0be92e41 Unbox QJSValue from QVariant in the GUI thread to prevent race condition in QML engine
Calling QJSValue::toVariant() can cause QJSValue to call into QML engine. Since
we perform this correction from QPythonWriter thread context, we end up calling
QML engine from non-GUI thread and causing race conditions and crashes.

This change performs the initial unboxing in QPython::call() and passes to
QPythonWriter the actual value of QJSValue in QVariant.

This fixes issue #36.
2015-02-16 11:19:45 +01:00
Thomas Perl
5c31bde3da Don't register signal handlers (fixes #33) 2015-01-11 13:37:22 +01:00
GreenAddress
a113f51db4 Fixed compile errors after last Qt 5.4 patch 2014-11-11 11:32:21 +01:00
Thomas Perl
dc94842773 QVariantConverter: Handle Qt 5.4 QJSValue-in-QVariant (Fixes #28) 2014-11-10 21:20:43 +01:00
Thomas Perl
8e0f99002d pythonlib_loader: Standard Library embedding 2014-11-07 23:02:01 +01:00
Thomas Perl
443dce1e54 Android compatibility fix
There's no need to load libpython globally on Android.
2014-11-07 23:01:31 +01:00
Thomas Perl
21b416a01e Print unhandled errors to the console 2014-10-12 11:24:54 +02:00