Skip to content

Commit ce9b355

Browse files
committed
Merge RB-2.0 and fix conflicts
2 parents 38e6c6d + 114b32e commit ce9b355

File tree

161 files changed

+10094
-3617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+10094
-3617
lines changed

CONTRIBUTORS.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Version 2.0:
66
Frédéric Devernay <devernay@github>
77
Alexandre Gauthier-Foichat <MrKepzie@github>
88
Ole-André Rodlie <olear@github> (Openfx-Arena Plug-Ins)
9-
Axel Airo-Farulla <AxelAF@github>
9+
Axel Airo-Farulla <Eaknyt@github>
1010

1111
#Artists:
1212

Documentation/source/PythonReference/NatronEngine/App.rst

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ See :ref:`detailed<app.details>` description...
1616

1717
Functions
1818
^^^^^^^^^
19-
19+
* def :meth:`addProjectLayer<NatronEngine.App.addProjectLayer>` (layer)
2020
* def :meth:`addFormat<NatronEngine.App.addFormat>` (formatSpec)
2121
* def :meth:`createNode<NatronEngine.App.createNode>` (pluginID[, majorVersion=-1[, group=None]])
2222
* def :meth:`createReader<NatronEngine.App.createReader>` (filename[, group=None])
@@ -132,6 +132,16 @@ You can get a specific :doc:`parameter<Param>` of the project settings with the
132132
Member functions description
133133
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
134134

135+
.. method:: NatronEngine.App.addProjectLayer(layer)
136+
137+
:param layer: :class:`ImageLayer<NatronEngine.ImageLayer>`
138+
139+
Appends a new project-wide layer. It will be available to all layer menus of all nodes.
140+
Each layer menu must be refreshed individually with either a right click on the menu or
141+
by changing nodes connections to get access to the new layer. Layer names are unique:
142+
even if you add duplicates to the layers list, only the first one in the list with that name
143+
will be available in the menus.
144+
135145
.. method:: NatronEngine.App.addFormat(formatSpec)
136146

137147
:param formatSpec: :class:`str<NatronEngine.std::string>`

Engine/AppInstance.cpp

+62-3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ struct AppInstancePrivate
124124
mutable QMutex renderQueueMutex;
125125
std::list<RenderQueueItem> renderQueue, activeRenders;
126126

127+
mutable QMutex invalidExprKnobsMutex;
128+
std::list<KnobWPtr> invalidExprKnobs;
129+
127130
AppInstancePrivate(int appID,
128131
AppInstance* app)
129132
: _publicInterface(app)
@@ -136,6 +139,9 @@ struct AppInstancePrivate
136139
, _creatingTree(0)
137140
, renderQueueMutex()
138141
, renderQueue()
142+
, activeRenders()
143+
, invalidExprKnobsMutex()
144+
, invalidExprKnobs()
139145
{
140146
}
141147

@@ -739,7 +745,7 @@ AppInstance::loadPythonScript(const QFileInfo& file)
739745
if (errCatcher) {
740746
errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref
741747
assert(errorObj);
742-
error = NATRON_PYTHON_NAMESPACE::PY3String_asString(errorObj);
748+
error = NATRON_PYTHON_NAMESPACE::PyString_asString(errorObj);
743749
PyObject* unicode = PyUnicode_FromString("");
744750
PyObject_SetAttrString(errCatcher, "value", unicode);
745751
Py_DECREF(errorObj);
@@ -842,7 +848,11 @@ AppInstance::createNodeFromPythonModule(Plugin* plugin,
842848
if (!moduleName.isEmpty()) {
843849
setGroupLabelIDAndVersion(node,modulePath, moduleName);
844850
}
845-
851+
852+
// If there's a serialization, restore the serialization of the group node because the Python script probably overriden any state
853+
if (serialization) {
854+
containerNode->loadKnobs(*serialization);
855+
}
846856

847857
} //FlagSetter fs(true,&_imp->_creatingGroup,&_imp->creatingGroupMutex);
848858

@@ -890,7 +900,7 @@ AppInstance::createReader(const std::string& filename, CreateNodeReason reason,
890900
#else
891901

892902
std::map<std::string,std::string> readersForFormat;
893-
appPTR->getCurrentSettings()->getFileFormatsForWritingAndWriter(&readersForFormat);
903+
appPTR->getCurrentSettings()->getFileFormatsForReadingAndReader(&readersForFormat);
894904
QString fileCpy = QString::fromUtf8(filename.c_str());
895905
std::string ext = QtCompat::removeFileExtension(fileCpy).toLower().toStdString();
896906
std::map<std::string,std::string>::iterator found = readersForFormat.find(ext);
@@ -1905,6 +1915,55 @@ AppInstance::newProject()
19051915
return app;
19061916
}
19071917

1918+
void
1919+
AppInstance::addInvalidExpressionKnob(const KnobPtr& knob)
1920+
{
1921+
QMutexLocker k(&_imp->invalidExprKnobsMutex);
1922+
for (std::list<KnobWPtr>::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) {
1923+
if (it->lock().get()) {
1924+
return;
1925+
}
1926+
}
1927+
_imp->invalidExprKnobs.push_back(knob);
1928+
}
1929+
1930+
void
1931+
AppInstance::removeInvalidExpressionKnob(const KnobI* knob)
1932+
{
1933+
QMutexLocker k(&_imp->invalidExprKnobsMutex);
1934+
for (std::list<KnobWPtr>::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) {
1935+
if (it->lock().get() == knob) {
1936+
_imp->invalidExprKnobs.erase(it);
1937+
break;
1938+
}
1939+
}
1940+
}
1941+
1942+
void
1943+
AppInstance::recheckInvalidExpressions()
1944+
{
1945+
std::list<KnobPtr> knobs;
1946+
{
1947+
QMutexLocker k(&_imp->invalidExprKnobsMutex);
1948+
for (std::list<KnobWPtr>::iterator it = _imp->invalidExprKnobs.begin(); it!=_imp->invalidExprKnobs.end(); ++it) {
1949+
KnobPtr k = it->lock();
1950+
if (k) {
1951+
knobs.push_back(k);
1952+
}
1953+
}
1954+
}
1955+
std::list<KnobWPtr> newInvalidKnobs;
1956+
for (std::list<KnobPtr>::iterator it = knobs.begin(); it!=knobs.end(); ++it) {
1957+
if (!(*it)->checkInvalidExpressions()) {
1958+
newInvalidKnobs.push_back(*it);
1959+
}
1960+
}
1961+
{
1962+
QMutexLocker k(&_imp->invalidExprKnobsMutex);
1963+
_imp->invalidExprKnobs = newInvalidKnobs;
1964+
}
1965+
}
1966+
19081967
NATRON_NAMESPACE_EXIT;
19091968

19101969
NATRON_NAMESPACE_USING;

Engine/AppInstance.h

+6
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ class AppInstance
336336

337337
public:
338338

339+
void addInvalidExpressionKnob(const KnobPtr& knob);
340+
void removeInvalidExpressionKnob(const KnobI* knob);
341+
void recheckInvalidExpressions();
342+
339343
virtual void clearViewersLastRenderedTexture() {}
340344

341345
virtual void toggleAutoHideGraphInputs() {}
@@ -439,6 +443,8 @@ class AppInstance
439443

440444
void removeRenderFromQueue(OutputEffectInstance* writer);
441445

446+
virtual void reloadScriptEditorFonts() {}
447+
442448
public Q_SLOTS:
443449

444450
void quit();

Engine/AppManager.cpp

+42-19
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ static bool findAndRunScriptFile(const QString& path,const QStringList& files,co
11701170
if (errCatcher) {
11711171
errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref
11721172
assert(errorObj);
1173-
error = NATRON_PYTHON_NAMESPACE::PY3String_asString(errorObj);
1173+
error = NATRON_PYTHON_NAMESPACE::PyString_asString(errorObj);
11741174
PyObject* unicode = PyUnicode_FromString("");
11751175
PyObject_SetAttrString(errCatcher, "value", unicode);
11761176
Py_DECREF(errorObj);
@@ -2460,15 +2460,28 @@ char2wchar(char* arg)
24602460

24612461

24622462
std::string
2463-
NATRON_PYTHON_NAMESPACE::PY3String_asString(PyObject* obj)
2463+
NATRON_PYTHON_NAMESPACE::PyString_asString(PyObject* obj)
24642464
{
2465+
24652466
std::string ret;
2466-
if (PyUnicode_Check(obj)) {
2467-
PyObject * temp_bytes = PyUnicode_AsEncodedString(obj, "ASCII", "strict"); // Owned reference
2468-
if (temp_bytes != NULL) {
2469-
char* cstr = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
2467+
2468+
if (PyString_Check(obj)) {
2469+
char* buf = PyString_AsString(obj);
2470+
if (buf) {
2471+
ret += std::string(buf);
2472+
}
2473+
} else if (PyUnicode_Check(obj)) {
2474+
/*PyObject * temp_bytes = PyUnicode_AsEncodedString(obj, "ASCII", "strict"); // Owned reference
2475+
if (temp_bytes != NULL) {
2476+
char* cstr = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
2477+
ret.append(cstr);
2478+
Py_DECREF(temp_bytes);
2479+
}*/
2480+
PyObject* utf8pyobj = PyUnicode_AsUTF8String(obj); // newRef
2481+
if (utf8pyobj) {
2482+
char* cstr = PyBytes_AS_STRING(utf8pyobj); // Borrowed pointer
24702483
ret.append(cstr);
2471-
Py_DECREF(temp_bytes);
2484+
Py_DECREF(utf8pyobj);
24722485
}
24732486
} else if (PyBytes_Check(obj)) {
24742487
char* cstr = PyBytes_AS_STRING(obj); // Borrowed pointer
@@ -3106,7 +3119,7 @@ NATRON_PYTHON_NAMESPACE::interpretPythonScript(const std::string& script,std::st
31063119
if (errCatcher && error) {
31073120
errorObj = PyObject_GetAttrString(errCatcher,"value"); //get the stderr from our catchErr object, new ref
31083121
assert(errorObj);
3109-
*error = PY3String_asString(errorObj);
3122+
*error = PyString_asString(errorObj);
31103123
PyObject* unicode = PyUnicode_FromString("");
31113124
PyObject_SetAttrString(errCatcher, "value", unicode);
31123125
Py_DECREF(errorObj);
@@ -3116,7 +3129,7 @@ NATRON_PYTHON_NAMESPACE::interpretPythonScript(const std::string& script,std::st
31163129
if (outCatcher && output) {
31173130
outObj = PyObject_GetAttrString(outCatcher,"value"); //get the stdout from our catchOut object, new ref
31183131
assert(outObj);
3119-
*output = PY3String_asString(outObj);
3132+
*output = PyString_asString(outObj);
31203133
PyObject* unicode = PyUnicode_FromString("");
31213134
PyObject_SetAttrString(outCatcher, "value", unicode);
31223135
Py_DECREF(outObj);
@@ -3156,9 +3169,7 @@ NATRON_PYTHON_NAMESPACE::compilePyScript(const std::string& script,PyObject** co
31563169
}
31573170
#endif
31583171

3159-
3160-
std::string
3161-
NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(const std::string& str)
3172+
static std::string makeNameScriptFriendlyInternal(const std::string& str, bool allowDots)
31623173
{
31633174
if (str == "from") {
31643175
return "pFrom";
@@ -3183,13 +3194,25 @@ NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(const std::string& str)
31833194
}
31843195

31853196
///Non alpha-numeric characters are not allowed in python
3186-
else if (str[i] == '_' || std::isalnum(str[i], loc)) {
3197+
else if (str[i] == '_' || std::isalnum(str[i], loc) || (allowDots && str[i] == '.')) {
31873198
cpy.push_back(str[i]);
31883199
}
31893200
}
31903201
return cpy;
31913202
}
31923203

3204+
std::string
3205+
NATRON_PYTHON_NAMESPACE::makeNameScriptFriendlyWithDots(const std::string& str)
3206+
{
3207+
return makeNameScriptFriendlyInternal(str, true);
3208+
}
3209+
3210+
std::string
3211+
NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(const std::string& str)
3212+
{
3213+
return makeNameScriptFriendlyInternal(str, false);
3214+
}
3215+
31933216
PythonGILLocker::PythonGILLocker()
31943217
// : state(PyGILState_UNLOCKED)
31953218
{
@@ -3317,25 +3340,25 @@ static bool getGroupInfosInternal(const std::string& modulePath,
33173340

33183341
assert(labelObj);
33193342

3320-
*pluginLabel = NATRON_PYTHON_NAMESPACE::PY3String_asString(labelObj);
3343+
*pluginLabel = NATRON_PYTHON_NAMESPACE::PyString_asString(labelObj);
33213344
Py_XDECREF(labelObj);
33223345

33233346
if (idObj) {
3324-
*pluginID = NATRON_PYTHON_NAMESPACE::PY3String_asString(idObj);
3347+
*pluginID = NATRON_PYTHON_NAMESPACE::PyString_asString(idObj);
33253348
deleteScript.append("del pluginID\n");
33263349
Py_XDECREF(idObj);
33273350
}
33283351

33293352
if (iconObj) {
3330-
*iconFilePath = NATRON_PYTHON_NAMESPACE::PY3String_asString(iconObj);
3353+
*iconFilePath = NATRON_PYTHON_NAMESPACE::PyString_asString(iconObj);
33313354
QFileInfo iconInfo(QString::fromUtf8(modulePath.c_str()) + QString::fromUtf8(iconFilePath->c_str()));
33323355
*iconFilePath = iconInfo.canonicalFilePath().toStdString();
33333356

33343357
deleteScript.append("del templateIcon\n");
33353358
Py_XDECREF(iconObj);
33363359
}
33373360
if (iconGrouping) {
3338-
*grouping = NATRON_PYTHON_NAMESPACE::PY3String_asString(iconGrouping);
3361+
*grouping = NATRON_PYTHON_NAMESPACE::PyString_asString(iconGrouping);
33393362
deleteScript.append("del templateGrouping\n");
33403363
Py_XDECREF(iconGrouping);
33413364
}
@@ -3354,7 +3377,7 @@ static bool getGroupInfosInternal(const std::string& modulePath,
33543377

33553378

33563379
if (pluginDescriptionObj) {
3357-
*description = NATRON_PYTHON_NAMESPACE::PY3String_asString(pluginDescriptionObj);
3380+
*description = NATRON_PYTHON_NAMESPACE::PyString_asString(pluginDescriptionObj);
33583381
deleteScript.append("del description\n");
33593382
Py_XDECREF(pluginDescriptionObj);
33603383
}
@@ -3476,7 +3499,7 @@ NATRON_PYTHON_NAMESPACE::getFunctionArguments(const std::string& pyFunc,std::str
34763499
PyObject* itemObj = PyList_GetItem(argListObj, i);
34773500
assert(itemObj);
34783501
if (itemObj) {
3479-
std::string itemName = PY3String_asString(itemObj);
3502+
std::string itemName = PyString_asString(itemObj);
34803503
assert(!itemName.empty());
34813504
if (!itemName.empty()) {
34823505
args->push_back(itemName);

Engine/AppManager.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ class AppManager
520520

521521
bool isSpawnedFromCrashReporter() const;
522522

523+
virtual void reloadScriptEditorFonts() {}
523524

524525
public Q_SLOTS:
525526

@@ -686,7 +687,9 @@ bool interpretPythonScript(const std::string& script, std::string* error, std::s
686687

687688
//void compilePyScript(const std::string& script,PyObject** code);
688689

689-
std::string PY3String_asString(PyObject* obj);
690+
std::string PyString_asString(PyObject* obj);
691+
692+
std::string makeNameScriptFriendlyWithDots(const std::string& str);
690693

691694
std::string makeNameScriptFriendly(const std::string& str);
692695

Engine/Bezier.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -2072,31 +2072,31 @@ Bezier::setKeyframe(double time)
20722072
double x, y;
20732073
double leftDerivX, rightDerivX, leftDerivY, rightDerivY;
20742074

2075-
(*it)->getPositionAtTime(true, time, ViewIdx(0), &x, &y, true);
2076-
(*it)->setPositionAtTime(true, time, x, y);
2075+
(*it)->getPositionAtTime(false, time, ViewIdx(0), &x, &y, true);
2076+
(*it)->setPositionAtTime(false, time, x, y);
20772077

2078-
(*it)->getLeftBezierPointAtTime(true, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
2079-
(*it)->getRightBezierPointAtTime(true, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
2080-
(*it)->setLeftBezierPointAtTime(true, time, leftDerivX, leftDerivY);
2081-
(*it)->setRightBezierPointAtTime(true, time, rightDerivX, rightDerivY);
2078+
(*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
2079+
(*it)->getRightBezierPointAtTime(false, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
2080+
(*it)->setLeftBezierPointAtTime(false, time, leftDerivX, leftDerivY);
2081+
(*it)->setRightBezierPointAtTime(false, time, rightDerivX, rightDerivY);
20822082
}
20832083

20842084
if (useFeather) {
20852085
for (BezierCPs::iterator it = _imp->featherPoints.begin(); it != _imp->featherPoints.end(); ++it) {
20862086
double x, y;
20872087
double leftDerivX, rightDerivX, leftDerivY, rightDerivY;
20882088

2089-
(*it)->getPositionAtTime(true, time, ViewIdx(0),&x, &y, true);
2090-
(*it)->setPositionAtTime(true, time, x, y);
2089+
(*it)->getPositionAtTime(false, time, ViewIdx(0),&x, &y, true);
2090+
(*it)->setPositionAtTime(false, time, x, y);
20912091

2092-
(*it)->getLeftBezierPointAtTime(true, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
2093-
(*it)->getRightBezierPointAtTime(true, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
2094-
(*it)->setLeftBezierPointAtTime(true, time, leftDerivX, leftDerivY);
2095-
(*it)->setRightBezierPointAtTime(true, time, rightDerivX, rightDerivY);
2092+
(*it)->getLeftBezierPointAtTime(false, time, ViewIdx(0),&leftDerivX, &leftDerivY, true);
2093+
(*it)->getRightBezierPointAtTime(false, time, ViewIdx(0),&rightDerivX, &rightDerivY, true);
2094+
(*it)->setLeftBezierPointAtTime(false, time, leftDerivX, leftDerivY);
2095+
(*it)->setRightBezierPointAtTime(false, time, rightDerivX, rightDerivY);
20962096
}
20972097
}
20982098
}
2099-
_imp->setMustCopyGuiBezier(true);
2099+
// _imp->setMustCopyGuiBezier(true);
21002100
Q_EMIT keyframeSet(time);
21012101
}
21022102

0 commit comments

Comments
 (0)