Skip to content

Commit

Permalink
Merge branch 'NatronGitHub:RB-2.6' into AJC-RB-2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
acolwell committed Jul 23, 2024
2 parents f28f2ef + 7683518 commit 36d2fa3
Show file tree
Hide file tree
Showing 49 changed files with 1,073 additions and 791 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
cmake_minimum_required(VERSION 3.16.7)

project(Natron
VERSION "2.5.0"
VERSION "2.6.0"
DESCRIPTION "Open Source Compositing Software"
HOMEPAGE_URL "https://natrongithub.github.io/"
LANGUAGES CXX C
)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

option(NATRON_SYSTEM_LIBS "use system versions of dependencies instead of bundled ones" OFF)
option(NATRON_BUILD_TESTS "build the Natron test suite" ON)
Expand Down
37 changes: 0 additions & 37 deletions Engine/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,9 @@ AppManager::loadFromArgs(const CLArgs& cl)
{

#ifdef DEBUG
#if PY_MAJOR_VERSION >= 3
for (std::size_t i = 0; i < _imp->commandLineArgsWide.size(); ++i) {
std::cout << "argv[" << i << "] = " << StrUtils::utf16_to_utf8( std::wstring(_imp->commandLineArgsWide[i]) ) << std::endl;
}
#else
for (std::size_t i = 0; i < _imp->commandLineArgsUtf8.size(); ++i) {
std::cout << "argv[" << i << "] = " << _imp->commandLineArgsUtf8[i] << std::endl;
}
#endif
#endif

// This needs to be done BEFORE creating qApp because
Expand Down Expand Up @@ -1765,11 +1759,7 @@ addToPythonPathFunctor(const QDir& directory)
std::string addToPythonPath("sys.path.append(str('");

addToPythonPath += directory.absolutePath().toStdString();
#if PY_MAJOR_VERSION >= 3
addToPythonPath += "'))\n";
#else
addToPythonPath += "').decode('utf-8'))\n";
#endif

std::string err;
bool ok = NATRON_PYTHON_NAMESPACE::interpretPythonScript(addToPythonPath, &err, 0);
Expand Down Expand Up @@ -2957,11 +2947,7 @@ AppManager::initPython()
///Must be called prior to Py_Initialize (calls PyImport_AppendInittab())
initBuiltinPythonModules();

#if PY_MAJOR_VERSION >= 3
_imp->mainModule = NATRON_PYTHON_NAMESPACE::initializePython3(_imp->commandLineArgsWide);
#else
_imp->mainModule = NATRON_PYTHON_NAMESPACE::initializePython2(_imp->commandLineArgsUtf8);
#endif

std::string err;
std::string modulename = NATRON_ENGINE_PYTHON_MODULE_NAME;
Expand Down Expand Up @@ -3053,23 +3039,13 @@ AppManager::getMainModule()
///The symbol has been generated by Shiboken in Engine/NatronEngine/natronengine_module_wrapper.cpp
extern "C"
{
#if PY_MAJOR_VERSION >= 3
// Python 3
PyObject* PyInit_NatronEngine();
#else
void initNatronEngine();
#endif
}

void
AppManager::initBuiltinPythonModules()
{
#if PY_MAJOR_VERSION >= 3
// Python 3
int ret = PyImport_AppendInittab(NATRON_ENGINE_PYTHON_MODULE_NAME, &PyInit_NatronEngine);
#else
int ret = PyImport_AppendInittab(NATRON_ENGINE_PYTHON_MODULE_NAME, &initNatronEngine);
#endif
if (ret == -1) {
throw std::runtime_error("Failed to initialize built-in Python module.");
}
Expand Down Expand Up @@ -3121,12 +3097,7 @@ AppManager::launchPythonInterpreter()
assert(PyGILState_Check()); // Not available prior to Python 3.4
#endif

#if PY_MAJOR_VERSION >= 3
// Python 3
Py_Main(1, &_imp->commandLineArgsWide[0]);
#else
Py_Main(1, &_imp->commandLineArgsUtf8[0]);
#endif
}

int
Expand Down Expand Up @@ -3640,11 +3611,7 @@ NATRON_PYTHON_NAMESPACE::interpretPythonScript(const std::string& script,
Py_DECREF(pyStr);

// See if we can get a full traceback
#if PY_MAJOR_VERSION >= 3
PyObject* module_name = PyUnicode_FromString("traceback");
#else
PyObject* module_name = PyString_FromString("traceback");
#endif
PyObject* pyth_module = PyImport_Import(module_name);
Py_DECREF(module_name);

Expand All @@ -3659,11 +3626,7 @@ NATRON_PYTHON_NAMESPACE::interpretPythonScript(const std::string& script,
if (pyth_func && PyCallable_Check(pyth_func)) {
PyObject *pyth_val = PyObject_CallFunctionObjArgs(pyth_func, pyExcType, pyExcValue, pyExcTraceback, NULL);
if (pyth_val) {
#if PY_MAJOR_VERSION >= 3
PyObject *emptyString = PyUnicode_FromString("");
#else
PyObject *emptyString = PyString_FromString("");
#endif
PyObject *strList = PyObject_CallMethod(emptyString, (char*)"join", (char*)"(O)", pyth_val);
Py_DECREF(emptyString);
Py_DECREF(pyth_val);
Expand Down
25 changes: 0 additions & 25 deletions Engine/AppManagerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,11 @@ GCC_DIAG_ON(unused-parameter)
BOOST_CLASS_EXPORT(NATRON_NAMESPACE::FrameParams)
BOOST_CLASS_EXPORT(NATRON_NAMESPACE::ImageParams)

#if PY_MAJOR_VERSION >= 3
// Python 3

//Borrowed from https://github.com/python/cpython/blob/634cb7aa2936a09e84c5787d311291f0e042dba3/Python/fileutils.c
//Somehow Python 3 dev forced every C application embedding python to have their own code to convert char** to wchar_t**
static wchar_t*
char2wchar(const char* arg)
{
#if PY_MAJOR_VERSION > 3 || PY_MAJOR_MINOR >= 7
// https://docs.python.org/3/c-api/sys.html#c.Py_DecodeLocale
return Py_DecodeLocale(arg, NULL);
#else // PY_VERSION < 3.7
wchar_t *res = NULL;

#ifdef HAVE_BROKEN_MBSTOWCS
Expand Down Expand Up @@ -203,7 +196,6 @@ char2wchar(const char* arg)
}
*out = 0;
#endif // ifdef HAVE_MBRTOWC
#endif // PY_VERSION < 3.7

return res;
oom:
Expand All @@ -213,9 +205,6 @@ char2wchar(const char* arg)
return NULL;
} // char2wchar

#endif // if PY_MAJOR_VERSION >= 3


NATRON_NAMESPACE_ENTER
AppManagerPrivate::AppManagerPrivate()
: globalTLS()
Expand Down Expand Up @@ -252,10 +241,8 @@ AppManagerPrivate::AppManagerPrivate()
, nThreadsMutex()
, runningThreadsCount()
, lastProjectLoadedCreatedDuringRC2Or3(false)
#if PY_MAJOR_VERSION >= 3
, commandLineArgsWideOriginal()
, commandLineArgsWide()
#endif
, commandLineArgsUtf8Original()
, commandLineArgsUtf8()
, nArgs(0)
Expand Down Expand Up @@ -294,12 +281,9 @@ AppManagerPrivate::~AppManagerPrivate()
for (std::size_t i = 0; i < commandLineArgsUtf8Original.size(); ++i) {
free(commandLineArgsUtf8Original[i]);
}
#if PY_MAJOR_VERSION >= 3
// Python 3
for (std::size_t i = 0; i < commandLineArgsWideOriginal.size(); ++i) {
free(commandLineArgsWideOriginal[i]);
}
#endif
}

#ifdef NATRON_USE_BREAKPAD
Expand Down Expand Up @@ -1177,26 +1161,17 @@ void
AppManagerPrivate::copyUtf8ArgsToMembers(const std::vector<std::string>& utf8Args)
{
// Copy command line args to local members that live throughout the lifetime of AppManager
#if PY_MAJOR_VERSION >= 3
// Python 3
commandLineArgsWideOriginal.resize(utf8Args.size());
#endif
commandLineArgsUtf8Original.resize(utf8Args.size());
nArgs = (int)utf8Args.size();
for (std::size_t i = 0; i < utf8Args.size(); ++i) {
commandLineArgsUtf8Original[i] = strdup(utf8Args[i].c_str());

// Python 3 needs wchar_t arguments
#if PY_MAJOR_VERSION >= 3
// Python 3
commandLineArgsWideOriginal[i] = char2wchar(utf8Args[i].c_str());
#endif
}
commandLineArgsUtf8 = commandLineArgsUtf8Original;
#if PY_MAJOR_VERSION >= 3
// Python 3
commandLineArgsWide = commandLineArgsWideOriginal;
#endif
}

void
Expand Down
2 changes: 1 addition & 1 deletion Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set(PYENGINE_HEADER PySide2_Engine_Python.h)
set(POST_SHIBOKEN ../tools/utils/runPostShiboken2.sh)

set(shiboken_args
"--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
"-std=c++17" "--enable-parent-ctor-heuristic" "--use-isnull-as-nb_nonzero"
"--avoid-protected-hack" "--enable-pyside-extensions"
"-I." "-I.." "-I../Global" "-I../libs/OpenFX/include" ${PYENGINE_INCS}
"-T${PYSIDE_TYPESYSTEMS}" "--output-directory=${PYENGINE_OUT}"
Expand Down
2 changes: 1 addition & 1 deletion Engine/Knob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2710,7 +2710,7 @@ KnobHelper::validateExpression(const std::string& expression,
if ( PyFloat_Check(ret) ) {
index = std::floor( (double)PyFloat_AsDouble(ret) + 0.5 );
} else if ( PyLong_Check(ret) ) {
index = (int)PyInt_AsLong(ret);
index = (int)PyLong_AsLong(ret);
} else if (PyObject_IsTrue(ret) == 1) {
index = 1;
}
Expand Down
18 changes: 2 additions & 16 deletions Engine/KnobImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QThread>

// clang-format off
CLANG_DIAG_OFF(mismatched-tags)
GCC_DIAG_OFF(unused-parameter)
#include <shiboken.h>
CLANG_DIAG_ON(mismatched-tags)
GCC_DIAG_ON(unused-parameter)
// clang-format on

#include "Global/PythonUtils.h"

#include "Engine/Curve.h"
Expand Down Expand Up @@ -346,9 +338,7 @@ template <>
int
KnobHelper::pyObjectToType(PyObject* o)
{
if (PyInt_Check(o)) {
return (int)PyInt_AsLong(o);
} else if (PyLong_Check(o)) {
if (PyLong_Check(o)) {
return (int)PyLong_AsLong(o);
} else if (PyFloat_Check(o)) {
return (int)PyFloat_AsDouble(o);
Expand All @@ -371,9 +361,7 @@ template <>
double
KnobHelper::pyObjectToType(PyObject* o)
{
if (PyInt_Check(o)) {
return (double)PyInt_AsLong(o);
} else if (PyLong_Check(o)) {
if (PyLong_Check(o)) {
return (double)PyLong_AsLong(o);
} else if (PyFloat_Check(o)) {
return PyFloat_AsDouble(o);
Expand Down Expand Up @@ -462,8 +450,6 @@ Knob<T>::evaluateExpression_pod(double time,

if ( PyFloat_Check(ret) ) {
*value = PyFloat_AsDouble(ret);
} else if ( PyInt_Check(ret) ) {
*value = (double)PyInt_AsLong(ret);
} else if ( PyLong_Check(ret) ) {
*value = (double)PyLong_AsLong(ret);
} else if (PyObject_IsTrue(ret) == 1) {
Expand Down
32 changes: 29 additions & 3 deletions Engine/RotoPaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,6 +2727,22 @@ RotoPaint::onOverlayPenMotion(double time,
cursorSet = true;
}

switch (_imp->ui->selectedTool) {
case eRotoToolSolidBrush:
case eRotoToolEraserBrush:
case eRotoToolClone:
case eRotoToolReveal:
case eRotoToolBlur:
case eRotoToolSharpen:
case eRotoToolSmear:
case eRotoToolDodge:
case eRotoToolBurn: {
redraw = true; // Those tools use the overlay to draw the tool
}
default:
break;
} // switch

if ( !cursorSet && _imp->ui->showCpsBbox && (_imp->ui->state != eEventStateDraggingControlPoint) && (_imp->ui->state != eEventStateDraggingSelectedControlPoints)
&& ( _imp->ui->state != eEventStateDraggingLeftTangent) &&
( _imp->ui->state != eEventStateDraggingRightTangent) ) {
Expand All @@ -2751,8 +2767,10 @@ RotoPaint::onOverlayPenMotion(double time,
} else if (lastHoverState != eHoverStateNothing) {
newState = eHoverStateNothing;
}
redraw = _imp->ui->hoverState != newState;
_imp->ui->hoverState = newState;
if (_imp->ui->hoverState != newState) {
redraw = true;
_imp->ui->hoverState = newState;
}
}
const bool featherVisible = _imp->ui->isFeatherVisible();

Expand Down Expand Up @@ -3161,7 +3179,15 @@ RotoPaint::onOverlayPenUp(double /*time*/,
**/
setCurrentCursor(eCursorBusy);
context->evaluateNeatStrokeRender();
setCurrentCursor(eCursorDefault);
if ( context->isRotoPaint() &&
( ( _imp->ui->selectedRole == eRotoRoleMergeBrush) ||
( _imp->ui->selectedRole == eRotoRoleCloneBrush) ||
( _imp->ui->selectedRole == eRotoRolePaintBrush) ||
( _imp->ui->selectedRole == eRotoRoleEffectBrush) ) ) {
setCurrentCursor(eCursorCross);
} else {
setCurrentCursor(eCursorDefault);
}
_imp->ui->strokeBeingPaint->setStrokeFinished();
ret = true;
}
Expand Down
4 changes: 2 additions & 2 deletions Global/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#endif

#ifdef __cplusplus
#if __cplusplus < 201402L
#error "Natron 2.5+ requires C++14"
#if __cplusplus < 201703L
#error "Natron 2.6+ requires C++17"
#endif
// Establish the name space.
namespace Natron { }
Expand Down
Loading

0 comments on commit 36d2fa3

Please sign in to comment.