From 73c1b1617a2e538dee6c49dd04ad2601a7544b45 Mon Sep 17 00:00:00 2001 From: Timothy Date: Tue, 3 Aug 2021 22:05:07 +1000 Subject: [PATCH] Everywhere: Replace most cases of exit() with Application::quit() Application::quit() is nicer for most cases where exit() is used. Cases where exit() is used intentionally for early termination are left intact. --- Userland/Applications/Assistant/main.cpp | 6 +++--- Userland/Applications/IRCClient/IRCAppWindow.cpp | 6 ++++-- Userland/Demos/Screensaver/Screensaver.cpp | 6 +++--- Userland/Demos/Starfield/Starfield.cpp | 4 ++-- .../Services/FileSystemAccessServer/ClientConnection.cpp | 1 - 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 703d843aa9..e68bfa8d03 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -250,7 +250,7 @@ int main(int argc, char** argv) if (!app_state.selected_index.has_value()) return; app_state.results[app_state.selected_index.value()].activate(); - exit(0); + GUI::Application::the()->quit(); }; text_box.on_up_pressed = [&]() { if (!app_state.visible_result_count) @@ -278,7 +278,7 @@ int main(int argc, char** argv) mark_selected_item(); }; text_box.on_escape_pressed = []() { - exit(0); + GUI::Application::the()->quit(); }; db.on_new_results = [&](auto results) { @@ -298,7 +298,7 @@ int main(int argc, char** argv) match.set_subtitle(result.subtitle()); match.on_selected = [&result]() { result.activate(); - exit(0); + GUI::Application::the()->quit(); }; } diff --git a/Userland/Applications/IRCClient/IRCAppWindow.cpp b/Userland/Applications/IRCClient/IRCAppWindow.cpp index 6f762f2eb0..3916467b52 100644 --- a/Userland/Applications/IRCClient/IRCAppWindow.cpp +++ b/Userland/Applications/IRCClient/IRCAppWindow.cpp @@ -73,8 +73,10 @@ void IRCAppWindow::setup_client() if (m_client->hostname().is_empty()) { String value; - if (GUI::InputBox::show(this, value, "Enter server:", "Connect to server") == GUI::InputBox::ExecCancel) - ::exit(0); + if (GUI::InputBox::show(this, value, "Enter server:", "Connect to server") == GUI::InputBox::ExecCancel) { + GUI::Application::the()->quit(); + return; + } m_client->set_server(value, 6667); } diff --git a/Userland/Demos/Screensaver/Screensaver.cpp b/Userland/Demos/Screensaver/Screensaver.cpp index 1ee8e3e31f..0c09f03c0c 100644 --- a/Userland/Demos/Screensaver/Screensaver.cpp +++ b/Userland/Demos/Screensaver/Screensaver.cpp @@ -52,18 +52,18 @@ void Screensaver::mousemove_event(GUI::MouseEvent& event) if (m_mouse_origin.is_null()) { m_mouse_origin = event.position(); } else if (event.position().distance_from(m_mouse_origin) > max_distance_move) { - ::exit(0); + GUI::Application::the()->quit(); } } void Screensaver::mousedown_event(GUI::MouseEvent&) { - ::exit(0); + GUI::Application::the()->quit(); } void Screensaver::keydown_event(GUI::KeyEvent&) { - ::exit(0); + GUI::Application::the()->quit(); } void Screensaver::paint_event(GUI::PaintEvent& event) diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index 3dbb98ac02..aabc130225 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -79,12 +79,12 @@ void Starfield::mousemove_event(GUI::MouseEvent&) void Starfield::mousedown_event(GUI::MouseEvent&) { - ::exit(0); + GUI::Application::the()->quit(); } void Starfield::keydown_event(GUI::KeyEvent&) { - ::exit(0); + GUI::Application::the()->quit(); } void Starfield::paint_event(GUI::PaintEvent& event) diff --git a/Userland/Services/FileSystemAccessServer/ClientConnection.cpp b/Userland/Services/FileSystemAccessServer/ClientConnection.cpp index 2a5939a590..aa697f672c 100644 --- a/Userland/Services/FileSystemAccessServer/ClientConnection.cpp +++ b/Userland/Services/FileSystemAccessServer/ClientConnection.cpp @@ -34,7 +34,6 @@ void ClientConnection::die() { s_connections.remove(client_id()); GUI::Application::the()->quit(); - exit(0); } RefPtr ClientConnection::create_dummy_child_window(i32 window_server_client_id, i32 parent_window_id)