diff --git a/UI/api-interface.cpp b/UI/api-interface.cpp index 5cf9acbe148c73..ee6dae7da87d47 100644 --- a/UI/api-interface.cpp +++ b/UI/api-interface.cpp @@ -229,7 +229,7 @@ struct OBSStudioAPI : obs_frontend_callbacks { { const OBSProfile &profile = main->GetCurrentProfile(); - return bstrdup(profile.path.c_str()); + return bstrdup(profile.path.u8string().c_str()); } void obs_frontend_set_current_profile(const char *profile) override diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index e6d8798cd2d9da..f199dc09ba1cfa 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -1102,7 +1102,7 @@ OBSApp::~OBSApp() { #ifdef _WIN32 bool disableAudioDucking = - config_get_bool(globalConfig, "Audio", "DisableAudioDucking"); + config_get_bool(userConfig, "Audio", "DisableAudioDucking"); if (disableAudioDucking) DisableAudioDucking(false); #else @@ -1428,7 +1428,7 @@ bool OBSApp::OBSInit() browserHWAccel ? "true" : "false"); #endif #ifdef _WIN32 - bool hideFromCapture = config_get_bool(globalConfig, "BasicWindow", + bool hideFromCapture = config_get_bool(userConfig, "BasicWindow", "HideOBSWindowsFromCapture"); blog(LOG_INFO, "Hide OBS windows from screen capture: %s", hideFromCapture ? "true" : "false"); diff --git a/UI/platform-windows.cpp b/UI/platform-windows.cpp index 229045a64330cc..b61c2070ac0787 100644 --- a/UI/platform-windows.cpp +++ b/UI/platform-windows.cpp @@ -307,7 +307,7 @@ RunOnceMutex CheckIfAlreadyRunning(bool &already_running) char absPath[512]; *path = 0; *absPath = 0; - GetConfigPath(path, sizeof(path), ""); + GetAppConfigPath(path, sizeof(path), ""); os_get_abs_path(path, absPath, sizeof(absPath)); name = "OBSStudioPortable"; name += absPath; diff --git a/UI/window-basic-auto-config.cpp b/UI/window-basic-auto-config.cpp index 9bc6b05470c8ab..efd61d8f34a6a0 100644 --- a/UI/window-basic-auto-config.cpp +++ b/UI/window-basic-auto-config.cpp @@ -55,7 +55,7 @@ static OBSData OpenServiceSettings(std::string &type) } OBSDataAutoRelease data = obs_data_create_from_json_file_safe( - jsonFilePath.c_str(), "bak"); + jsonFilePath.u8string().c_str(), "bak"); obs_data_set_default_string(data, "type", "rtmp_common"); type = obs_data_get_string(data, "type"); diff --git a/UI/window-basic-main-outputs.cpp b/UI/window-basic-main-outputs.cpp index ca2ae58c50b863..8cdedba4aa5b9c 100644 --- a/UI/window-basic-main-outputs.cpp +++ b/UI/window-basic-main-outputs.cpp @@ -1621,8 +1621,8 @@ static OBSData GetDataFromJsonFile(const char *jsonFile) OBSDataAutoRelease data = nullptr; if (!jsonFilePath.empty()) { - BPtr jsonData = - os_quick_read_utf8_file(jsonFilePath.c_str()); + BPtr jsonData = os_quick_read_utf8_file( + jsonFilePath.u8string().c_str()); if (!!jsonData) { data = obs_data_create_from_json(jsonData); diff --git a/UI/window-basic-main-profiles.cpp b/UI/window-basic-main-profiles.cpp index 5a4780543de004..f388fbe8fb0a9a 100644 --- a/UI/window-basic-main-profiles.cpp +++ b/UI/window-basic-main-profiles.cpp @@ -79,6 +79,7 @@ void OBSBasic::SetupDuplicateProfile(const std::string &profileName) std::filesystem::copy(currentProfile.path, newProfile.path, copyOptions); } catch (const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); throw std::logic_error( "Failed to copy files for cloned profile: " + newProfile.name); @@ -104,6 +105,7 @@ void OBSBasic::SetupRenameProfile(const std::string &profileName) std::filesystem::copy(currentProfile.path, newProfile.path, copyOptions); } catch (const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); throw std::logic_error("Failed to copy files for profile: " + currentProfile.name); } @@ -167,7 +169,8 @@ const OBSProfile &OBSBasic::CreateProfile(const std::string &profileName) auto [iterator, success] = profiles.try_emplace( profileName, - OBSProfile{profileName, profileDirectoryPath.filename(), + OBSProfile{profileName, + profileDirectoryPath.filename().string(), profileDirectoryPath, profileFile}); if (api) { @@ -182,6 +185,7 @@ void OBSBasic::RemoveProfile(OBSProfile profile) try { std::filesystem::remove_all(profile.path); } catch (const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); throw std::logic_error("Failed to remove profile directory: " + profile.directoryName); } @@ -357,7 +361,7 @@ void OBSBasic::RefreshProfileCache() ConfigFile config; - if (config.Open(profileCandidate.c_str(), + if (config.Open(profileCandidate.u8string().c_str(), CONFIG_OPEN_EXISTING) != CONFIG_SUCCESS) { continue; } @@ -715,8 +719,8 @@ void OBSBasic::on_actionExportProfile_triggered() void OBSBasic::ActivateProfile(const OBSProfile &profile, bool reset) { ConfigFile config; - if (config.Open(profile.profileFile.c_str(), CONFIG_OPEN_ALWAYS) != - CONFIG_SUCCESS) { + if (config.Open(profile.profileFile.u8string().c_str(), + CONFIG_OPEN_ALWAYS) != CONFIG_SUCCESS) { throw std::logic_error( "failed to open configuration file of new profile: " + profile.profileFile.string()); diff --git a/UI/window-basic-main-scene-collections.cpp b/UI/window-basic-main-scene-collections.cpp index 4a63a2ccd15c89..30a6380f0e4cb2 100644 --- a/UI/window-basic-main-scene-collections.cpp +++ b/UI/window-basic-main-scene-collections.cpp @@ -69,13 +69,14 @@ void OBSBasic::SetupDuplicateSceneCollection(const std::string &collectionName) newCollection.collectionFile, copyOptions); } catch (const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); throw std::logic_error( "Failed to copy file for cloned scene collection: " + newCollection.name); } OBSDataAutoRelease collection = obs_data_create_from_json_file( - newCollection.collectionFile.c_str()); + newCollection.collectionFile.u8string().c_str()); obs_data_set_string(collection, "name", newCollection.name.c_str()); @@ -100,8 +101,8 @@ void OBSBasic::SetupDuplicateSceneCollection(const std::string &collectionName) } obs_data_save_json_safe(collection, - newCollection.collectionFile.c_str(), "tmp", - nullptr); + newCollection.collectionFile.u8string().c_str(), + "tmp", nullptr); ActivateSceneCollection(newCollection); @@ -127,6 +128,7 @@ void OBSBasic::SetupRenameSceneCollection(const std::string &collectionName) newCollection.collectionFile, copyOptions); } catch (const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); throw std::logic_error( "Failed to copy file for scene collection: " + currentCollection.name); @@ -135,13 +137,13 @@ void OBSBasic::SetupRenameSceneCollection(const std::string &collectionName) collections.erase(currentCollection.name); OBSDataAutoRelease collection = obs_data_create_from_json_file( - newCollection.collectionFile.c_str()); + newCollection.collectionFile.u8string().c_str()); obs_data_set_string(collection, "name", newCollection.name.c_str()); obs_data_save_json_safe(collection, - newCollection.collectionFile.c_str(), "tmp", - nullptr); + newCollection.collectionFile.u8string().c_str(), + "tmp", nullptr); ActivateSceneCollection(newCollection); RemoveSceneCollection(currentCollection); @@ -192,7 +194,7 @@ OBSBasic::CreateSceneCollection(const std::string &collectionName) auto [iterator, success] = collections.try_emplace( collectionName, OBSSceneCollection{collectionName, - collectionFilePath.filename(), + collectionFilePath.filename().string(), collectionFilePath}); return iterator->second; @@ -207,6 +209,7 @@ void OBSBasic::RemoveSceneCollection(OBSSceneCollection collection) std::filesystem::remove(collection.collectionFile); std::filesystem::remove(collectionBackupFile); } catch (const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); throw std::logic_error( "Failed to remove scene collection file: " + collection.fileName); @@ -382,7 +385,7 @@ void OBSBasic::RefreshSceneCollectionCache() OBSDataAutoRelease collectionData = obs_data_create_from_json_file_safe( - entry.path().c_str(), "bak"); + entry.path().u8string().c_str(), "bak"); std::string candidateName; const char *collectionName = @@ -624,8 +627,8 @@ void OBSBasic::on_actionExportSceneCollection_triggered() const std::filesystem::path destinationFile{ destinationFileName.toStdString()}; - OBSDataAutoRelease collection = - obs_data_create_from_json_file(sourceFile.c_str()); + OBSDataAutoRelease collection = obs_data_create_from_json_file( + sourceFile.u8string().c_str()); OBSDataArrayAutoRelease sources = obs_data_get_array(collection, "sources"); @@ -664,7 +667,8 @@ void OBSBasic::on_actionExportSceneCollection_triggered() obs_data_set_array(collection, "sources", newSources); obs_data_save_json_pretty_safe( - collection, destinationFile.c_str(), "tmp", "bak"); + collection, destinationFile.u8string().c_str(), "tmp", + "bak"); } } @@ -672,15 +676,14 @@ void OBSBasic::on_actionExportSceneCollection_triggered() void OBSBasic::ActivateSceneCollection(const OBSSceneCollection &collection) { - try { - const OBSSceneCollection ¤tCollection = - GetCurrentSceneCollection(); + const std::string currentCollectionName{config_get_string( + App()->GetUserConfig(), "Basic", "SceneCollection")}; - if (collection.name != currentCollection.name) { + if (auto foundCollection = + GetSceneCollectionByName(currentCollectionName)) { + if (collection.name != foundCollection.value().name) { SaveProjectNow(); } - } catch (const std::invalid_argument &error) { - ; } config_set_string(App()->GetUserConfig(), "Basic", "SceneCollection", @@ -688,7 +691,7 @@ void OBSBasic::ActivateSceneCollection(const OBSSceneCollection &collection) config_set_string(App()->GetUserConfig(), "Basic", "SceneCollectionFile", collection.fileName.c_str()); - Load(collection.collectionFile.c_str()); + Load(collection.collectionFile.u8string().c_str()); RefreshSceneCollections(); diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 9054558bbc0dce..51aa4ce1960390 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -1469,8 +1469,8 @@ void OBSBasic::SaveService() obs_data_set_string(data, "type", obs_service_get_type(service)); obs_data_set_obj(data, "settings", settings); - if (!obs_data_save_json_safe(data, jsonFilePath.c_str(), "tmp", - "bak")) { + if (!obs_data_save_json_safe(data, jsonFilePath.u8string().c_str(), + "tmp", "bak")) { blog(LOG_WARNING, "Failed to save service"); } } @@ -1485,8 +1485,8 @@ bool OBSBasic::LoadService() const std::filesystem::path jsonFilePath{ currentProfile.path / OBSServiceFileName.data()}; - data = obs_data_create_from_json_file_safe(jsonFilePath.c_str(), - "bak"); + data = obs_data_create_from_json_file_safe( + jsonFilePath.u8string().c_str(), "bak"); if (!data) { return false; @@ -1978,12 +1978,13 @@ bool OBSBasic::InitBasicConfig() const OBSProfile ¤tProfile = GetCurrentProfile(); int code = activeConfiguration.Open( - currentProfile.profileFile.c_str(), CONFIG_OPEN_ALWAYS); + currentProfile.profileFile.u8string().c_str(), + CONFIG_OPEN_ALWAYS); if (code != CONFIG_SUCCESS) { OBSErrorBox(NULL, "Failed to open basic.ini: %d", code); return false; } - } catch (const std::invalid_argument &error) { + } catch (const std::invalid_argument &) { const std::string_view profileDirectory{config_get_string( App()->GetUserConfig(), "Basic", "ProfileDir")}; @@ -2002,6 +2003,7 @@ bool OBSBasic::InitBasicConfig() profilePath); } catch ( const std::filesystem::filesystem_error &error) { + blog(LOG_DEBUG, "%s", error.what()); OBSErrorBox(nullptr, "Failed to create profile path"); return false; @@ -2016,8 +2018,8 @@ bool OBSBasic::InitBasicConfig() return false; } - int code = activeConfiguration.Open(userProfileFile.c_str(), - CONFIG_OPEN_ALWAYS); + int code = activeConfiguration.Open( + userProfileFile.u8string().c_str(), CONFIG_OPEN_ALWAYS); if (code != CONFIG_SUCCESS) { OBSErrorBox(NULL, "Failed to open basic.ini: %d", code); return false; @@ -2345,7 +2347,7 @@ void OBSBasic::OBSInit() const OBSSceneCollection ¤tCollection = GetCurrentSceneCollection(); ActivateSceneCollection(currentCollection); - } catch (const std::invalid_argument &error) { + } catch (const std::invalid_argument &) { const std::string collectionName = config_get_string(App()->GetUserConfig(), "Basic", "SceneCollection"); @@ -3285,7 +3287,7 @@ void OBSBasic::SaveProjectDeferred() const OBSSceneCollection ¤tCollection = GetCurrentSceneCollection(); - Save(currentCollection.collectionFile.c_str()); + Save(currentCollection.collectionFile.u8string().c_str()); } catch (const std::invalid_argument &error) { blog(LOG_ERROR, "%s", error.what()); } @@ -4230,14 +4232,14 @@ void OBSBasic::TimedCheckForUpdates() #if defined(ENABLE_SPARKLE_UPDATER) CheckForUpdates(false); #elif _WIN32 - long long lastUpdate = config_get_int(App()->GlobalConfig(), "General", + long long lastUpdate = config_get_int(App()->GetAppConfig(), "General", "LastUpdateCheck"); uint32_t lastVersion = - config_get_int(App()->GlobalConfig(), "General", "LastVersion"); + config_get_int(App()->GetAppConfig(), "General", "LastVersion"); if (lastVersion < LIBOBS_API_VER) { lastUpdate = 0; - config_set_int(App()->GlobalConfig(), "General", + config_set_int(App()->GetAppConfig(), "General", "LastUpdateCheck", 0); } @@ -7352,7 +7354,7 @@ void OBSBasic::SetupBroadcast() #ifdef _WIN32 static inline void UpdateProcessPriority() { - const char *priority = config_get_string(App()->GlobalConfig(), + const char *priority = config_get_string(App()->GetAppConfig(), "General", "ProcessPriority"); if (priority && strcmp(priority, "Normal") != 0) SetProcessPriority(priority); @@ -7360,7 +7362,7 @@ static inline void UpdateProcessPriority() static inline void ClearProcessPriority() { - const char *priority = config_get_string(App()->GlobalConfig(), + const char *priority = config_get_string(App()->GetAppConfig(), "General", "ProcessPriority"); if (priority && strcmp(priority, "Normal") != 0) SetProcessPriority("Normal"); diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 0f582a3964d8ae..a869a7e1bfe611 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -1400,7 +1400,7 @@ void OBSBasicSettings::LoadGeneralSettings() #if defined(_WIN32) if (ui->hideOBSFromCapture) { bool hideWindowFromCapture = - config_get_bool(GetGlobalConfig(), "BasicWindow", + config_get_bool(App()->GetUserConfig(), "BasicWindow", "HideOBSWindowsFromCapture"); ui->hideOBSFromCapture->setChecked(hideWindowFromCapture); @@ -1595,7 +1595,7 @@ void OBSBasicSettings::LoadRendererList() { #ifdef _WIN32 const char *renderer = - config_get_string(GetGlobalConfig(), "Video", "Renderer"); + config_get_string(App()->GetUserConfig(), "Video", "Renderer"); ui->renderer->addItem(QT_UTF8("Direct3D 11")); if (opt_allow_opengl || strcmp(renderer, "OpenGL") == 0) @@ -2145,7 +2145,7 @@ OBSBasicSettings::CreateEncoderPropertyView(const char *encoder, if (!jsonFilePath.empty()) { obs_data_t *data = obs_data_create_from_json_file_safe( - jsonFilePath.c_str(), "bak"); + jsonFilePath.u8string().c_str(), "bak"); obs_data_apply(settings, data); obs_data_release(data); } @@ -2986,11 +2986,11 @@ void OBSBasicSettings::LoadAdvancedSettings() ui->resetOSXVSync->setEnabled(disableOSXVSync); #elif _WIN32 bool disableAudioDucking = config_get_bool( - App()->GlobalConfig(), "Audio", "DisableAudioDucking"); + App()->GetUserConfig(), "Audio", "DisableAudioDucking"); ui->disableAudioDucking->setChecked(disableAudioDucking); const char *processPriority = config_get_string( - App()->GlobalConfig(), "General", "ProcessPriority"); + App()->GetAppConfig(), "General", "ProcessPriority"); bool enableNewSocketLoop = config_get_bool(main->Config(), "Output", "NewSocketLoopEnable"); bool enableLowLatencyMode = @@ -3622,12 +3622,12 @@ void OBSBasicSettings::SaveAdvancedSettings() #ifdef _WIN32 if (WidgetChanged(ui->renderer)) - config_set_string(App()->GlobalConfig(), "Video", "Renderer", + config_set_string(App()->GetUserConfig(), "Video", "Renderer", QT_TO_UTF8(ui->renderer->currentText())); std::string priority = QT_TO_UTF8(ui->processPriority->currentData().toString()); - config_set_string(App()->GlobalConfig(), "General", "ProcessPriority", + config_set_string(App()->GetAppConfig(), "General", "ProcessPriority", priority.c_str()); if (main->Active()) SetProcessPriority(priority.c_str()); @@ -3675,7 +3675,7 @@ void OBSBasicSettings::SaveAdvancedSettings() #ifdef _WIN32 if (WidgetChanged(ui->disableAudioDucking)) { bool disable = ui->disableAudioDucking->isChecked(); - config_set_bool(App()->GlobalConfig(), "Audio", + config_set_bool(App()->GetUserConfig(), "Audio", "DisableAudioDucking", disable); DisableAudioDucking(disable); } @@ -3758,7 +3758,8 @@ static void WriteJsonData(OBSPropertiesView *view, const char *path) if (!jsonFilePath.empty()) { obs_data_t *settings = view->GetSettings(); if (settings) { - obs_data_save_json_safe(settings, jsonFilePath.c_str(), + obs_data_save_json_safe(settings, + jsonFilePath.u8string().c_str(), "tmp", "bak"); } } @@ -5693,7 +5694,7 @@ void OBSBasicSettings::AdvReplayBufferChanged() if (!jsonFilePath.empty()) { OBSDataAutoRelease data = obs_data_create_from_json_file_safe( - jsonFilePath.c_str(), "bak"); + jsonFilePath.u8string().c_str(), "bak"); obs_data_apply(settings, data); } }