Ver Fonte

fix: don't treat "particle": "None" on text objects as a particle system (#692)

Some scenes' text objects carry "particle": "None" (Workshop 1315534440,
"[4K] RetroLake", has four clock text objects like that). ObjectParser::parse
dispatched any object with a "particle" key to parseParticle, which tried to
load a particle file called "None", got no material, and CParticle's
constructor then dereferenced the null material and segfaulted while the
scene loaded.

Only an inline definition or a non-empty path other than "None" now counts
as a particle system, so those objects reach parseText. CScene also skips a
particle system whose material failed to load instead of crashing on it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Greg Gage há 1 mês atrás
pai
commit
eff5d740e6

+ 7 - 1
src/WallpaperEngine/Data/Parsers/ObjectParser.cpp

@@ -25,6 +25,12 @@ ObjectUniquePtr ObjectParser::parse (const JSON& it, const Project& project) {
     const auto lightIt = it.find ("light");
     // use shape to refer to VolumeLight
     const auto shapeIt = it.find ("shape");
+    // Only an inline definition or a file path is a particle system; other objects (text
+    // objects, for example) can carry a placeholder like "particle": "None".
+    const bool hasParticle = particleIt != it.end ()
+	&& (particleIt->is_object ()
+	    || (particleIt->is_string () && !particleIt->get<std::string> ().empty ()
+		&& particleIt->get<std::string> () != "None"));
 
     // Parse base object data
     // Some particle objects have numeric 'name' fields, so handle type mismatches gracefully
@@ -69,7 +75,7 @@ ObjectUniquePtr ObjectParser::parse (const JSON& it, const Project& project) {
 	return parseImage (it, project, std::move (basedata), *imageIt);
     } else if (soundIt != it.end () && soundIt->is_array ()) {
 	return parseSound (it, std::move (basedata));
-    } else if (particleIt != it.end ()) {
+    } else if (hasParticle) {
 	return parseParticle (it, project, std::move (basedata));
     } else if (textIt != it.end ()) {
 	return parseText (it, project, std::move (basedata));

+ 5 - 0
src/WallpaperEngine/Render/Wallpapers/CScene.cpp

@@ -242,6 +242,11 @@ Render::CObject* CScene::dispatchObjectType (const Object& object) {
 	    return nullptr;
 	}
 
+	if (particleData.material == nullptr || particleData.material->material == nullptr) {
+	    sLog.error ("Ignoring particle system without a material: ", particleData.name);
+	    return nullptr;
+	}
+
 	renderObject = new Objects::CParticle (*this, particleData);
     } else {
 	sLog.error ("Unknown object type, creating placeholder, empty object: ", object.id);