diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 18:34:06 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 18:34:06 +0200 |
commit | 7584480f628c878e107bf66770e988bedb8cd6c5 (patch) | |
tree | 29e922c758183698ccf7f7653f6a1174ac53a95b | |
parent | 70412c7d4f5f6f55bfb0cf9409463b19f27c632a (diff) | |
download | serenity-7584480f628c878e107bf66770e988bedb8cd6c5.zip |
LibGUI: Convert GWindow to ObjectPtr
25 files changed, 37 insertions, 37 deletions
diff --git a/Applications/About/main.cpp b/Applications/About/main.cpp index e14e07d330..803593c090 100644 --- a/Applications/About/main.cpp +++ b/Applications/About/main.cpp @@ -10,7 +10,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("About Serenity"); Rect window_rect { 0, 0, 240, 150 }; window_rect.center_within(GDesktop::the().rect()); diff --git a/Applications/Calculator/main.cpp b/Applications/Calculator/main.cpp index 082dacb9e8..9e7208a293 100644 --- a/Applications/Calculator/main.cpp +++ b/Applications/Calculator/main.cpp @@ -6,7 +6,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Calculator"); window->set_resizable(false); window->set_rect({ 300, 200, 254, 213 }); diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp index 095710f270..9ebda060c9 100644 --- a/Applications/ChanViewer/main.cpp +++ b/Applications/ChanViewer/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("ChanViewer"); window->set_rect(100, 100, 800, 500); window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png")); diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 363cd0b878..7ac0d0a8f0 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("File Manager"); window->set_rect(20, 200, 640, 480); diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index 93f74eee70..d8799c4279 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char** argv) else edited_font = Font::default_font().clone(); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Font Editor"); window->set_rect({ 50, 50, 390, 342 }); auto* font_editor = new FontEditorWidget(path, move(edited_font)); diff --git a/Applications/Launcher/main.cpp b/Applications/Launcher/main.cpp index 857b4f0356..51aea7ea1c 100644 --- a/Applications/Launcher/main.cpp +++ b/Applications/Launcher/main.cpp @@ -12,7 +12,7 @@ #include <sys/wait.h> #include <unistd.h> -static GWindow* make_launcher_window(); +static ObjectPtr<GWindow> make_launcher_window(); void handle_sigchld(int) { @@ -31,7 +31,7 @@ int main(int argc, char** argv) signal(SIGCHLD, handle_sigchld); - auto* launcher_window = make_launcher_window(); + auto launcher_window = make_launcher_window(); launcher_window->show(); return app.exec(); @@ -63,12 +63,12 @@ private: String m_executable_path; }; -GWindow* make_launcher_window() +ObjectPtr<GWindow> make_launcher_window() { auto config = CConfigFile::get_for_app("Launcher"); auto vertical = config->read_bool_entry("Launcher", "Vertical", true); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Launcher"); int launcher_size = (config->groups().size() - 1) * 50; window->set_rect(50, 50, vertical ? 50 : launcher_size, vertical ? launcher_size : 50); diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index 60bea29517..453da4a42c 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -15,7 +15,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("PaintBrush"); window->set_rect(100, 100, 640, 480); diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index 21d896f0d6..22699a1ada 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -17,7 +17,7 @@ int main(int argc, char** argv) AClientConnection audio_connection; audio_connection.handshake(); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Piano"); window->set_rect(100, 100, 512, 512); diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index b8097d62e1..22cadbb3a7 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -50,7 +50,7 @@ int main(int argc, char** argv) return 1; } - auto* window = new GWindow; + auto window = GWindow::construct(); auto update_window_title = [&](int scale) { window->set_title(String::format("QuickShow: %s %s %d%%", path, bitmap->size().to_string().characters(), scale)); diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp index e5a2c95188..26a64f42d5 100644 --- a/Applications/SoundPlayer/main.cpp +++ b/Applications/SoundPlayer/main.cpp @@ -30,7 +30,7 @@ int main(int argc, char** argv) AClientConnection audio_client; audio_client.handshake(); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("SoundPlayer"); window->set_rect(300, 300, 300, 200); diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 55971ad5e1..bec782c3dc 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -88,9 +88,9 @@ static void run_command(int ptm_fd, String command) } } -GWindow* create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> config) +ObjectPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> config) { - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Terminal Settings"); window->set_rect(50, 50, 200, 140); @@ -156,7 +156,7 @@ int main(int argc, char** argv) run_command(ptm_fd, args.get("e")); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Terminal"); window->set_background_color(Color::Black); window->set_double_buffering_enabled(false); @@ -170,7 +170,7 @@ int main(int argc, char** argv) window->set_icon(load_png("/res/icons/16x16/app-terminal.png")); terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false)); - WeakPtr<GWindow> settings_window; + ObjectPtr<GWindow> settings_window; auto new_opacity = config->read_num_entry("Window", "Opacity", 255); terminal->set_opacity(new_opacity); @@ -180,9 +180,9 @@ int main(int argc, char** argv) auto app_menu = make<GMenu>("Terminal"); app_menu->add_action(GAction::create("Settings...", load_png("/res/icons/gear16.png"), - [&settings_window, terminal, &config](const GAction&) { + [&](const GAction&) { if (!settings_window) - settings_window = create_settings_window(*terminal, config)->make_weak_ptr(); + settings_window = create_settings_window(*terminal, config); settings_window->show(); settings_window->move_to_front(); })); diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp index 80f7925da2..66d4699f17 100644 --- a/Applications/TextEditor/main.cpp +++ b/Applications/TextEditor/main.cpp @@ -5,7 +5,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Text Editor"); window->set_rect(20, 200, 640, 400); diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp index 85608ce286..e126f8dc16 100644 --- a/Applications/Welcome/main.cpp +++ b/Applications/Welcome/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char** argv) GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Welcome to Serenity"); Rect window_rect { 0, 0, 640, 360 }; window_rect.center_within(GDesktop::the().rect()); diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index 2714f40240..acf7119e79 100644 --- a/Demos/Fire/Fire.cpp +++ b/Demos/Fire/Fire.cpp @@ -214,7 +214,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_double_buffering_enabled(false); window->set_title("Fire"); window->set_resizable(false); diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index e460ca0cb3..f8f8f1c78f 100644 --- a/Demos/HelloWorld/main.cpp +++ b/Demos/HelloWorld/main.cpp @@ -9,7 +9,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_rect(100, 100, 240, 160); window->set_title("Hello World!"); diff --git a/Demos/HelloWorld2/main.cpp b/Demos/HelloWorld2/main.cpp index 1d3830c17c..bc0cf7727e 100644 --- a/Demos/HelloWorld2/main.cpp +++ b/Demos/HelloWorld2/main.cpp @@ -10,7 +10,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_rect(100, 100, 240, 160); window->set_title("Hello World!"); diff --git a/Demos/PaintTest/main.cpp b/Demos/PaintTest/main.cpp index 971ae2ed60..3486c5f186 100644 --- a/Demos/PaintTest/main.cpp +++ b/Demos/PaintTest/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_rect(100, 100, 400, 400); window->set_title("Paint test"); diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index 788acf440e..b19fd75a16 100755 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -18,7 +18,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_rect(100, 100, 320, 620); window->set_title("Widget Gallery"); diff --git a/DevTools/Inspector/main.cpp b/DevTools/Inspector/main.cpp index ed2d98f6f1..03ed077f80 100644 --- a/DevTools/Inspector/main.cpp +++ b/DevTools/Inspector/main.cpp @@ -28,7 +28,7 @@ int main(int argc, char** argv) GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Inspector"); window->set_rect(150, 150, 300, 500); diff --git a/DevTools/VisualBuilder/main.cpp b/DevTools/VisualBuilder/main.cpp index 1d314b8467..9a68d9d0d6 100644 --- a/DevTools/VisualBuilder/main.cpp +++ b/DevTools/VisualBuilder/main.cpp @@ -17,7 +17,7 @@ #include <stdio.h> #include <unistd.h> -static GWindow* make_toolbox_window(); +static ObjectPtr<GWindow> make_toolbox_window(); int main(int argc, char** argv) { @@ -47,7 +47,7 @@ int main(int argc, char** argv) })); menubar->add_menu(move(file_menu)); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title(form1->name()); window->set_rect(120, 200, 640, 400); window->set_main_widget(form1); @@ -62,7 +62,7 @@ int main(int argc, char** argv) app.set_menubar(move(menubar)); - auto* toolbox = make_toolbox_window(); + auto toolbox = make_toolbox_window(); toolbox->show(); propbox->show(); @@ -74,9 +74,9 @@ int main(int argc, char** argv) return app.exec(); } -GWindow* make_toolbox_window() +ObjectPtr<GWindow> make_toolbox_window() { - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("Widgets"); window->set_rect(20, 200, 80, 300); diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 96ad49e1bd..27b568e72c 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_resizable(false); window->set_title("Minesweeper"); window->set_rect(100, 100, 139, 175); diff --git a/Games/Snake/main.cpp b/Games/Snake/main.cpp index 9a98c9ba29..e8df14fd36 100644 --- a/Games/Snake/main.cpp +++ b/Games/Snake/main.cpp @@ -12,7 +12,7 @@ int main(int argc, char** argv) { GApplication app(argc, argv); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_double_buffering_enabled(false); window->set_title("Snake"); diff --git a/Libraries/LibGUI/GComboBox.cpp b/Libraries/LibGUI/GComboBox.cpp index 090f2688d7..8a984c7099 100644 --- a/Libraries/LibGUI/GComboBox.cpp +++ b/Libraries/LibGUI/GComboBox.cpp @@ -28,7 +28,7 @@ GComboBox::GComboBox(GWidget* parent) open(); }; - m_list_window = new GWindow(this); + m_list_window = GWindow::construct(this); // FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm. m_list_window->set_window_type(GWindowType::Tooltip); m_list_window->set_should_destroy_on_close(false); diff --git a/Libraries/LibGUI/GComboBox.h b/Libraries/LibGUI/GComboBox.h index 72721c2ff8..6ac2c01f95 100644 --- a/Libraries/LibGUI/GComboBox.h +++ b/Libraries/LibGUI/GComboBox.h @@ -38,7 +38,7 @@ protected: private: ObjectPtr<GTextEditor> m_editor; GButton* m_open_button { nullptr }; - GWindow* m_list_window { nullptr }; + ObjectPtr<GWindow> m_list_window; ObjectPtr<GListView> m_list_view; bool m_only_allow_values_from_model { false }; }; diff --git a/Libraries/LibGUI/GWindow.h b/Libraries/LibGUI/GWindow.h index 4f4803a85b..3150fc3528 100644 --- a/Libraries/LibGUI/GWindow.h +++ b/Libraries/LibGUI/GWindow.h @@ -24,7 +24,6 @@ enum class GStandardCursor { class GWindow : public CObject { C_OBJECT(GWindow) public: - GWindow(CObject* parent = nullptr); virtual ~GWindow() override; static GWindow* from_window_id(int); @@ -135,6 +134,7 @@ public: virtual void save_to(AK::JsonObject&) override; protected: + GWindow(CObject* parent = nullptr); virtual void wm_event(GWMEvent&); private: |