1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 01:51:03 +09:00

Maps: Add massage_for_display for lat and long

This prevents a crash when attempting to add a
favorite or load favorites list in Maps application
This commit is contained in:
Brendan Kelly 2024-01-29 11:15:15 -05:00 committed by Sam Atkins
parent 69964e10f4
commit 00ab8e0a14
Notes: sideshowbarker 2024-07-16 21:51:02 +09:00

View file

@ -61,8 +61,12 @@ void FavoritesPanel::load_favorites()
double longitude = object.get_double_with_precision_loss("longitude"sv).release_value();
return ByteString::formatted("{}\n{:.5}, {:.5}", name, latitude, longitude);
});
favorites_fields.empend("latitude", "Latitude"_string, Gfx::TextAlignment::CenterLeft);
favorites_fields.empend("longitude", "Longitude"_string, Gfx::TextAlignment::CenterLeft);
favorites_fields.empend("latitude", "Latitude"_string, Gfx::TextAlignment::CenterLeft, [](JsonObject const& object) -> GUI::Variant {
return object.get_double_with_precision_loss("latitude"sv).release_value();
});
favorites_fields.empend("longitude", "Longitude"_string, Gfx::TextAlignment::CenterLeft, [](JsonObject const& object) -> GUI::Variant {
return object.get_double_with_precision_loss("longitude"sv).release_value();
});
favorites_fields.empend("zoom", "Zoom"_string, Gfx::TextAlignment::CenterLeft);
m_favorites_list->set_model(*GUI::JsonArrayModel::create(ByteString::formatted("{}/MapsFavorites.json", Core::StandardPaths::config_directory()), move(favorites_fields)));
m_favorites_list->model()->invalidate();
@ -136,11 +140,12 @@ void FavoritesPanel::favorites_changed()
m_favorites_list->set_visible(model.row_count() > 0);
Vector<Favorite> favorites;
for (int index = 0; index < model.row_count(); index++)
for (int index = 0; index < model.row_count(); index++) {
favorites.append({ MUST(String::from_byte_string(model.index(index, 0).data().to_byte_string())),
{ model.index(index, 1).data().as_double(),
model.index(index, 2).data().as_double() },
model.index(index, 3).data().to_i32() });
}
on_favorites_change(favorites);
}