diff options
author | Christian Tismer <tismer@stackless.com> | 2019-08-06 12:52:33 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2019-08-06 18:53:13 +0200 |
commit | 21d948aa47dfe62b58286a31c729e76c9e3c13db (patch) | |
tree | 3edbc8b04de200ca2aea5656ff8d2f8d7212a601 /sources/shiboken2/libshiboken | |
parent | 5838387e31987286ae836135ecd06326f0c7e1ba (diff) |
PySide: Create a framework for deprecated functions
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>
Diffstat (limited to 'sources/shiboken2/libshiboken')
-rw-r--r-- | sources/shiboken2/libshiboken/signature.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index e62f861a2..7eaf35e1c 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -77,6 +77,7 @@ typedef struct safe_globals_struc { PyObject *create_signature_func; PyObject *seterror_argument_func; PyObject *make_helptext_func; + PyObject *finish_import_func; } safe_globals_struc, *safe_globals; static safe_globals pyside_globals = nullptr; @@ -543,6 +544,9 @@ init_phase_1(void) if (p->value_dict == nullptr) goto error; + // This function will be disabled until phase 2 is done. + p->finish_import_func = nullptr; + return p; } error: @@ -585,6 +589,10 @@ init_phase_2(safe_globals_struc *p, PyMethodDef *methods) p->make_helptext_func = PyObject_GetAttrString(loader, "make_helptext"); if (p->make_helptext_func == nullptr) goto error; + p->finish_import_func = PyObject_GetAttrString(loader, "finish_import"); + if (p->finish_import_func == nullptr) + goto error; + return 0; return 0; } error: @@ -1014,7 +1022,16 @@ PySide_FinishSignatures(PyObject *module, const char *signatures[]) return -1; if (_finish_nested_classes(obdict) < 0) return -1; - return 0; + // The finish_import function will not work the first time since phase 2 + // was not yet run. But that is ok, because the first import is always for + // the shiboken module (or a test module). + if (pyside_globals->finish_import_func == nullptr) { + assert(strncmp(name, "PySide2.", 8) != 0); + return 0; + } + Shiboken::AutoDecRef ret(PyObject_CallFunction( + pyside_globals->finish_import_func, const_cast<char *>("(O)"), module)); + return ret.isNull() ? -1 : 0; } static int |