From 609334e427a58608f8a44570b3091c8543049c8d Mon Sep 17 00:00:00 2001 From: Michel Date: Thu, 13 Jul 2017 18:55:30 +0200 Subject: [PATCH] UI: Fix problem with exporting scene collections/profiles When exporting scene collections/profiles existing files are not overwritten. Closes jp9000/obs-studio#963 --- UI/window-basic-main-profiles.cpp | 29 ++++++++++++++++------ UI/window-basic-main-scene-collections.cpp | 6 ++++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/UI/window-basic-main-profiles.cpp b/UI/window-basic-main-profiles.cpp index 7c5d426d4..54f6060bd 100644 --- a/UI/window-basic-main-profiles.cpp +++ b/UI/window-basic-main-profiles.cpp @@ -524,15 +524,28 @@ void OBSBasic::on_actionExportProfile_triggered() if (!folder.exists()) { folder.mkpath(outputDir); - QFile::copy(inputPath + currentProfile + "/basic.ini", - outputDir + "/basic.ini"); - QFile::copy(inputPath + currentProfile + "/service.json", - outputDir + "/service.json"); - QFile::copy(inputPath + currentProfile + "/streamEncoder.json", - outputDir + "/streamEncoder.json"); - QFile::copy(inputPath + currentProfile + "/recordEncoder.json", - outputDir + "/recordEncoder.json"); + } else { + if (QFile::exists(outputDir + "/basic.ini")) + QFile::remove(outputDir + "/basic.ini"); + + if (QFile::exists(outputDir + "/service.json")) + QFile::remove(outputDir + "/service.json"); + + if (QFile::exists(outputDir + "/streamEncoder.json")) + QFile::remove(outputDir + "/streamEncoder.json"); + + if (QFile::exists(outputDir + "/recordEncoder.json")) + QFile::remove(outputDir + "/recordEncoder.json"); } + + QFile::copy(inputPath + currentProfile + "/basic.ini", + outputDir + "/basic.ini"); + QFile::copy(inputPath + currentProfile + "/service.json", + outputDir + "/service.json"); + QFile::copy(inputPath + currentProfile + "/streamEncoder.json", + outputDir + "/streamEncoder.json"); + QFile::copy(inputPath + currentProfile + "/recordEncoder.json", + outputDir + "/recordEncoder.json"); } } diff --git a/UI/window-basic-main-scene-collections.cpp b/UI/window-basic-main-scene-collections.cpp index 088fb7013..067c7b7a4 100644 --- a/UI/window-basic-main-scene-collections.cpp +++ b/UI/window-basic-main-scene-collections.cpp @@ -425,8 +425,12 @@ void OBSBasic::on_actionExportSceneCollection_triggered() string file = QT_TO_UTF8(exportFile); - if (!exportFile.isEmpty() && !exportFile.isNull()) + if (!exportFile.isEmpty() && !exportFile.isNull()) { + if (QFile::exists(exportFile)) + QFile::remove(exportFile); + QFile::copy(path + currentFile + ".json", exportFile); + } } void OBSBasic::ChangeSceneCollection()