浏览代码

frontend: Use filename stem as fallback value on empty collection name

If - for some reason - the name in a scene collection is empty (or
the key doesn't even exist), use the filename stem as a fallback name.

This ensures that the scene collection entry in the cache has a valid
non-empty name.

Using an std::string allows the use of its "empty" method to check for
this otherwise invalid state of the collection data.
PatTheMav 9 月之前
父节点
当前提交
1baa4619e4
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      frontend/widgets/OBSBasic_SceneCollections.cpp

+ 4 - 4
frontend/widgets/OBSBasic_SceneCollections.cpp

@@ -394,12 +394,12 @@ void OBSBasic::RefreshSceneCollectionCache()
 			obs_data_create_from_json_file_safe(entry.path().u8string().c_str(), "bak");
 
 		std::string candidateName;
-		const char *collectionName = obs_data_get_string(collectionData, "name");
+		std::string collectionName = obs_data_get_string(collectionData, "name");
 
-		if (!collectionName) {
-			candidateName = entry.path().filename().u8string();
+		if (collectionName.empty()) {
+			candidateName = entry.path().stem().u8string();
 		} else {
-			candidateName = collectionName;
+			candidateName = std::move(collectionName);
 		}
 
 		foundCollections.try_emplace(candidateName,