diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 18:17:23 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 18:17:23 +0200 |
commit | f57cc5873ce69c9949dc5d60010eca37293343ee (patch) | |
tree | 87a3213defb92982087b21280c63fe18b01f352c /Applications | |
parent | f4b51a63ec085db62ea2c122ee6ba93eeef62594 (diff) | |
download | serenity-f57cc5873ce69c9949dc5d60010eca37293343ee.zip |
SystemMonitor: Remove all remaining naked "new" usage
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/SystemMonitor/GraphWidget.h | 4 | ||||
-rw-r--r-- | Applications/SystemMonitor/MemoryStatsWidget.h | 1 | ||||
-rw-r--r-- | Applications/SystemMonitor/NetworkStatisticsWidget.h | 2 | ||||
-rw-r--r-- | Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h | 3 | ||||
-rw-r--r-- | Applications/SystemMonitor/ProcessMemoryMapWidget.h | 2 | ||||
-rw-r--r-- | Applications/SystemMonitor/ProcessTableView.h | 5 | ||||
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 22 |
7 files changed, 23 insertions, 16 deletions
diff --git a/Applications/SystemMonitor/GraphWidget.h b/Applications/SystemMonitor/GraphWidget.h index 1d39beb1f1..67402b3f72 100644 --- a/Applications/SystemMonitor/GraphWidget.h +++ b/Applications/SystemMonitor/GraphWidget.h @@ -2,8 +2,8 @@ #include <LibGUI/GFrame.h> class GraphWidget final : public GFrame { + C_OBJECT(GraphWidget) public: - explicit GraphWidget(GWidget* parent); virtual ~GraphWidget() override; void set_max(int max) { m_max = max; } @@ -15,6 +15,8 @@ public: Function<String(int value, int max)> text_formatter; private: + explicit GraphWidget(GWidget* parent); + virtual void paint_event(GPaintEvent&) override; int m_max { 100 }; diff --git a/Applications/SystemMonitor/MemoryStatsWidget.h b/Applications/SystemMonitor/MemoryStatsWidget.h index a7b94ef2c6..7762da38c9 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.h +++ b/Applications/SystemMonitor/MemoryStatsWidget.h @@ -7,6 +7,7 @@ class GLabel; class GraphWidget; class MemoryStatsWidget final : public GWidget { + C_OBJECT(MemoryStatsWidget) public: MemoryStatsWidget(GraphWidget& graph, GWidget* parent); virtual ~MemoryStatsWidget() override; diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.h b/Applications/SystemMonitor/NetworkStatisticsWidget.h index 564ecc1b79..018ad0d955 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.h +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.h @@ -8,10 +8,10 @@ class GTableView; class NetworkStatisticsWidget final : public GWidget { C_OBJECT(NetworkStatisticsWidget) public: - explicit NetworkStatisticsWidget(GWidget* parent = nullptr); virtual ~NetworkStatisticsWidget() override; private: + explicit NetworkStatisticsWidget(GWidget* parent = nullptr); void update_models(); ObjectPtr<GTableView> m_adapter_table_view; diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h index 66d94a1b23..4bc8f3434f 100644 --- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h +++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h @@ -7,12 +7,13 @@ class GTableView; class ProcessFileDescriptorMapWidget final : public GWidget { C_OBJECT(ProcessFileDescriptorMapWidget); public: - explicit ProcessFileDescriptorMapWidget(GWidget* parent); virtual ~ProcessFileDescriptorMapWidget() override; void set_pid(pid_t); private: + explicit ProcessFileDescriptorMapWidget(GWidget* parent); + ObjectPtr<GTableView> m_table_view; pid_t m_pid { -1 }; }; diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.h b/Applications/SystemMonitor/ProcessMemoryMapWidget.h index 003f896eda..7ee769f96e 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.h +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.h @@ -7,12 +7,12 @@ class GTableView; class ProcessMemoryMapWidget final : public GWidget { C_OBJECT(ProcessMemoryMapWidget); public: - explicit ProcessMemoryMapWidget(GWidget* parent); virtual ~ProcessMemoryMapWidget() override; void set_pid(pid_t); private: + explicit ProcessMemoryMapWidget(GWidget* parent); ObjectPtr<GTableView> m_table_view; pid_t m_pid { -1 }; }; diff --git a/Applications/SystemMonitor/ProcessTableView.h b/Applications/SystemMonitor/ProcessTableView.h index 3eace1bdb1..c193e214f4 100644 --- a/Applications/SystemMonitor/ProcessTableView.h +++ b/Applications/SystemMonitor/ProcessTableView.h @@ -8,8 +8,8 @@ class GraphWidget; class ProcessModel; class ProcessTableView final : public GTableView { + C_OBJECT(ProcessTableView) public: - ProcessTableView(GraphWidget&, GWidget* parent); virtual ~ProcessTableView() override; pid_t selected_pid() const; @@ -17,4 +17,7 @@ public: void refresh(); Function<void(pid_t)> on_process_selected; + +private: + ProcessTableView(GraphWidget&, GWidget* parent); }; diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 1cf905d0a6..418a1d069c 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char** argv) keeper->set_background_color(Color::WarmGray); keeper->layout()->set_margins({ 4, 4, 4, 4 }); - auto* tabwidget = new GTabWidget(keeper); + auto tabwidget = GTabWidget::construct(keeper); auto process_container_splitter = GSplitter::construct(Orientation::Vertical, nullptr); tabwidget->add_widget("Processes", process_container_splitter); @@ -71,7 +71,7 @@ int main(int argc, char** argv) cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 }); cpu_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); cpu_graph_group_box->set_preferred_size(0, 120); - auto* cpu_graph = new GraphWidget(cpu_graph_group_box); + auto cpu_graph = GraphWidget::construct(cpu_graph_group_box); cpu_graph->set_max(100); cpu_graph->set_text_color(Color::Green); cpu_graph->set_graph_color(Color::from_rgb(0x00bb00)); @@ -84,7 +84,7 @@ int main(int argc, char** argv) memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 }); memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); memory_graph_group_box->set_preferred_size(0, 120); - auto* memory_graph = new GraphWidget(memory_graph_group_box); + auto memory_graph = GraphWidget::construct(memory_graph_group_box); memory_graph->set_text_color(Color::Cyan); memory_graph->set_graph_color(Color::from_rgb(0x00bbbb)); memory_graph->text_formatter = [](int value, int max) { @@ -99,7 +99,7 @@ int main(int argc, char** argv) tabwidget->add_widget("Devices", build_devices_tab()); - auto* network_stats_widget = new NetworkStatisticsWidget(nullptr); + auto network_stats_widget = NetworkStatisticsWidget::construct(nullptr); tabwidget->add_widget("Network", network_stats_widget); process_table_container->set_layout(make<GBoxLayout>(Orientation::Vertical)); @@ -108,8 +108,8 @@ int main(int argc, char** argv) auto toolbar = GToolBar::construct(process_table_container); toolbar->set_has_frame(false); - auto* process_table_view = new ProcessTableView(*cpu_graph, process_table_container); - auto* memory_stats_widget = new MemoryStatsWidget(*memory_graph, graphs_container); + auto process_table_view = ProcessTableView::construct(*cpu_graph, process_table_container); + auto memory_stats_widget = MemoryStatsWidget::construct(*memory_graph, graphs_container); auto refresh_timer = CTimer::construct(1000, [&] { process_table_view->refresh(); @@ -138,7 +138,7 @@ int main(int argc, char** argv) toolbar->add_action(stop_action); toolbar->add_action(continue_action); - auto* window = new GWindow; + auto window = GWindow::construct(); window->set_title("System Monitor"); window->set_rect(20, 200, 680, 400); window->set_main_widget(keeper); @@ -192,15 +192,15 @@ int main(int argc, char** argv) app.set_menubar(move(menubar)); - auto* process_tab_widget = new GTabWidget(process_container_splitter); + auto process_tab_widget = GTabWidget::construct(process_container_splitter); - auto* open_files_widget = new ProcessFileDescriptorMapWidget(nullptr); + auto open_files_widget = ProcessFileDescriptorMapWidget::construct(nullptr); process_tab_widget->add_widget("Open files", open_files_widget); - auto* memory_map_widget = new ProcessMemoryMapWidget(nullptr); + auto memory_map_widget = ProcessMemoryMapWidget::construct(nullptr); process_tab_widget->add_widget("Memory map", memory_map_widget); - auto* stacks_widget = new ProcessStacksWidget(nullptr); + auto stacks_widget = ProcessStacksWidget::construct(nullptr); process_tab_widget->add_widget("Stacks", stacks_widget); process_table_view->on_process_selected = [&](pid_t pid) { |