diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-11-26 17:11:12 -0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-27 11:24:31 +0100 |
commit | 72e9d024b927032488caf146a853882692a08cd7 (patch) | |
tree | 2bd35834a3efd5e32fb0e4c6cb66a55c929b1f8e /Userland/Applications/Settings/main.cpp | |
parent | f25466ae08b3d5cab205cc41ffe963007b244dd0 (diff) | |
download | serenity-72e9d024b927032488caf146a853882692a08cd7.zip |
Settings: Fix launch of settings dialog
There was a bug report on discord where someone mentioned that
launching the keyboard settings always crashed. When looking
at the backtrace it became clear we were calling down the
`AppFile::executable()` path on uninitialized memory.
We can fix this by using the "official" API for obtaining data
from the GUI ModelIndex, instead of casting random memory to
the object type we expect it to be. :^)
Validated this fixes the issue for me locally.
Diffstat (limited to 'Userland/Applications/Settings/main.cpp')
-rw-r--r-- | Userland/Applications/Settings/main.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Userland/Applications/Settings/main.cpp b/Userland/Applications/Settings/main.cpp index 7d8aff87dd..15795d1835 100644 --- a/Userland/Applications/Settings/main.cpp +++ b/Userland/Applications/Settings/main.cpp @@ -104,8 +104,7 @@ int main(int argc, char** argv) icon_view.set_model(*model); icon_view.on_activation = [&](GUI::ModelIndex const& index) { - auto& app = *(Desktop::AppFile*)index.internal_data(); - auto executable = app.executable(); + auto executable = model->data(index, GUI::ModelRole::Custom).as_string(); auto launch_origin_rect = icon_view.to_widget_rect(icon_view.content_rect(index)).translated(icon_view.screen_relative_rect().location()); setenv("__libgui_launch_origin_rect", String::formatted("{},{},{},{}", launch_origin_rect.x(), launch_origin_rect.y(), launch_origin_rect.width(), launch_origin_rect.height()).characters(), 1); |