Просмотр исходного кода

chore: treat null values as optionals too instead of crashing

Almamu 11 месяцев назад
Родитель
Сommit
1f278468a8

+ 3 - 3
src/WallpaperEngine/Data/JSON.h

@@ -82,7 +82,7 @@ class JsonExtensions {
         const auto it = base.find (key);
         auto result = std::optional<base_type> {};
 
-        if (it != base.end ()) {
+        if (it != base.end () && !it->is_null ()) {
             result.emplace (*it);
         }
 
@@ -93,7 +93,7 @@ class JsonExtensions {
         auto base = this->base ();
         const auto it = base.find (key);
 
-        if (it == base.end ()) {
+        if (it == base.end () || it->is_null ()) {
             return std::nullopt;
         }
 
@@ -104,7 +104,7 @@ class JsonExtensions {
         auto base = this->base ();
         const auto it = base.find (key);
 
-        if (it == base.end ()) {
+        if (it == base.end () || it->is_null ()) {
             return defaultValue;
         }
 

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

@@ -58,7 +58,7 @@ ObjectUniquePtr ObjectParser::parse (const JSON& it, const Project& project) {
         sLog.error ("Light objects are not supported yet");
     } else {
         // dump the object for now, might want to change later
-        sLog.exception ("Unknown object type found: ", it.dump ());
+        sLog.error ("Unknown object type found: ", it.dump ());
     }
 
     return std::make_unique <Object> (basedata);