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>2015-10-06 16:27:27 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-06 16:36:39 +0300
commit84713629877d84d8c973d55e7e7cb0eca0f2ba49 (patch)
treedb12b860677dd59f3e3ffddb71c670de7aeb36d3 /source/blender/editors/screen/screen_ops.c
parent867c49b962fed324b41492e4cbaf586b5020e2dd (diff)
WM: Fix crash when a new window can't be created
Report an error instead of crashing if a new window can't be created (typically caused by bad drivers).
Diffstat (limited to 'source/blender/editors/screen/screen_ops.c')
-rw-r--r--source/blender/editors/screen/screen_ops.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 4a1c1e34414..24653dc556c 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -992,6 +992,11 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
rect.ymax = rect.ymin + BLI_rcti_size_y(&rect) / U.pixelsize;
newwin = WM_window_open(C, &rect);
+ if (newwin == NULL) {
+ BKE_report(op->reports, RPT_ERROR, "Failed to open window!");
+ goto finally;
+ }
+
*newwin->stereo3d_format = *win->stereo3d_format;
/* allocs new screen and adds to newly created window, using window size */
@@ -1005,11 +1010,18 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
/* screen, areas init */
WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
-
+
+
+finally:
if (event->type == EVT_ACTIONZONE_AREA)
actionzone_exit(op);
- return OPERATOR_FINISHED;
+ if (newwin) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
static void SCREEN_OT_area_dupli(wmOperatorType *ot)
@@ -3845,7 +3857,7 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
/* *********** show user pref window ****** */
-static int userpref_show_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
wmWindow *win = CTX_wm_window(C);
rcti rect;
@@ -3862,9 +3874,13 @@ static int userpref_show_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve
rect.ymax = rect.ymin + sizey;
/* changes context! */
- WM_window_open_temp(C, &rect, WM_WINDOW_USERPREFS);
-
- return OPERATOR_FINISHED;
+ if (WM_window_open_temp(C, &rect, WM_WINDOW_USERPREFS) != NULL) {
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "Failed to open window!");
+ return OPERATOR_CANCELLED;
+ }
}