Explorar o código

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 hai 9 meses
pai
achega
1baa4619e4
Modificáronse 1 ficheiros con 4 adicións e 4 borrados
  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,