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/wm_files.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c81
1 files changed, 47 insertions, 34 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index a170fa9902b..9d6687eaa9c 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -71,6 +71,7 @@
#include "BKE_lib_override.h"
#include "BKE_lib_remap.h"
#include "BKE_main.h"
+#include "BKE_main_namemap.h"
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_scene.h"
@@ -295,6 +296,12 @@ static void wm_window_match_keep_current_wm(const bContext *C,
}
}
+ /* we'll be using the current wm list directly; make sure
+ * the names are validated and in the name map. */
+ LISTBASE_FOREACH (wmWindowManager *, wm_item, current_wm_list) {
+ BKE_main_namemap_get_name(bmain, &wm_item->id, wm_item->id.name + 2);
+ }
+
*r_new_wm_list = *current_wm_list;
}
@@ -698,6 +705,14 @@ static void wm_file_read_post(bContext *C, const struct wmFileReadPost_Params *p
}
}
+ if (is_factory_startup && BLT_translate_new_dataname()) {
+ /* Translate workspace names */
+ LISTBASE_FOREACH_MUTABLE (WorkSpace *, workspace, &bmain->workspaces) {
+ BKE_libblock_rename(
+ bmain, &workspace->id, CTX_DATA_(BLT_I18NCONTEXT_ID_WORKSPACE, workspace->id.name + 2));
+ }
+ }
+
if (use_data) {
/* important to do before NULL'ing the context */
BKE_callback_exec_null(bmain, BKE_CB_EVT_VERSION_UPDATE);
@@ -1004,6 +1019,8 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
WM_cursor_wait(false);
+ BLI_assert(BKE_main_namemap_validate(CTX_data_main(C)));
+
return success;
}
@@ -1380,29 +1397,27 @@ void wm_homefile_read_post(struct bContext *C,
void wm_history_file_read(void)
{
- char name[FILE_MAX];
- LinkNode *l, *lines;
- struct RecentFile *recent;
- const char *line;
- int num;
const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
-
if (!cfgdir) {
return;
}
+ char name[FILE_MAX];
+ LinkNode *l;
+ int num;
+
BLI_join_dirfile(name, sizeof(name), cfgdir, BLENDER_HISTORY_FILE);
- lines = BLI_file_read_as_lines(name);
+ LinkNode *lines = BLI_file_read_as_lines(name);
wm_history_files_free();
/* read list of recent opened files from recent-files.txt to memory */
for (l = lines, num = 0; l && (num < U.recent_files); l = l->next) {
- line = l->link;
+ const char *line = l->link;
/* don't check if files exist, causes slow startup for remote/external drives */
if (line[0]) {
- recent = (RecentFile *)MEM_mallocN(sizeof(RecentFile), "RecentFile");
+ struct RecentFile *recent = (RecentFile *)MEM_mallocN(sizeof(RecentFile), "RecentFile");
BLI_addtail(&(G.recent_files), recent);
recent->filepath = BLI_strdup(line);
num++;
@@ -1765,9 +1780,11 @@ static bool wm_file_write(bContext *C,
/* Enforce full override check/generation on file save. */
BKE_lib_override_library_main_operations_create(bmain, true);
- /* NOTE: Ideally we would call `WM_redraw_windows` here to remove any open menus. But we
- * can crash if saving from a script, see T92704 & T97627. Just checking `!G.background
- * && BLI_thread_is_main()` is not sufficient to fix this. */
+ /* NOTE: Ideally we would call `WM_redraw_windows` here to remove any open menus.
+ * But we can crash if saving from a script, see T92704 & T97627.
+ * Just checking `!G.background && BLI_thread_is_main()` is not sufficient to fix this.
+ * Additionally some some EGL configurations don't support reading the front-buffer
+ * immediately after drawing, see: T98462. In that case off-screen drawing is necessary. */
/* don't forget not to return without! */
WM_cursor_wait(true);
@@ -1821,7 +1838,7 @@ static bool wm_file_write(bContext *C,
ED_editors_flush_edits(bmain);
/* XXX(ton): temp solution to solve bug, real fix coming. */
- bmain->recovered = 0;
+ bmain->recovered = false;
if (BLO_write_file(bmain,
filepath,
@@ -1880,13 +1897,10 @@ static bool wm_file_write(bContext *C,
/** \name Auto-Save API
* \{ */
-static void wm_autosave_location(char *filepath)
+static void wm_autosave_location(char filepath[FILE_MAX])
{
const int pid = abs(getpid());
char path[1024];
-#ifdef WIN32
- const char *savedir;
-#endif
/* Normally there is no need to check for this to be NULL,
* however this runs on exit when it may be cleared. */
@@ -1902,23 +1916,21 @@ static void wm_autosave_location(char *filepath)
BLI_snprintf(path, sizeof(path), "%d_autosave.blend", pid);
}
+ const char *tempdir_base = BKE_tempdir_base();
+ /* NOTE(@campbellbarton): It's strange that this is only used on WIN32.
+ * From reading commits it seems accessing the temporary directory used to be less reliable.
+ * If this is still the case on WIN32 - other features such as copy-paste will also fail.
+ * We could support #BLENDER_USER_AUTOSAVE on all platforms or remove it entirely. */
#ifdef WIN32
- /* XXX Need to investigate how to handle default location of '/tmp/'
- * This is a relative directory on Windows, and it may be
- * found. Example:
- * Blender installed on D:\ drive, D:\ drive has D:\tmp\
- * Now, BLI_exists() will find '/tmp/' exists, but
- * BLI_make_file_string will create string that has it most likely on C:\
- * through BLI_windows_get_default_root_dir().
- * If there is no C:\tmp autosave fails. */
- if (!BLI_exists(BKE_tempdir_base())) {
- savedir = BKE_appdir_folder_id_create(BLENDER_USER_AUTOSAVE, NULL);
- BLI_make_file_string("/", filepath, savedir, path);
- return;
+ if (!BLI_exists(tempdir_base)) {
+ const char *savedir = BKE_appdir_folder_id_create(BLENDER_USER_AUTOSAVE, NULL);
+ if (savedir) {
+ tempdir_base = savedir;
+ }
}
#endif
- BLI_join_dirfile(filepath, FILE_MAX, BKE_tempdir_base(), path);
+ BLI_join_dirfile(filepath, FILE_MAX, tempdir_base, path);
}
static void wm_autosave_write(Main *bmain, wmWindowManager *wm)
@@ -3003,7 +3015,9 @@ void WM_OT_recover_auto_save(wmOperatorType *ot)
static void wm_filepath_default(const Main *bmain, char *filepath)
{
if (bmain->filepath[0] == '\0') {
- BLI_path_filename_ensure(filepath, FILE_MAX, "untitled.blend");
+ char filename_untitled[FILE_MAXFILE];
+ SNPRINTF(filename_untitled, "%s.blend", DATA_("untitled"));
+ BLI_path_filename_ensure(filepath, FILE_MAX, filename_untitled);
}
}
@@ -3063,8 +3077,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
char path[FILE_MAX];
const bool is_save_as = (op->type->invoke == wm_save_as_mainfile_invoke);
- const bool use_save_as_copy = (RNA_struct_property_is_set(op->ptr, "copy") &&
- RNA_boolean_get(op->ptr, "copy"));
+ const bool use_save_as_copy = is_save_as && RNA_boolean_get(op->ptr, "copy");
/* We could expose all options to the users however in most cases remapping
* existing relative paths is a good default.
@@ -3637,7 +3650,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C,
BLI_split_file_part(blendfile_path, filename, sizeof(filename));
}
else {
- STRNCPY(filename, "untitled.blend");
+ SNPRINTF(filename, "%s.blend", DATA_("untitled"));
}
uiItemL(layout, filename, ICON_NONE);