An ignorable exception for plugins
parent
1eb63773c9
commit
14a38ee78d
|
@ -16,6 +16,7 @@
|
|||
#include <Python.h>
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#include "pygobject.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "moopython/moopython-loader.h"
|
||||
#include "mooutils/mooutils-misc.h"
|
||||
|
@ -131,6 +132,32 @@ do_load_file (const char *path)
|
|||
|
||||
if (!mod)
|
||||
{
|
||||
if (PyErr_ExceptionMatches (PyExc_Exception))
|
||||
{
|
||||
PyObject *type, *value, *traceback;
|
||||
PyObject *r;
|
||||
char *s;
|
||||
|
||||
PyErr_Fetch (&type, &value, &traceback);
|
||||
PyErr_NormalizeException (&type, &value, &traceback);
|
||||
r = PyObject_Repr (value);
|
||||
s = r ? PyString_AsString (r) : NULL;
|
||||
|
||||
if (s && strcmp (s, "PluginWontLoad") == 0)
|
||||
{
|
||||
Py_XDECREF (r);
|
||||
Py_XDECREF (type);
|
||||
Py_XDECREF (value);
|
||||
Py_XDECREF (traceback);
|
||||
goto out;
|
||||
}
|
||||
|
||||
Py_XDECREF (r);
|
||||
|
||||
PyErr_Restore(type, value, traceback);
|
||||
}
|
||||
|
||||
g_warning ("error when loading file '%s'", path);
|
||||
PyErr_Print ();
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,13 @@ from _moo_edit import *
|
|||
def edit_class_add_action(cls, action_id, action_class):
|
||||
_edit._edit_class_add_action(cls, action_id, action_class)
|
||||
|
||||
class _PluginWontLoad(Exception):
|
||||
def __repr__(self):
|
||||
return 'PluginWontLoad'
|
||||
|
||||
def cancel_plugin_loading():
|
||||
raise _PluginWontLoad()
|
||||
|
||||
#class _UIInfo(object):
|
||||
#def __init__(self, parent, action, name=None, index=-1):
|
||||
#self.parent = parent
|
||||
|
|
Loading…
Reference in New Issue