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>2011-09-28 19:42:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-28 19:42:55 +0400
commitb88776ba5a1d58d87b1a70ed73337c2e04e068f8 (patch)
treebe72e48c94a71f2ea9218242fc3890dedb45607a /source/blender/windowmanager
parent35f881b44dfed78290770f929405b63f480d78cb (diff)
fix for crash with demo mode addon, modal operator loading a blend file would free all window data which was then accessed, causing a crash.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index cfeaee18416..596fa35d597 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1223,41 +1223,47 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
retval= ot->modal(C, op, event);
OPERATOR_RETVAL_CHECK(retval);
- if(ot->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm)
- wm->op_undo_depth--;
+ /* when this is _not_ the case the modal modifier may have loaded
+ * a new blend file (demo mode does this), so we have to assume
+ * the event, operator etc have all been freed. - campbell */
+ if(CTX_wm_manager(C) == wm) {
- /* putting back screen context, reval can pass trough after modal failures! */
- if((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) {
- CTX_wm_area_set(C, area);
- CTX_wm_region_set(C, region);
- }
- else {
- /* this special cases is for areas and regions that get removed */
- CTX_wm_area_set(C, NULL);
- CTX_wm_region_set(C, NULL);
- }
+ if(ot->flag & OPTYPE_UNDO)
+ wm->op_undo_depth--;
- if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED))
- wm_operator_reports(C, op, retval, 0);
-
- if(retval & OPERATOR_FINISHED) {
- wm_operator_finished(C, op, 0);
- handler->op= NULL;
- }
- else if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
- WM_operator_free(op);
- handler->op= NULL;
- }
-
- /* remove modal handler, operator itself should have been cancelled and freed */
- if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
- WM_cursor_ungrab(CTX_wm_window(C));
+ /* putting back screen context, reval can pass trough after modal failures! */
+ if((retval & OPERATOR_PASS_THROUGH) || wm_event_always_pass(event)) {
+ CTX_wm_area_set(C, area);
+ CTX_wm_region_set(C, region);
+ }
+ else {
+ /* this special cases is for areas and regions that get removed */
+ CTX_wm_area_set(C, NULL);
+ CTX_wm_region_set(C, NULL);
+ }
- BLI_remlink(handlers, handler);
- wm_event_free_handler(handler);
-
- /* prevent silly errors from operator users */
- //retval &= ~OPERATOR_PASS_THROUGH;
+ if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED))
+ wm_operator_reports(C, op, retval, 0);
+
+ if(retval & OPERATOR_FINISHED) {
+ wm_operator_finished(C, op, 0);
+ handler->op= NULL;
+ }
+ else if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
+ WM_operator_free(op);
+ handler->op= NULL;
+ }
+
+ /* remove modal handler, operator itself should have been cancelled and freed */
+ if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED)) {
+ WM_cursor_ungrab(CTX_wm_window(C));
+
+ BLI_remlink(handlers, handler);
+ wm_event_free_handler(handler);
+
+ /* prevent silly errors from operator users */
+ //retval &= ~OPERATOR_PASS_THROUGH;
+ }
}
}