Skip to content

Commit

Permalink
Everywhere: Replace most cases of exit() with Application::quit()
Browse files Browse the repository at this point in the history
Application::quit() is nicer for most cases where exit() is used. Cases
where exit() is used intentionally for early termination are left
intact.
  • Loading branch information
timmot authored and awesomekling committed Aug 3, 2021
1 parent 2caafac commit 73c1b16
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Userland/Applications/Assistant/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
};
}

Expand Down
6 changes: 4 additions & 2 deletions Userland/Applications/IRCClient/IRCAppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions Userland/Demos/Screensaver/Screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Userland/Demos/Starfield/Starfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void ClientConnection::die()
{
s_connections.remove(client_id());
GUI::Application::the()->quit();
exit(0);
}

RefPtr<GUI::Window> ClientConnection::create_dummy_child_window(i32 window_server_client_id, i32 parent_window_id)
Expand Down

0 comments on commit 73c1b16

Please sign in to comment.