fix [#35860] crash if pressing <F8> in import dialog

disallow reloading scripts while running modal, python operators.
This commit is contained in:
Campbell Barton 2013-06-28 16:15:44 +00:00
parent dc85135045
commit 8b96383b8f

@ -36,10 +36,12 @@
#include "BLI_utildefines.h" #include "BLI_utildefines.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_report.h"
#include "BKE_global.h" #include "BKE_global.h"
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
#include "wm_event_system.h"
#include "RNA_access.h" #include "RNA_access.h"
#include "RNA_define.h" #include "RNA_define.h"
@ -84,10 +86,41 @@ void SCRIPT_OT_python_file_run(wmOperatorType *ot)
RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "Path", ""); RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "Path", "");
} }
#ifdef WITH_PYTHON
static bool script_test_modal_operators(bContext *C)
{
wmWindowManager *wm;
wmWindow *win;
static int script_reload_exec(bContext *C, wmOperator *UNUSED(op)) wm = CTX_wm_manager(C);
for (win = wm->windows.first; win; win = win->next) {
wmEventHandler *handler;
for (handler = win->modalhandlers.first; handler; handler = handler->next) {
if (handler->op) {
wmOperatorType *ot = handler->op->type;
if (ot->ext.srna) {
return true;
}
}
}
}
return false;
}
#endif
static int script_reload_exec(bContext *C, wmOperator *op)
{ {
#ifdef WITH_PYTHON #ifdef WITH_PYTHON
/* clear running operators */
if (script_test_modal_operators(C)) {
BKE_report(op->reports, RPT_ERROR, "Can't reload with running modal operators");
return OPERATOR_CANCELLED;
}
/* TODO, this crashes on netrender and keying sets, need to look into why /* TODO, this crashes on netrender and keying sets, need to look into why
* disable for now unless running in debug mode */ * disable for now unless running in debug mode */
WM_cursor_wait(1); WM_cursor_wait(1);