Skip to content

Commit

Permalink
[cmake,tinyPy] Rely on caller to catch None as return value for Pytho…
Browse files Browse the repository at this point in the history
…n functions which return a string

This allows user to cancel file dialog opened by a project script without
getting slapped in the face with a tinyPy exception.
  • Loading branch information
eumagga0x2a committed Jan 8, 2021
1 parent fb265ba commit 6e6746c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions avidemux_plugins/ADM_scriptEngines/tinyPy/src/GUI_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static tp_obj zzpy_fileWriteSelect(TP)
IEditor *p0 = editor;
const char *p1 = pm.asString();
char *r = pyFileSelWrite(p0,p1);
if(!r) pm.raise("pyGui : null pointer");
if(!r) return tp_None;

tp_obj o = tp_string_copy(tp, r, strlen(r));
ADM_dealloc(r);
Expand Down Expand Up @@ -44,7 +44,7 @@ static tp_obj zzpy_dirSelect(TP)
IEditor *p0 = editor;
const char *p1 = pm.asString();
char *r = pyDirSelect(p0,p1);
if(!r) pm.raise("pyGui : null pointer");
if(!r) return tp_None;

tp_obj o = tp_string_copy(tp, r, strlen(r));
ADM_dealloc(r);
Expand Down Expand Up @@ -77,7 +77,7 @@ static tp_obj zzpy_fileReadSelect(TP)
IEditor *p0 = editor;
const char *p1 = pm.asString();
char *r = pyFileSelRead(p0,p1);
if(!r) pm.raise("pyGui : null pointer");
if(!r) return tp_None;

tp_obj o = tp_string_copy(tp, r, strlen(r));
ADM_dealloc(r);
Expand Down
2 changes: 1 addition & 1 deletion avidemux_plugins/ADM_scriptEngines/tinyPy/src/adm_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static tp_obj zzpy_getVideoCodec(TP)
void *me = (void *)pm.asThis(&self, ADM_PYID_AVIDEMUX);

char *r = editor->getVideoCodec();
if(!r) pm.raise("pyAdm : null pointer");
if(!r) return tp_None;

tp_obj o = tp_string_copy(tp, r, strlen(r));
ADM_dealloc(r);
Expand Down
2 changes: 1 addition & 1 deletion cmake/admPyClass.pl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ sub genReturn
}
if($retType=~m/str/)
{
return " if(!r) pm.raise(\"$className : null pointer\");\n
return " if(!r) return tp_None;\n
tp_obj o = tp_string_copy(tp, r, strlen(r));
ADM_dealloc(r);
return o;";
Expand Down

0 comments on commit 6e6746c

Please sign in to comment.