* Even if we don't have pyside2 to treat qwidgets as full objects and
access their methods and data, we still need to be able to pass around
the QWidget* as an opaque pointer to be able to use the API properly.
* This change falls back to just using SWIG's default opaque pointer
wrapping and unwrapping when pyside2 isn't available.
* The error handling code will be OK if a NULL parameter was passed in
but during cleanup it will go through tempdealloc, so we need to check
that the pointer is actually valid.
* This really isn't ideal as it means the python module will only work
with that specific major.minor version of python, when it could in
theory work with any python version above 3.2 or so, depending on what
features are used.
* Since we're not distributing these modules yet though, add this
linking to support -Wl,--no-undefined.
* Added a couple of utility macros to help with the conversion. lit() is
paired with tr() for untranslated text.
* QFormatStr is more explicitly for non-textual formatting strings.
* Both are just #define'd to QStringLiteral()
* This is only relevant for static qrenderdoc builds where the python
used isn't the system python, so it needs to locate its libs.
Otherwise the system libpython3.so and libs will be used.
* If it's called every write then it risks spamming the system with
signals and locking the UI thread with constant writes. Checking and
flushing output every 100ms is sufficient.
* In python globals aren't really global, they're just module-level
variables. So to find our _renderdoc_internal we have to potentailly
walk the stack if we're inside another module until we get to the
globals dict we set up.
* Generally this means removing ref out parameters and instead returning
values. In a couple of cases we will want to avoid copies in future
either by returning const references (e.g. to the pipeline state which
is immutable).
* At the same time, some pointless bool return values that were always
true and didn't indicate errors have been removed. They can be added
again if an error condition comes back.
* Some free functions still have out parameters as C linkage doesn't
allow returning user types by value.
* The C# UI still invokes into C wrappers for all the C++ classes, which
handle taking the return value and doing a copy into an out parameter
still for compatibility.
* This means that if we BlockInvoke a python callback, we don't end up
in a deadlock where we're holding the GIL during script execution but
also waiting on the renderer running (which is trying to acquire the
GIL before calling the callback).
* We need to keep a PythonContext (and its globals Dict) around while
we still have some pending callbacks happening. So now the external
code creates a PythonContext and then releases it when it's done, but
the context will hang around until the global redirector object is
destructed, which is responsible for deleting the context.
* The global redirector is deleted when a refcounting cycle is detected
and the dict is unreachable, which only happens after the context is
released.
* Any time a callback is passed to something and converted to a
std::function we add a reference on the global redirector to keep it
alive. When the callback has finished executing we remove the ref.
* This way, any pending callbacks that have been called but not finished
or converted (queued) and not called yet asynchronously will keep the
context object alive to be able to output, handle exceptions, etc.
* Additionally we need to detect when we're being called asynchronously
and handle exceptions separately instead of trying to propagate up the
call chain, because there might not be any more python code up the
chain (e.g. the render manager calling a python callback).