Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-10-12 15:31:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-10-12 15:31:11 +0400
commitf8d60578086e0405d56244b783d966c3d872b21a (patch)
tree11faab081d9d22642a660857315fea5fe4ac7695
parenta146614a5ca47768176664c14afa0f5c585eee4c (diff)
in rare cases the screen cant be found for BPy's file/image selector
-rw-r--r--source/blender/python/api2_2x/Window.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c
index a4c7802ff34..40f6d52d8da 100644
--- a/source/blender/python/api2_2x/Window.c
+++ b/source/blender/python/api2_2x/Window.c
@@ -577,8 +577,6 @@ static PyObject * FileAndImageSelector(PyObject * self, PyObject * args, int typ
"\nexpected a callback function (and optionally one or two strings) "
"as argument(s)" );
- Py_INCREF(pycallback);
-
/* trick: we move to a spacescript because then the fileselector will properly
* unset our SCRIPT_FILESEL flag when the user chooses a file or cancels the
* selection. This is necessary because when a user cancels, the
@@ -605,9 +603,18 @@ static PyObject * FileAndImageSelector(PyObject * self, PyObject * args, int typ
script->lastspace = startspace;
sc->script = script;
}
-
+
+ if (!script) {
+ /* should never happen unless we are executed
+ * from the BGE or somthing really strange like that */
+ return EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Could not allocate a screen for an unknown reason." );
+ }
+
+ Py_INCREF(pycallback);
+
script->flags |= SCRIPT_FILESEL;
-
+
/* clear any previous callback (nested calls to selector) */
if (script->py_browsercallback) {
Py_DECREF((PyObject *)script->py_browsercallback);