diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-11-05 13:41:16 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-11-05 13:41:16 +0300 |
commit | e51d7a7a85ead23c5b5dc311d8b333db66b544e4 (patch) | |
tree | 94dfc51efe65fefb61176319115c89683e8eb077 /source/blender/windowmanager/intern | |
parent | 388dc243302ee522aedc7ee866cd45e61a91d890 (diff) | |
parent | 6566013c913e033fdabac4f1efb46bf08342b4df (diff) |
Merge branch 'master' into wiggly-widgets
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 60 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 99 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 4 |
3 files changed, 102 insertions, 61 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 832fef404e3..8f0f76466e9 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -171,6 +171,28 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist) #endif } +static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win) +{ + win->ghostwin = oldwin->ghostwin; + win->active = oldwin->active; + if (win->active) + wm->winactive = win; + + if (!G.background) /* file loading in background mode still calls this */ + GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ + + oldwin->ghostwin = NULL; + + win->eventstate = oldwin->eventstate; + oldwin->eventstate = NULL; + + /* ensure proper screen rescaling */ + win->sizex = oldwin->sizex; + win->sizey = oldwin->sizey; + win->posx = oldwin->posx; + win->posy = oldwin->posy; +} + /* match old WM with new, 4 cases: * 1- no current wm, no read wm: make new default * 2- no current wm, but read wm: that's OK, do nothing @@ -224,6 +246,8 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) ED_screens_initialize(G.main->wm.first); } else { + bool has_match = false; + /* what if old was 3, and loaded 1? */ /* this code could move to setup_appdata */ oldwm = oldwmlist->first; @@ -243,33 +267,27 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) /* ensure making new keymaps and set space types */ wm->initialized = 0; wm->winactive = NULL; - + /* only first wm in list has ghostwins */ for (win = wm->windows.first; win; win = win->next) { for (oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) { - - if (oldwin->winid == win->winid) { - win->ghostwin = oldwin->ghostwin; - win->active = oldwin->active; - if (win->active) - wm->winactive = win; - if (!G.background) /* file loading in background mode still calls this */ - GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */ + if (oldwin->winid == win->winid) { + has_match = true; - oldwin->ghostwin = NULL; - - win->eventstate = oldwin->eventstate; - oldwin->eventstate = NULL; - - /* ensure proper screen rescaling */ - win->sizex = oldwin->sizex; - win->sizey = oldwin->sizey; - win->posx = oldwin->posx; - win->posy = oldwin->posy; + wm_window_substitute_old(wm, oldwin, win); } } } + + /* make sure at least one window is kept open so we don't lose the context, check T42303 */ + if (!has_match) { + oldwin = oldwm->windows.first; + win = wm->windows.first; + + wm_window_substitute_old(wm, oldwin, win); + } + wm_close_and_free_all(C, oldwmlist); } } @@ -458,6 +476,8 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) BPY_python_reset(C); #endif + WM_operatortype_last_properties_clear_all(); + /* important to do before NULL'ing the context */ BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE); BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); @@ -650,6 +670,8 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c } #endif + WM_operatortype_last_properties_clear_all(); + /* important to do before NULL'ing the context */ BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE); BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 68aad2dbda6..f048562a380 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -147,9 +147,9 @@ wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) } /* caller must free */ -GHashIterator *WM_operatortype_iter(void) +void WM_operatortype_iter(GHashIterator *ghi) { - return BLI_ghashIterator_new(global_ops_hash); + BLI_ghashIterator_init(ghi, global_ops_hash); } /* all ops in 1 list (for time being... needs evaluation later) */ @@ -494,6 +494,27 @@ bool WM_operatortype_remove(const char *idname) return true; } +/** + * Remove memory of all previously executed tools. + */ +void WM_operatortype_last_properties_clear_all(void) +{ + GHashIterator iter; + + for (WM_operatortype_iter(&iter); + (!BLI_ghashIterator_done(&iter)); + (BLI_ghashIterator_step(&iter))) + { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); + + if (ot->last_properties) { + IDP_FreeProperty(ot->last_properties); + MEM_freeN(ot->last_properties); + ot->last_properties = NULL; + } + } +} + /* SOME_OT_op -> some.op */ void WM_operator_py_idname(char *to, const char *from) { @@ -1058,6 +1079,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); + return OPERATOR_INTERFACE; } return OPERATOR_CANCELLED; @@ -1102,7 +1124,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { uiPupBlock(C, wm_enum_search_menu, op); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } /* Can't be used as an invoke directly, needs message arg (can be NULL) */ @@ -1124,7 +1146,7 @@ int WM_operator_confirm_message_ex(bContext *C, wmOperator *op, uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message) @@ -1194,31 +1216,32 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, if (action == FILE_SAVE) { /* note, this is only used to check if we should highlight the filename area red when the * filepath is an existing file. */ - prop = RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files"); + prop = RNA_def_boolean(ot->srna, "check_existing", true, "Check Existing", + "Check and warn on overwriting existing files"); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } - prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", ""); + prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE) != 0, "Filter .blend files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_backup", (filter & BLENDERFILE_BACKUP), "Filter .blend files", ""); + prop = RNA_def_boolean(ot->srna, "filter_backup", (filter & BLENDERFILE_BACKUP) != 0, "Filter .blend files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", ""); + prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE) != 0, "Filter image files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", ""); + prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE) != 0, "Filter movie files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE), "Filter python files", ""); + prop = RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE) != 0, "Filter python files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE), "Filter font files", ""); + prop = RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE) != 0, "Filter font files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE), "Filter sound files", ""); + prop = RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE) != 0, "Filter sound files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE), "Filter text files", ""); + prop = RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE) != 0, "Filter text files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_btx", (filter & BTXFILE), "Filter btx files", ""); + prop = RNA_def_boolean(ot->srna, "filter_btx", (filter & BTXFILE) != 0, "Filter btx files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_collada", (filter & COLLADAFILE), "Filter COLLADA files", ""); + prop = RNA_def_boolean(ot->srna, "filter_collada", (filter & COLLADAFILE) != 0, "Filter COLLADA files", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE), "Filter folders", ""); + prop = RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE) != 0, "Filter folders", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); prop = RNA_def_int(ot->srna, "filemode", type, FILE_LOADLIB, FILE_SPECIAL, @@ -1307,7 +1330,7 @@ void WM_operator_properties_gesture_border(wmOperatorType *ot, bool extend) WM_operator_properties_border(ot); if (extend) { - RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first"); + RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection instead of deselecting everything first"); } } @@ -1315,11 +1338,12 @@ void WM_operator_properties_mouse_select(wmOperatorType *ot) { PropertyRNA *prop; - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first"); + prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", + "Extend selection instead of deselecting everything first"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Remove from selection"); + prop = RNA_def_boolean(ot->srna, "deselect", false, "Deselect", "Remove from selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "toggle", 0, "Toggle Selection", "Toggle the selection"); + prop = RNA_def_boolean(ot->srna, "toggle", false, "Toggle Selection", "Toggle the selection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -1997,7 +2021,7 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNU { uiPupBlock(C, wm_block_search_menu, op); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } /* op->poll */ @@ -2036,9 +2060,7 @@ static int wm_call_menu_exec(bContext *C, wmOperator *op) char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - uiPupMenuInvoke(C, idname, op->reports); - - return OPERATOR_CANCELLED; + return uiPupMenuInvoke(C, idname, op->reports); } static void WM_OT_call_menu(wmOperatorType *ot) @@ -2060,9 +2082,7 @@ static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *e char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - uiPieMenuInvoke(C, idname, event); - - return OPERATOR_CANCELLED; + return uiPieMenuInvoke(C, idname, event); } static int wm_call_pie_menu_exec(bContext *C, wmOperator *op) @@ -2070,9 +2090,7 @@ static int wm_call_pie_menu_exec(bContext *C, wmOperator *op) char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate); - - return OPERATOR_CANCELLED; + return uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate); } static void WM_OT_call_menu_pie(wmOperatorType *ot) @@ -2763,9 +2781,9 @@ static void save_set_compress(wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "compress")) { if (G.save_over) /* keep flag for existing file */ - RNA_boolean_set(op->ptr, "compress", G.fileflags & G_FILE_COMPRESS); + RNA_boolean_set(op->ptr, "compress", (G.fileflags & G_FILE_COMPRESS) != 0); else /* use userdef for new file */ - RNA_boolean_set(op->ptr, "compress", U.flag & USER_FILECOMPRESS); + RNA_boolean_set(op->ptr, "compress", (U.flag & USER_FILECOMPRESS) != 0); } } @@ -2864,14 +2882,14 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); - RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", + RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file"); + RNA_def_boolean(ot->srna, "relative_remap", true, "Remap Relative", "Remap relative paths when saving in a different directory"); - prop = RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", + prop = RNA_def_boolean(ot->srna, "copy", false, "Save Copy", "Save a copy of the actual working state but does not make saved file active"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); #ifdef USE_BMESH_SAVE_AS_COMPAT - RNA_def_boolean(ot->srna, "use_mesh_compat", 0, "Legacy Mesh Format", + RNA_def_boolean(ot->srna, "use_mesh_compat", false, "Legacy Mesh Format", "Save using legacy mesh format (no ngons) - WARNING: only saves tris and quads, other ngons will " "be lost (no implicit triangulation)"); #endif @@ -2940,8 +2958,9 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE | BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); - RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); + RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file"); + RNA_def_boolean(ot->srna, "relative_remap", false, "Remap Relative", + "Remap relative paths when saving in a different directory"); } static void WM_OT_window_fullscreen_toggle(wmOperatorType *ot) @@ -3989,7 +4008,7 @@ static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, PropertyType prop_type = RNA_property_type(*r_prop); if (((flags & RC_PROP_REQUIRE_BOOL) && (prop_type != PROP_BOOLEAN)) || - ((flags & RC_PROP_REQUIRE_FLOAT) && prop_type != PROP_FLOAT)) + ((flags & RC_PROP_REQUIRE_FLOAT) && (prop_type != PROP_FLOAT))) { MEM_freeN(str); BKE_reportf(op->reports, RPT_ERROR, "Property from path '%s' is not a float", name); @@ -4343,7 +4362,7 @@ static void WM_OT_radial_control(wmOperatorType *ot) RNA_def_string(ot->srna, "image_id", NULL, 0, "Image ID", "Path of ID that is used to generate an image for the control"); - RNA_def_boolean(ot->srna, "secondary_tex", 0, "Secondary Texture", "Tweak brush secondary/mask texture"); + RNA_def_boolean(ot->srna, "secondary_tex", false, "Secondary Texture", "Tweak brush secondary/mask texture"); } /* ************************** timer for testing ***************** */ diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 76add2f9aac..677be734d4b 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -298,8 +298,8 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf glRasterPos2f(offs_x + (ps->draw_flip[0] ? span_x : 0.0f), offs_y + (ps->draw_flip[1] ? span_y : 0.0f)); - glPixelZoom(ps->zoom * ps->draw_flip[0] ? -1.0f : 1.0f, - ps->zoom * ps->draw_flip[1] ? -1.0f : 1.0f); + glPixelZoom(ps->zoom * (ps->draw_flip[0] ? -1.0f : 1.0f), + ps->zoom * (ps->draw_flip[1] ? -1.0f : 1.0f)); glDrawPixels(ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); |