Skip to content

Commit

Permalink
LibCore: Remove ObjectPtr in favor of RefPtr
Browse files Browse the repository at this point in the history
Now that CObject is fully ref-counted, just use RefPtr everywhere! :^)
  • Loading branch information
awesomekling committed Sep 21, 2019
1 parent bc319d9 commit d6abfbd
Show file tree
Hide file tree
Showing 71 changed files with 147 additions and 157 deletions.
42 changes: 21 additions & 21 deletions Applications/Calculator/CalculatorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ class CalculatorWidget final : public GWidget {
Calculator m_calculator;
Keypad m_keypad;

ObjectPtr<GTextBox> m_entry;
ObjectPtr<GLabel> m_label;

ObjectPtr<GButton> m_digit_button[10];
ObjectPtr<GButton> m_mem_add_button;
ObjectPtr<GButton> m_mem_save_button;
ObjectPtr<GButton> m_mem_recall_button;
ObjectPtr<GButton> m_mem_clear_button;
ObjectPtr<GButton> m_clear_button;
ObjectPtr<GButton> m_clear_error_button;
ObjectPtr<GButton> m_backspace_button;
ObjectPtr<GButton> m_decimal_point_button;
ObjectPtr<GButton> m_sign_button;
ObjectPtr<GButton> m_add_button;
ObjectPtr<GButton> m_subtract_button;
ObjectPtr<GButton> m_multiply_button;
ObjectPtr<GButton> m_divide_button;
ObjectPtr<GButton> m_sqrt_button;
ObjectPtr<GButton> m_inverse_button;
ObjectPtr<GButton> m_percent_button;
ObjectPtr<GButton> m_equals_button;
RefPtr<GTextBox> m_entry;
RefPtr<GLabel> m_label;

RefPtr<GButton> m_digit_button[10];
RefPtr<GButton> m_mem_add_button;
RefPtr<GButton> m_mem_save_button;
RefPtr<GButton> m_mem_recall_button;
RefPtr<GButton> m_mem_clear_button;
RefPtr<GButton> m_clear_button;
RefPtr<GButton> m_clear_error_button;
RefPtr<GButton> m_backspace_button;
RefPtr<GButton> m_decimal_point_button;
RefPtr<GButton> m_sign_button;
RefPtr<GButton> m_add_button;
RefPtr<GButton> m_subtract_button;
RefPtr<GButton> m_multiply_button;
RefPtr<GButton> m_divide_button;
RefPtr<GButton> m_sqrt_button;
RefPtr<GButton> m_inverse_button;
RefPtr<GButton> m_percent_button;
RefPtr<GButton> m_equals_button;

};
2 changes: 1 addition & 1 deletion Applications/ChanViewer/BoardListModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class BoardListModel final : public GModel {
BoardListModel();

JsonArray m_boards;
ObjectPtr<CHttpJob> m_pending_job;
RefPtr<CHttpJob> m_pending_job;
};
2 changes: 1 addition & 1 deletion Applications/ChanViewer/ThreadCatalogModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class ThreadCatalogModel final : public GModel {

String m_board { "g" };
JsonArray m_catalog;
ObjectPtr<CHttpJob> m_pending_job;
RefPtr<CHttpJob> m_pending_job;
};
4 changes: 2 additions & 2 deletions Applications/DisplayProperties/DisplayProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class DisplayPropertiesWidget final {
private:
String m_wallpaper_path;
RefPtr<CConfigFile> m_wm_config;
ObjectPtr<GWidget> m_root_widget;
RefPtr<GWidget> m_root_widget;
Vector<Size> m_resolutions;
Vector<String> m_wallpapers;
ObjectPtr<GLabel> m_wallpaper_preview;
RefPtr<GLabel> m_wallpaper_preview;

Size m_selected_resolution;
String m_selected_wallpaper;
Expand Down
4 changes: 2 additions & 2 deletions Applications/FileManager/DirectoryView.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ class DirectoryView final : public GStackWidget {
Vector<String> m_path_history;
void add_path_to_history(const StringView& path);

ObjectPtr<GTableView> m_table_view;
ObjectPtr<GItemView> m_item_view;
RefPtr<GTableView> m_table_view;
RefPtr<GItemView> m_item_view;
};
4 changes: 2 additions & 2 deletions Applications/IRCClient/IRCAppWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class IRCAppWindow : public GWindow {

IRCWindow& create_window(void* owner, IRCWindow::Type, const String& name);
IRCClient m_client;
ObjectPtr<GStackWidget> m_container;
ObjectPtr<GTableView> m_window_list;
RefPtr<GStackWidget> m_container;
RefPtr<GTableView> m_window_list;
RefPtr<GAction> m_join_action;
RefPtr<GAction> m_part_action;
RefPtr<GAction> m_whois_action;
Expand Down
5 changes: 2 additions & 3 deletions Applications/IRCClient/IRCClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <AK/String.h>
#include <LibCore/CConfigFile.h>
#include <LibCore/CTCPSocket.h>
#include <LibCore/ObjectPtr.h>

class IRCChannel;
class IRCQuery;
Expand Down Expand Up @@ -137,10 +136,10 @@ class IRCClient final : public CObject {
String m_hostname;
int m_port { 6667 };

ObjectPtr<CTCPSocket> m_socket;
RefPtr<CTCPSocket> m_socket;

String m_nickname;
ObjectPtr<CNotifier> m_notifier;
RefPtr<CNotifier> m_notifier;
HashMap<String, RefPtr<IRCChannel>, CaseInsensitiveStringTraits> m_channels;
HashMap<String, RefPtr<IRCQuery>, CaseInsensitiveStringTraits> m_queries;

Expand Down
4 changes: 2 additions & 2 deletions Applications/IRCClient/IRCWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class IRCWindow : public GWidget {
void* m_owner { nullptr };
Type m_type;
String m_name;
ObjectPtr<GTableView> m_table_view;
ObjectPtr<GTextEditor> m_text_editor;
RefPtr<GTableView> m_table_view;
RefPtr<GTextEditor> m_text_editor;
RefPtr<IRCLogBuffer> m_log_buffer;
int m_unread_count { 0 };
};
4 changes: 2 additions & 2 deletions Applications/Launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <sys/wait.h>
#include <unistd.h>

static ObjectPtr<GWindow> make_launcher_window();
static RefPtr<GWindow> make_launcher_window();

void handle_sigchld(int)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ class LauncherButton final : public GButton {
String m_executable_path;
};

ObjectPtr<GWindow> make_launcher_window()
RefPtr<GWindow> make_launcher_window()
{
auto config = CConfigFile::get_for_app("Launcher");
auto vertical = config->read_bool_entry("Launcher", "Vertical", true);
Expand Down
2 changes: 1 addition & 1 deletion Applications/PaintBrush/ColorDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ class ColorDialog final : public GDialog {
void build();

Color m_color;
ObjectPtr<GFrame> m_preview_widget;
RefPtr<GFrame> m_preview_widget;
};
4 changes: 2 additions & 2 deletions Applications/PaintBrush/PaletteWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class PaletteWidget final : public GFrame {

private:
PaintableWidget& m_paintable_widget;
ObjectPtr<GFrame> m_primary_color_widget;
ObjectPtr<GFrame> m_secondary_color_widget;
RefPtr<GFrame> m_primary_color_widget;
RefPtr<GFrame> m_secondary_color_widget;
};
2 changes: 1 addition & 1 deletion Applications/PaintBrush/SprayTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SprayTool final : public Tool {
private:
virtual const char* class_name() const override { return "SprayTool"; }
void paint_it();
ObjectPtr<CTimer> m_timer;
RefPtr<CTimer> m_timer;
Point m_last_pos;
Color m_color;
OwnPtr<GMenu> m_context_menu;
Expand Down
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/MemoryStatsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
layout()->set_margins({ 0, 8, 0, 0 });
layout()->set_spacing(3);

auto build_widgets_for_label = [this](const String& description) -> ObjectPtr<GLabel> {
auto build_widgets_for_label = [this](const String& description) -> RefPtr<GLabel> {
auto container = GWidget::construct(this);
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
Expand Down
10 changes: 5 additions & 5 deletions Applications/SystemMonitor/MemoryStatsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class MemoryStatsWidget final : public GWidget {
virtual void timer_event(CTimerEvent&) override;

GraphWidget& m_graph;
ObjectPtr<GLabel> m_user_physical_pages_label;
ObjectPtr<GLabel> m_supervisor_physical_pages_label;
ObjectPtr<GLabel> m_kmalloc_label;
ObjectPtr<GLabel> m_kmalloc_count_label;
ObjectPtr<CFile> m_proc_memstat;
RefPtr<GLabel> m_user_physical_pages_label;
RefPtr<GLabel> m_supervisor_physical_pages_label;
RefPtr<GLabel> m_kmalloc_label;
RefPtr<GLabel> m_kmalloc_count_label;
RefPtr<CFile> m_proc_memstat;
};
6 changes: 3 additions & 3 deletions Applications/SystemMonitor/NetworkStatisticsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NetworkStatisticsWidget final : public GWidget {
explicit NetworkStatisticsWidget(GWidget* parent = nullptr);
void update_models();

ObjectPtr<GTableView> m_adapter_table_view;
ObjectPtr<GTableView> m_socket_table_view;
ObjectPtr<CTimer> m_update_timer;
RefPtr<GTableView> m_adapter_table_view;
RefPtr<GTableView> m_socket_table_view;
RefPtr<CTimer> m_update_timer;
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class ProcessFileDescriptorMapWidget final : public GWidget {
private:
explicit ProcessFileDescriptorMapWidget(GWidget* parent);

ObjectPtr<GTableView> m_table_view;
RefPtr<GTableView> m_table_view;
pid_t m_pid { -1 };
};
2 changes: 1 addition & 1 deletion Applications/SystemMonitor/ProcessMemoryMapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class ProcessMemoryMapWidget final : public GWidget {

private:
explicit ProcessMemoryMapWidget(GWidget* parent);
ObjectPtr<GTableView> m_table_view;
RefPtr<GTableView> m_table_view;
pid_t m_pid { -1 };
};
5 changes: 2 additions & 3 deletions Applications/SystemMonitor/ProcessStacksWidget.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <LibCore/ObjectPtr.h>
#include <LibGUI/GTextEditor.h>
#include <LibGUI/GWidget.h>

Expand All @@ -17,6 +16,6 @@ class ProcessStacksWidget final : public GWidget {

private:
pid_t m_pid { -1 };
ObjectPtr<GTextEditor> m_stacks_editor;
ObjectPtr<CTimer> m_timer;
RefPtr<GTextEditor> m_stacks_editor;
RefPtr<CTimer> m_timer;
};
12 changes: 6 additions & 6 deletions Applications/SystemMonitor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ static String human_readable_size(u32 size)
return String::format("%u GB", size / GB);
}

static ObjectPtr<GWidget> build_file_systems_tab();
static ObjectPtr<GWidget> build_pci_devices_tab();
static ObjectPtr<GWidget> build_devices_tab();
static RefPtr<GWidget> build_file_systems_tab();
static RefPtr<GWidget> build_pci_devices_tab();
static RefPtr<GWidget> build_devices_tab();

int main(int argc, char** argv)
{
Expand Down Expand Up @@ -234,7 +234,7 @@ class ProgressBarPaintingDelegate final : public GTableCellPaintingDelegate {
}
};

ObjectPtr<GWidget> build_file_systems_tab()
RefPtr<GWidget> build_file_systems_tab()
{
auto fs_widget = GWidget::construct();
fs_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
Expand Down Expand Up @@ -299,7 +299,7 @@ ObjectPtr<GWidget> build_file_systems_tab()
return fs_widget;
}

ObjectPtr<GWidget> build_pci_devices_tab()
RefPtr<GWidget> build_pci_devices_tab()
{
auto pci_widget = GWidget::construct();
pci_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
Expand Down Expand Up @@ -353,7 +353,7 @@ ObjectPtr<GWidget> build_pci_devices_tab()
return pci_widget;
}

ObjectPtr<GWidget> build_devices_tab()
RefPtr<GWidget> build_devices_tab()
{
auto devices_widget = GWidget::construct();
devices_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
Expand Down
8 changes: 4 additions & 4 deletions Applications/Terminal/TerminalWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ class TerminalWidget final : public GFrame

bool m_in_active_window { false };

ObjectPtr<CNotifier> m_notifier;
RefPtr<CNotifier> m_notifier;

u8 m_opacity { 255 };
bool m_needs_background_fill { true };
bool m_cursor_blink_state { true };

int m_glyph_width { 0 };

ObjectPtr<CTimer> m_cursor_blink_timer;
ObjectPtr<CTimer> m_visual_beep_timer;
RefPtr<CTimer> m_cursor_blink_timer;
RefPtr<CTimer> m_visual_beep_timer;
RefPtr<CConfigFile> m_config;

ObjectPtr<GScrollBar> m_scrollbar;
RefPtr<GScrollBar> m_scrollbar;
};
4 changes: 2 additions & 2 deletions Applications/Terminal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void run_command(int ptm_fd, String command)
}
}

ObjectPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> config)
RefPtr<GWindow> create_settings_window(TerminalWidget& terminal, RefPtr<CConfigFile> config)
{
auto window = GWindow::construct();
window->set_title("Terminal Settings");
Expand Down Expand Up @@ -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));

ObjectPtr<GWindow> settings_window;
RefPtr<GWindow> settings_window;

auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
terminal->set_opacity(new_opacity);
Expand Down
8 changes: 4 additions & 4 deletions Applications/TextEditor/TextEditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TextEditorWidget final : public GWidget {
void set_path(const FileSystemPath& file);
void update_title();

ObjectPtr<GTextEditor> m_editor;
RefPtr<GTextEditor> m_editor;
String m_path;
String m_name;
String m_extension;
Expand All @@ -37,12 +37,12 @@ class TextEditorWidget final : public GWidget {
RefPtr<GAction> m_find_next_action;
RefPtr<GAction> m_find_previous_action;

ObjectPtr<GStatusBar> m_statusbar;
RefPtr<GStatusBar> m_statusbar;

ObjectPtr<GTextBox> m_find_textbox;
RefPtr<GTextBox> m_find_textbox;
GButton* m_find_previous_button { nullptr };
GButton* m_find_next_button { nullptr };
ObjectPtr<GWidget> m_find_widget;
RefPtr<GWidget> m_find_widget;

bool m_document_dirty { false };
};
4 changes: 2 additions & 2 deletions DevTools/FormCompiler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ int main(int argc, char** argv)
});

dbg() << "struct UI_" << name << " {";
dbg() << " ObjectPtr<GWidget> main_widget;";
dbg() << " RefPtr<GWidget> main_widget;";

widgets.as_array().for_each([&](auto& value) {
ASSERT(value.is_object());
const JsonObject& widget_object = value.as_object();
auto name = widget_object.get("name").to_string();
auto class_name = widget_object.get("class").to_string();
dbg() << " ObjectPtr<" << class_name << "> " << name << ";";
dbg() << " RefPtr<" << class_name << "> " << name << ";";
});

dbg() << " UI_" << name << "();";
Expand Down
2 changes: 1 addition & 1 deletion DevTools/Inspector/RemoteProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class RemoteProcess {
pid_t m_pid { -1 };
String m_process_name;
NonnullRefPtr<RemoteObjectGraphModel> m_object_graph_model;
ObjectPtr<CLocalSocket> m_socket;
RefPtr<CLocalSocket> m_socket;
NonnullOwnPtrVector<RemoteObject> m_roots;
};
2 changes: 1 addition & 1 deletion DevTools/VisualBuilder/VBPropertiesWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BoolModelEditingDelegate : public GModelEditingDelegate {
BoolModelEditingDelegate() {}
virtual ~BoolModelEditingDelegate() override {}

virtual ObjectPtr<GWidget> create_widget() override
virtual RefPtr<GWidget> create_widget() override
{
auto combo = GComboBox::construct(nullptr);
combo->set_only_allow_values_from_model(true);
Expand Down
2 changes: 1 addition & 1 deletion DevTools/VisualBuilder/VBPropertiesWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class VBPropertiesWindow final : public GWindow {
const GTableView& table_view() const { return *m_table_view; }

private:
ObjectPtr<GTableView> m_table_view;
RefPtr<GTableView> m_table_view;
};
2 changes: 1 addition & 1 deletion DevTools/VisualBuilder/VBWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class VBWidget : public RefCounted<VBWidget>

VBWidgetType m_type { VBWidgetType::None };
VBForm& m_form;
ObjectPtr<GWidget> m_gwidget;
RefPtr<GWidget> m_gwidget;
NonnullOwnPtrVector<VBProperty> m_properties;
NonnullRefPtr<VBWidgetPropertyModel> m_property_model;
Rect m_transform_origin_rect;
Expand Down
Loading

0 comments on commit d6abfbd

Please sign in to comment.