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:
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c2
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
-rw-r--r--source/blender/windowmanager/intern/wm_files.c70
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c6
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c4
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c2
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c2
-rw-r--r--source/blender/windowmanager/intern/wm_menu_type.c1
-rw-r--r--source/blender/windowmanager/intern/wm_operator_type.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c16
-rw-r--r--source/blender/windowmanager/intern/wm_window.c20
11 files changed, 90 insertions, 37 deletions
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 24ec3aef759..e789099c799 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -274,7 +274,7 @@ bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event)
}
-/* afer this you can call restore too */
+/* after this you can call restore too */
void WM_cursor_time(wmWindow *win, int nr)
{
/* 10 8x8 digits */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 3a300877750..0084c3a5407 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2101,7 +2101,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
/* modal handlers can get removed in this loop, we keep the loop this way
*
* note: check 'handlers->first' because in rare cases the handlers can be cleared
- * by the event thats called, for eg:
+ * by the event that's called, for eg:
*
* Calling a python script which changes the area.type, see [#32232] */
for (handler = handlers->first; handler && handlers->first; handler = nexthandler) {
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 477699fccaa..acb954a4b05 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -473,10 +473,14 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
if (use_userdef) {
/* Only run when we have a template path found. */
if (BKE_appdir_app_template_any()) {
- BPY_execute_string(C, "__import__('bl_app_template_utils').reset()");
+ BPY_execute_string(
+ C, (const char *[]){"bl_app_template_utils", NULL},
+ "bl_app_template_utils.reset()");
}
/* sync addons, these may have changed from the defaults */
- BPY_execute_string(C, "__import__('addon_utils').reset_all()");
+ BPY_execute_string(
+ C, (const char *[]){"addon_utils", NULL},
+ "addon_utils.reset_all()");
}
BPY_python_reset(C);
addons_loaded = true;
@@ -565,7 +569,10 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
/* confusing this global... */
G.relbase_valid = 1;
- retval = BKE_blendfile_read(C, filepath, reports, 0);
+ retval = BKE_blendfile_read(
+ C, filepath,
+ &(const struct BlendFileReadParams){0},
+ reports);
/* BKE_file_read sets new Main into context. */
Main *bmain = CTX_data_main(C);
@@ -641,7 +648,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
struct {
char app_template[64];
bool override;
-} wm_init_state_app_template = {0};
+} wm_init_state_app_template = {{0}};
/**
* Used for setting app-template from the command line:
@@ -800,7 +807,13 @@ int wm_homefile_read(
if (!use_factory_settings || (filepath_startup[0] != '\0')) {
if (BLI_access(filepath_startup, R_OK) == 0) {
- success = (BKE_blendfile_read(C, filepath_startup, NULL, skip_flags) != BKE_BLENDFILE_READ_FAIL);
+ success = BKE_blendfile_read(
+ C, filepath_startup,
+ &(const struct BlendFileReadParams){
+ .is_startup = true,
+ .skip_flags = skip_flags,
+ },
+ NULL) != BKE_BLENDFILE_READ_FAIL;
}
if (BLI_listbase_is_empty(&U.themes)) {
if (G.debug & G_DEBUG)
@@ -816,8 +829,12 @@ int wm_homefile_read(
if (success == false) {
success = BKE_blendfile_read_from_memory(
- C, datatoc_startup_blend, datatoc_startup_blend_size,
- NULL, skip_flags, true);
+ C, datatoc_startup_blend, datatoc_startup_blend_size, true,
+ &(const struct BlendFileReadParams){
+ .is_startup = true,
+ .skip_flags = skip_flags,
+ },
+ NULL);
if (success) {
if (use_userdef) {
if ((skip_flags & BLO_READ_SKIP_USERDEF) == 0) {
@@ -964,7 +981,7 @@ static RecentFile *wm_file_history_find(const char *filepath)
/**
* Write #BLENDER_HISTORY_FILE as-is, without checking the environment
- * (thats handled by #wm_history_file_update).
+ * (that's handled by #wm_history_file_update).
*/
static void wm_history_file_write(void)
{
@@ -1128,12 +1145,12 @@ bool write_crash_blend(void)
/**
* \see #wm_homefile_write_exec wraps #BLO_write_file in a similar way.
*/
-static int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports)
+static bool wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports)
{
Main *bmain = CTX_data_main(C);
Library *li;
int len;
- int ret = -1;
+ int ok = false;
BlendThumbnail *thumb, *main_thumb;
ImBuf *ibuf_thumb = NULL;
@@ -1141,18 +1158,18 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
if (len == 0) {
BKE_report(reports, RPT_ERROR, "Path is empty, cannot save");
- return ret;
+ return ok;
}
if (len >= FILE_MAX) {
BKE_report(reports, RPT_ERROR, "Path too long, cannot save");
- return ret;
+ return ok;
}
/* Check if file write permission is ok */
if (BLI_exists(filepath) && !BLI_file_is_writable(filepath)) {
BKE_reportf(reports, RPT_ERROR, "Cannot save blend file, path '%s' is not writable", filepath);
- return ret;
+ return ok;
}
/* note: used to replace the file extension (to ensure '.blend'),
@@ -1163,7 +1180,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
for (li = bmain->library.first; li; li = li->id.next) {
if (BLI_path_cmp(li->filepath, filepath) == 0) {
BKE_reportf(reports, RPT_ERROR, "Cannot overwrite used library '%.240s'", filepath);
- return ret;
+ return ok;
}
}
@@ -1226,7 +1243,8 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
ibuf_thumb = IMB_thumb_create(filepath, THB_LARGE, THB_SOURCE_BLEND, ibuf_thumb);
}
- ret = 0; /* Success. */
+ /* Success. */
+ ok = true;
}
if (ibuf_thumb) {
@@ -1238,7 +1256,7 @@ static int wm_file_write(bContext *C, const char *filepath, int fileflags, Repor
WM_cursor_wait(0);
- return ret;
+ return ok;
}
/************************ autosave ****************************/
@@ -1415,6 +1433,7 @@ void WM_file_tag_modified(void)
/**
* \see #wm_file_write wraps #BLO_write_file in a similar way.
+ * \return success.
*/
static int wm_homefile_write_exec(bContext *C, wmOperator *op)
{
@@ -2092,7 +2111,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
char path[FILE_MAX];
- int fileflags;
+ const bool is_save_as = (op->type->invoke == wm_save_as_mainfile_invoke);
save_set_compress(op);
@@ -2104,7 +2123,8 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
wm_filepath_default(path);
}
- fileflags = G.fileflags & ~G_FILE_USERPREFS;
+ const int fileflags_orig = G.fileflags;
+ int fileflags = G.fileflags & ~G_FILE_USERPREFS;
/* set compression flag */
SET_FLAG_FROM_TEST(
@@ -2119,12 +2139,22 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
RNA_boolean_get(op->ptr, "copy")),
G_FILE_SAVE_COPY);
- if (wm_file_write(C, path, fileflags, op->reports) != 0)
+ const bool ok = wm_file_write(C, path, fileflags, op->reports);
+
+ if ((op->flag & OP_IS_INVOKE) == 0) {
+ /* OP_IS_INVOKE is set when the operator is called from the GUI.
+ * If it is not set, the operator is called from a script and
+ * shouldn't influence G.fileflags. */
+ G.fileflags = fileflags_orig;
+ }
+
+ if (ok == false) {
return OPERATOR_CANCELLED;
+ }
WM_event_add_notifier(C, NC_WM | ND_FILESAVE, NULL);
- if (RNA_boolean_get(op->ptr, "exit")) {
+ if (!is_save_as && RNA_boolean_get(op->ptr, "exit")) {
wm_exit_schedule_delayed(C);
}
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 72973d3de56..d8cc5b37b7d 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -361,7 +361,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
}
if (!BLI_ghash_haskey(libraries, libname)) {
- BLI_ghash_insert(libraries, BLI_strdup(libname), SET_INT_IN_POINTER(lib_idx));
+ BLI_ghash_insert(libraries, BLI_strdup(libname), POINTER_FROM_INT(lib_idx));
lib_idx++;
wm_link_append_data_library_add(lapp_data, libname);
}
@@ -382,7 +382,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op)
continue;
}
- lib_idx = GET_INT_FROM_POINTER(BLI_ghash_lookup(libraries, libname));
+ lib_idx = POINTER_AS_INT(BLI_ghash_lookup(libraries, libname));
item = wm_link_append_data_item_add(lapp_data, name, BKE_idcode_from_name(group), NULL);
BLI_BITMAP_ENABLE(item->libraries, lib_idx);
@@ -602,7 +602,7 @@ static void lib_relocate_do(
BKE_main_id_tag_all(bmain, LIB_TAG_PRE_EXISTING, true);
- /* We do not want any instanciation here! */
+ /* We do not want any instantiation here! */
wm_link_do(lapp_data, reports, bmain, NULL, NULL);
BKE_main_lock(bmain);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 185cf3fad4f..d254a83fcc2 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -188,7 +188,10 @@ void WM_init(bContext *C, int argc, const char **argv)
ED_node_init_butfuncs();
BLF_init(); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
+
BLT_lang_init();
+ /* Must call first before doing any .blend file reading, since versionning code may create new IDs... See T57066. */
+ BLT_lang_set(NULL);
/* reports cant be initialized before the wm,
* but keep before file reading, since that may report errors */
@@ -197,6 +200,7 @@ void WM_init(bContext *C, int argc, const char **argv)
/* get the default database, plus a wm */
wm_homefile_read(C, NULL, G.factory_startup, false, true, NULL, WM_init_state_app_template_get());
+ /* Call again to set from userpreferences... */
BLT_lang_set(NULL);
if (!G.background) {
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index d7df671bce5..92d51c9a400 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -175,7 +175,7 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
/* ******************* public API ***************** */
/**
- * \return current job or adds new job, but doesnt run it.
+ * \return current job or adds new job, but doesn't run it.
*
* \note every owner only gets a single job,
* adding a new one will stop running job and when stopped it starts the new one.
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index be147606c46..2834e95527a 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -121,7 +121,7 @@ static void wm_keymap_item_properties_update_ot(wmKeyMapItem *kmi)
wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0);
if (ot) {
if (ot->srna != kmi->ptr->type) {
- /* matches wm_keymap_item_properties_set but doesnt alloc new ptr */
+ /* matches wm_keymap_item_properties_set but doesn't alloc new ptr */
WM_operator_properties_create_ptr(kmi->ptr, ot);
/* 'kmi->ptr->data' NULL'd above, keep using existing properties.
* Note: the operators property types may have changed,
diff --git a/source/blender/windowmanager/intern/wm_menu_type.c b/source/blender/windowmanager/intern/wm_menu_type.c
index 58e85716bf1..4e71001990d 100644
--- a/source/blender/windowmanager/intern/wm_menu_type.c
+++ b/source/blender/windowmanager/intern/wm_menu_type.c
@@ -60,6 +60,7 @@ MenuType *WM_menutype_find(const char *idname, bool quiet)
bool WM_menutype_add(MenuType *mt)
{
+ BLI_assert((mt->description == NULL) || (mt->description[0]));
BLI_ghash_insert(menutypes_hash, mt->idname, mt);
return true;
}
diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c
index 25ca84f3d57..e9287d83a9a 100644
--- a/source/blender/windowmanager/intern/wm_operator_type.c
+++ b/source/blender/windowmanager/intern/wm_operator_type.c
@@ -116,6 +116,7 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType *))
if (ot->name == NULL) {
CLOG_ERROR(WM_LOG_OPERATORS, "Operator '%s' has no name property", ot->idname);
}
+ BLI_assert((ot->description == NULL) || (ot->description[0]));
/* XXX All ops should have a description but for now allow them not to. */
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
@@ -134,6 +135,7 @@ void WM_operatortype_append_ptr(void (*opfunc)(wmOperatorType *, void *), void *
RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT;
opfunc(ot, userdata);
+ BLI_assert((ot->description == NULL) || (ot->description[0]));
RNA_def_struct_ui_text(ot->srna, ot->name, ot->description ? ot->description : UNDOCUMENTED_OPERATOR_TIP);
RNA_def_struct_identifier(&BLENDER_RNA, ot->srna, ot->idname);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 4438bd1595f..2008d388ad3 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -262,7 +262,7 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args,
}
}
else {
- /* only to get the orginal props for comparisons */
+ /* only to get the original props for comparisons */
PointerRNA opptr_default;
const bool macro_args_test = ot->macro.first ? macro_args : true;
@@ -607,7 +607,7 @@ void WM_operator_properties_sanitize(PointerRNA *ptr, const bool no_context)
/** set all props to their default,
* \param do_update Only update un-initialized props.
*
- * \note, theres nothing specific to operators here.
+ * \note, there's nothing specific to operators here.
* this could be made a general function.
*/
bool WM_operator_properties_default(PointerRNA *ptr, const bool do_update)
@@ -1813,7 +1813,7 @@ static void WM_OT_console_toggle(wmOperatorType *ot)
* - draw(bContext): drawing callback for paint cursor
*/
-void *WM_paint_cursor_activate(
+wmPaintCursor *WM_paint_cursor_activate(
wmWindowManager *wm, bool (*poll)(bContext *C),
wmPaintCursorDraw draw, void *customdata)
{
@@ -1828,7 +1828,7 @@ void *WM_paint_cursor_activate(
return pc;
}
-void WM_paint_cursor_end(wmWindowManager *wm, void *handle)
+bool WM_paint_cursor_end(wmWindowManager *wm, wmPaintCursor *handle)
{
wmPaintCursor *pc;
@@ -1836,9 +1836,15 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle)
if (pc == (wmPaintCursor *)handle) {
BLI_remlink(&wm->paintcursors, pc);
MEM_freeN(pc);
- return;
+ return true;
}
}
+ return false;
+}
+
+void *WM_paint_cursor_customdata_get(wmPaintCursor *pc)
+{
+ return pc->customdata;
}
/* *********************** radial control ****************** */
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 501d448011b..04a236e5d66 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -102,8 +102,9 @@ static struct WMInitStruct {
int windowstate;
WinOverrideFlag override_flag;
+ bool window_focus;
bool native_pixels;
-} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, true};
+} wm_init_state = {0, 0, 0, 0, GHOST_kWindowStateNormal, 0, true, true};
/* ******** win open & close ************ */
@@ -624,7 +625,9 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
#ifndef __APPLE__
/* set the state here, so minimized state comes up correct on windows */
- GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
+ if (wm_init_state.window_focus) {
+ GHOST_SetWindowState(ghostwin, (GHOST_TWindowState)win->windowstate);
+ }
#endif
/* until screens get drawn, make it nice gray */
glClearColor(0.55, 0.55, 0.55, 0.0);
@@ -809,7 +812,7 @@ wmWindow *WM_window_open_temp(bContext *C, int x, int y, int sizex, int sizey, i
sizex /= native_pixel_size;
sizey /= native_pixel_size;
- /* calculate postition */
+ /* calculate position */
rcti rect;
rect.xmin = x + win_prev->posx - sizex / 2;
rect.ymin = y + win_prev->posy - sizey / 2;
@@ -1468,7 +1471,7 @@ static int wm_window_timer(const bContext *C)
else if (wt->event_type == TIMERAUTOSAVE)
wm_autosave_timer(C, wm, wt);
else if (wt->event_type == TIMERNOTIFIER)
- WM_main_add_notifier(GET_UINT_FROM_POINTER(wt->customdata), NULL);
+ WM_main_add_notifier(POINTER_AS_UINT(wt->customdata), NULL);
else if (win) {
wmEvent event;
wm_event_init_from_window(win, &event);
@@ -1546,6 +1549,8 @@ void wm_ghost_init(bContext *C)
if (wm_init_state.native_pixels) {
GHOST_UseNativePixels();
}
+
+ GHOST_UseWindowFocus(wm_init_state.window_focus);
}
}
@@ -1598,7 +1603,7 @@ wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm, wmWindow *win, unsigne
wt->stime = wt->ltime;
wt->timestep = timestep;
wt->win = win;
- wt->customdata = SET_UINT_IN_POINTER(type);
+ wt->customdata = POINTER_FROM_UINT(type);
wt->flags |= WM_TIMER_NO_FREE_CUSTOM_DATA;
BLI_addtail(&wm->timers, wt);
@@ -1832,6 +1837,11 @@ void WM_init_state_normal_set(void)
wm_init_state.override_flag |= WIN_OVERRIDE_WINSTATE;
}
+void WM_init_window_focus_set(bool do_it)
+{
+ wm_init_state.window_focus = do_it;
+}
+
void WM_init_native_pixels(bool do_it)
{
wm_init_state.native_pixels = do_it;