|
@@ -88,6 +88,38 @@ static bool SceneCollectionExists(const char *findName)
|
|
|
return found;
|
|
|
}
|
|
|
|
|
|
+static bool GetUnusedSceneCollectionFile(std::string &name, std::string &file)
|
|
|
+{
|
|
|
+ char path[512];
|
|
|
+ size_t len;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ if (!GetFileSafeName(name.c_str(), file)) {
|
|
|
+ blog(LOG_WARNING, "Failed to create safe file name for '%s'",
|
|
|
+ name.c_str());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/scenes/");
|
|
|
+ if (ret <= 0) {
|
|
|
+ blog(LOG_WARNING, "Failed to get scene collection config path");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ len = file.size();
|
|
|
+ file.insert(0, path);
|
|
|
+
|
|
|
+ if (!GetClosestUnusedFileName(file, "json")) {
|
|
|
+ blog(LOG_WARNING, "Failed to get closest file name for %s",
|
|
|
+ file.c_str());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ file.erase(file.size() - 5, 5);
|
|
|
+ file.erase(0, file.size() - len);
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
|
|
std::string &file,
|
|
|
const char *oldName = nullptr)
|
|
@@ -95,9 +127,6 @@ static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
|
|
bool rename = oldName != nullptr;
|
|
|
const char *title;
|
|
|
const char *text;
|
|
|
- char path[512];
|
|
|
- size_t len;
|
|
|
- int ret;
|
|
|
|
|
|
if (rename) {
|
|
|
title = Str("Basic.Main.RenameSceneCollection.Title");
|
|
@@ -128,29 +157,10 @@ static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (!GetFileSafeName(name.c_str(), file)) {
|
|
|
- blog(LOG_WARNING, "Failed to create safe file name for '%s'",
|
|
|
- name.c_str());
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/scenes/");
|
|
|
- if (ret <= 0) {
|
|
|
- blog(LOG_WARNING, "Failed to get scene collection config path");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- len = file.size();
|
|
|
- file.insert(0, path);
|
|
|
-
|
|
|
- if (!GetClosestUnusedFileName(file, "json")) {
|
|
|
- blog(LOG_WARNING, "Failed to get closest file name for %s",
|
|
|
- file.c_str());
|
|
|
+ if (!GetUnusedSceneCollectionFile(name, file)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- file.erase(file.size() - 5, 5);
|
|
|
- file.erase(0, file.size() - len);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -166,6 +176,10 @@ bool OBSBasic::AddSceneCollection(bool create_new, const QString &qname)
|
|
|
name = QT_TO_UTF8(qname);
|
|
|
if (SceneCollectionExists(name.c_str()))
|
|
|
return false;
|
|
|
+
|
|
|
+ if (!GetUnusedSceneCollectionFile(name, file)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
SaveProjectNow();
|