LibGUI: Don't silently create a 0 UIDimension when the JSON is invalid

The function already can report an invalid JSON value for the dimension,
so let's actually use that for when the number is too large or some
other invalid JSON type, like an object or a boolean, was passed.
This commit is contained in:
kleines Filmröllchen 2023-02-18 12:11:56 +01:00 committed by Jelle Raaijmakers
commit d385adf6bd
Notes: sideshowbarker 2024-07-16 22:18:54 +09:00

View file

@ -162,12 +162,13 @@ public:
return UIDimension { SpecialDimension::Fit };
else
return {};
} else {
int value_int = value.to_i32();
} else if (value.is_integer<i32>()) {
auto value_int = value.as_integer<i32>();
if (value_int < 0)
return {};
return UIDimension(value_int);
}
return {};
}
private: