Skip to content

Commit e6aeca0

Browse files
committed
frontend: Use default location for user settings as fallback
When a unique path is set up as the location for user settings, profiles, or scene collections, migrating the files from one computer to another will lead to confusing error messages as the original paths might not exist on the new machine. The default directories for configuration files are already created by this point, so using those paths as a fallback should enable OBS Studio to also create the corresponding fallback settings files.
1 parent f8d2bfe commit e6aeca0

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

frontend/OBSApp.cpp

+25-10
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ bool OBSApp::InitGlobalConfig()
431431

432432
uint32_t lastVersion = config_get_int(appConfig, "General", "LastVersion");
433433

434-
if (lastVersion < MAKE_SEMANTIC_VERSION(31, 0, 0)) {
434+
if (lastVersion && lastVersion < MAKE_SEMANTIC_VERSION(31, 0, 0)) {
435435
bool migratedUserSettings = config_get_bool(appConfig, "General", "Pre31Migrated");
436436

437437
if (!migratedUserSettings) {
@@ -445,19 +445,34 @@ bool OBSApp::InitGlobalConfig()
445445
InitGlobalConfigDefaults();
446446
InitGlobalLocationDefaults();
447447

448+
std::filesystem::path defaultUserConfigLocation =
449+
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Configuration"));
450+
std::filesystem::path defaultUserScenesLocation =
451+
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "SceneCollections"));
452+
std::filesystem::path defaultUserProfilesLocation =
453+
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Profiles"));
454+
448455
if (IsPortableMode()) {
449-
userConfigLocation =
450-
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Configuration"));
451-
userScenesLocation =
452-
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "SceneCollections"));
453-
userProfilesLocation =
454-
std::filesystem::u8path(config_get_default_string(appConfig, "Locations", "Profiles"));
456+
userConfigLocation = std::move(defaultUserConfigLocation);
457+
userScenesLocation = std::move(defaultUserScenesLocation);
458+
userProfilesLocation = std::move(defaultUserProfilesLocation);
455459
} else {
456-
userConfigLocation =
460+
std::filesystem::path currentUserConfigLocation =
457461
std::filesystem::u8path(config_get_string(appConfig, "Locations", "Configuration"));
458-
userScenesLocation =
462+
std::filesystem::path currentUserScenesLocation =
459463
std::filesystem::u8path(config_get_string(appConfig, "Locations", "SceneCollections"));
460-
userProfilesLocation = std::filesystem::u8path(config_get_string(appConfig, "Locations", "Profiles"));
464+
std::filesystem::path currentUserProfilesLocation =
465+
std::filesystem::u8path(config_get_string(appConfig, "Locations", "Profiles"));
466+
467+
userConfigLocation = (std::filesystem::exists(currentUserConfigLocation))
468+
? std::move(currentUserConfigLocation)
469+
: std::move(defaultUserConfigLocation);
470+
userScenesLocation = (std::filesystem::exists(currentUserScenesLocation))
471+
? std::move(currentUserScenesLocation)
472+
: std::move(defaultUserScenesLocation);
473+
userProfilesLocation = (std::filesystem::exists(currentUserProfilesLocation))
474+
? std::move(currentUserProfilesLocation)
475+
: std::move(defaultUserProfilesLocation);
461476
}
462477

463478
bool userConfigResult = InitUserConfig(userConfigLocation, lastVersion);

0 commit comments

Comments
 (0)