From bc1445ae9b858cba6287661b110615274947d693 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 21 Jul 2017 20:38:12 +0200 Subject: [PATCH] Python/shiboken: All files included by shiboken must have a namespace macro (such as NATRON_NAMESPACE_ENTER) appended with a ';' character, otherwise shiboken fails to generate code. Bug was introduced in https://github.com/MrKepzie/Natron/commit/8b2b55162e35bbbe9acc3685973b07bef540cb3d --- CHANGELOG.md | 4 ++++ Engine/NatronEngine/pathparam_wrapper.cpp | 13 ++++++++++--- Engine/PyAppInstance.h | 8 ++++---- Engine/PyExprUtils.h | 8 ++++---- Engine/PyGlobalFunctions.h | 8 ++++---- Engine/PyNode.h | 4 ++-- Engine/PyNodeGroup.h | 4 ++-- Engine/PyParameter.h | 8 ++++---- Engine/PyRoto.h | 8 ++++---- Engine/PyTracker.h | 8 ++++---- Engine/RectD.h | 4 ++-- Engine/RectI.h | 4 ++-- Engine/typesystem_engine.xml | 18 ++++++++++++------ Gui/NatronGui/natrongui_module_wrapper.cpp | 4 ++-- Gui/PyGlobalGui.h | 8 ++++---- Gui/PyGuiApp.h | 8 ++++---- Gui/PythonPanels.h | 8 ++++---- 17 files changed, 72 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87836883de..284fb8de85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ # History +## Version 2.3.1 + +- Python: Fix the setTable() function of the PathParam class +- Windows: Fix a bug where most image formats would not read and write correctly ## Version 2.3.0 diff --git a/Engine/NatronEngine/pathparam_wrapper.cpp b/Engine/NatronEngine/pathparam_wrapper.cpp index 28aea8c8cc..31c4924424 100644 --- a/Engine/NatronEngine/pathparam_wrapper.cpp +++ b/Engine/NatronEngine/pathparam_wrapper.cpp @@ -152,7 +152,7 @@ static PyObject* Sbk_PathParamFunc_setTable(PyObject* self, PyObject* pyArg) PyObject* subList = PyList_GET_ITEM(pyArg,i); - if (!subList) { + if (!subList || !PyList_Check(subList)) { PyErr_SetString(PyExc_TypeError, "table must be a list of list objects."); return 0; } @@ -161,8 +161,14 @@ static PyObject* Sbk_PathParamFunc_setTable(PyObject* self, PyObject* pyArg) for (int j = 0; j < subSize; ++j) { PyObject* pyString = PyList_GET_ITEM(subList,j); - if ( PyUnicode_Check(pyString) ) { - + if ( PyString_Check(pyString) ) { + char* buf = PyString_AsString(pyString); + if (buf) { + std::string ret; + ret.append(buf); + rowVec[j] = ret; + } + } else if (PyUnicode_Check(pyString) ) { PyObject* utf8pyobj = PyUnicode_AsUTF8String(pyString); // newRef if (utf8pyobj) { char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer @@ -173,6 +179,7 @@ static PyObject* Sbk_PathParamFunc_setTable(PyObject* self, PyObject* pyArg) } } } + table.push_back(rowVec); } cppSelf->setTable(table); diff --git a/Engine/PyAppInstance.h b/Engine/PyAppInstance.h index 11f5a5383f..a74ff1b2ca 100644 --- a/Engine/PyAppInstance.h +++ b/Engine/PyAppInstance.h @@ -44,8 +44,8 @@ CLANG_DIAG_ON(uninitialized) #include "Engine/PyNode.h" #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class AppSettings { @@ -332,7 +332,7 @@ class App boost::shared_ptr getCollectionFromGroup(Group* group) const; }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // Engine_AppInstanceWrapper_h diff --git a/Engine/PyExprUtils.h b/Engine/PyExprUtils.h index ab11db2180..440442afe5 100644 --- a/Engine/PyExprUtils.h +++ b/Engine/PyExprUtils.h @@ -31,8 +31,8 @@ #include "Engine/PyParameter.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class ExprUtils @@ -121,8 +121,8 @@ class ExprUtils static double pnoise(const Double3DTuple& p, const Double3DTuple& period); }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // PYNOISE_H diff --git a/Engine/PyGlobalFunctions.h b/Engine/PyGlobalFunctions.h index 95a7be9b14..769609adc2 100644 --- a/Engine/PyGlobalFunctions.h +++ b/Engine/PyGlobalFunctions.h @@ -38,8 +38,8 @@ #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class PyCoreApplication { @@ -227,8 +227,8 @@ class PyCoreApplication } }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #if defined(PYSIDE_H) && defined(PYSIDE_OLD) namespace PySide { diff --git a/Engine/PyNode.h b/Engine/PyNode.h index 68c56ca6f6..eb96365015 100644 --- a/Engine/PyNode.h +++ b/Engine/PyNode.h @@ -43,8 +43,8 @@ #include "Engine/RectD.h" #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class ImageLayer { diff --git a/Engine/PyNodeGroup.h b/Engine/PyNodeGroup.h index d48912b291..dd5f890789 100644 --- a/Engine/PyNodeGroup.h +++ b/Engine/PyNodeGroup.h @@ -35,8 +35,8 @@ #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class Group { diff --git a/Engine/PyParameter.h b/Engine/PyParameter.h index cf1bc970b2..2455957b9a 100644 --- a/Engine/PyParameter.h +++ b/Engine/PyParameter.h @@ -41,8 +41,8 @@ #include "Engine/KnobFile.h" #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class Param { @@ -1194,7 +1194,7 @@ class ParametricParam void setDefaultCurvesFromCurrentCurves(); }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // Engine_ParameterWrapper_h diff --git a/Engine/PyRoto.h b/Engine/PyRoto.h index 8d7b4e1b78..14e906ab96 100644 --- a/Engine/PyRoto.h +++ b/Engine/PyRoto.h @@ -38,8 +38,8 @@ #include "Engine/PyParameter.h" #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class Layer; // defined below @@ -191,7 +191,7 @@ class Roto boost::shared_ptr _ctx; }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // ROTOWRAPPER_H diff --git a/Engine/PyTracker.h b/Engine/PyTracker.h index d560d18146..e916cc386e 100644 --- a/Engine/PyTracker.h +++ b/Engine/PyTracker.h @@ -37,8 +37,8 @@ #include "Engine/PyParameter.h" #include "Engine/EngineFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class Track { @@ -100,7 +100,7 @@ class Tracker boost::weak_ptr _ctx; }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // Engine_PyTracker_H diff --git a/Engine/RectD.h b/Engine/RectD.h index 5ec27fed54..a5d7d246c3 100644 --- a/Engine/RectD.h +++ b/Engine/RectD.h @@ -44,7 +44,7 @@ GCC_DIAG_OFF(strict-overflow) #endif -NATRON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; class RectD { @@ -344,7 +344,7 @@ operator!=(const RectD & b1, b1.top() != b2.top(); } -NATRON_NAMESPACE_EXIT +NATRON_NAMESPACE_EXIT; Q_DECLARE_METATYPE(NATRON_NAMESPACE::RectD) diff --git a/Engine/RectI.h b/Engine/RectI.h index f49572b252..7f725d3566 100644 --- a/Engine/RectI.h +++ b/Engine/RectI.h @@ -44,7 +44,7 @@ GCC_DIAG_OFF(strict-overflow) #endif -NATRON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; /** * @brief A rectangle where x1 < x2 and y1 < y2 such as width() == (x2 - x1) && height() == (y2 - y1) @@ -469,7 +469,7 @@ operator!=(const RectI & b1, return !(b1 == b2); } -NATRON_NAMESPACE_EXIT +NATRON_NAMESPACE_EXIT; Q_DECLARE_METATYPE(NATRON_NAMESPACE::RectI) diff --git a/Engine/typesystem_engine.xml b/Engine/typesystem_engine.xml index 8201088a43..8d786970fa 100644 --- a/Engine/typesystem_engine.xml +++ b/Engine/typesystem_engine.xml @@ -217,7 +217,6 @@ - @@ -770,10 +769,10 @@ - - - + + + This is an abstract class, it is derived by 2 different classes: @@ -1506,8 +1505,14 @@ for (int j = 0; j < subSize; ++j) { PyObject* pyString = PyList_GET_ITEM(subList,j); - if ( PyString_Check(pyString) || PyUnicode_Check(pyString) ) { - + if ( PyString_Check(pyString) ) { + char* buf = PyString_AsString(pyString); + if (buf) { + std::string ret; + ret.append(buf); + rowVec[j] = ret; + } + } else if (PyUnicode_Check(pyString) ) { PyObject* utf8pyobj = PyUnicode_AsUTF8String(pyString); // newRef if (utf8pyobj) { char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer @@ -1518,6 +1523,7 @@ } } } + table.push_back(rowVec); } %CPPSELF.%FUNCTION_NAME(table); diff --git a/Gui/NatronGui/natrongui_module_wrapper.cpp b/Gui/NatronGui/natrongui_module_wrapper.cpp index e2d1df2407..6823567781 100644 --- a/Gui/NatronGui/natrongui_module_wrapper.cpp +++ b/Gui/NatronGui/natrongui_module_wrapper.cpp @@ -39,8 +39,8 @@ void init_PyGuiApplication(PyObject* module); void init_GuiApp(PyObject* module); void init_PyViewer(PyObject* module); void init_PyTabWidget(PyObject* module); -void init_PyPanel(PyObject* module); void init_PyModalDialog(PyObject* module); +void init_PyPanel(PyObject* module); // Required modules' type and converter arrays. PyTypeObject** SbkPySide_QtGuiTypes; @@ -508,8 +508,8 @@ SBK_MODULE_INIT_FUNCTION_BEGIN(NatronGui) init_GuiApp(module); init_PyViewer(module); init_PyTabWidget(module); - init_PyPanel(module); init_PyModalDialog(module); + init_PyPanel(module); // Register converter for type 'const std::map&'. SbkNatronGuiTypeConverters[SBK_NATRONGUI_STD_MAP_QSTRING_NODECREATIONPROPERTYPTR_IDX] = Shiboken::Conversions::createConverter(&PyDict_Type, _conststd_map_QString_NodeCreationPropertyPTR_REF_CppToPython__conststd_map_QString_NodeCreationPropertyPTR_REF); diff --git a/Gui/PyGlobalGui.h b/Gui/PyGlobalGui.h index bb0c32e7d5..97326c1a80 100644 --- a/Gui/PyGlobalGui.h +++ b/Gui/PyGlobalGui.h @@ -41,8 +41,8 @@ CLANG_DIAG_ON(uninitialized) #include "Gui/GuiApplicationManager.h" #include "Gui/GuiFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class PyGuiApplication : public PyCoreApplication @@ -121,7 +121,7 @@ class PyGuiApplication } }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // GLOBAL_GUI_WRAPPER_H diff --git a/Gui/PyGuiApp.h b/Gui/PyGuiApp.h index 0c8244f342..1b29366202 100644 --- a/Gui/PyGuiApp.h +++ b/Gui/PyGuiApp.h @@ -35,8 +35,8 @@ #include "Gui/GuiAppInstance.h" #include "Gui/GuiFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; class PyViewer { @@ -165,7 +165,7 @@ class GuiApp void renderBlocking(const std::list& effects, const std::list& firstFrames, const std::list& lastFrames, const std::list& frameSteps); }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // GUIAPPWRAPPER_H diff --git a/Gui/PythonPanels.h b/Gui/PythonPanels.h index 7afcbff659..9589f639a3 100644 --- a/Gui/PythonPanels.h +++ b/Gui/PythonPanels.h @@ -45,8 +45,8 @@ CLANG_DIAG_ON(uninitialized) #include "Gui/PanelWidget.h" #include "Gui/GuiFwd.h" -NATRON_NAMESPACE_ENTER -NATRON_PYTHON_NAMESPACE_ENTER +NATRON_NAMESPACE_ENTER; +NATRON_PYTHON_NAMESPACE_ENTER; struct DialogParamHolderPrivate; class DialogParamHolder @@ -215,7 +215,7 @@ class PyTabWidget QString getScriptName() const; }; -NATRON_PYTHON_NAMESPACE_EXIT -NATRON_NAMESPACE_EXIT +NATRON_PYTHON_NAMESPACE_EXIT; +NATRON_NAMESPACE_EXIT; #endif // PYTHONPANELS_H