summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-11 15:55:54 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-11 15:57:29 +0200
commit7faf878e0adbd37bd8b52867e57997628006f60b (patch)
tree9de19d4332175a55bd26ccadd0e8eaccb7e32cd1 /Libraries/LibGUI
parent8327b1229157f3d26191dc8835e8b184b6eb1ff3 (diff)
downloadserenity-7faf878e0adbd37bd8b52867e57997628006f60b.zip
GToolBar: Make add_action() take a GAction& instead of NonnullRefPtr&&.
There's very little reason to take NonnullRefPtr&& in arguments really. You can avoid ref-count churn in the cases where ownership is transferred from the caller to the callee, but that's a pretty unusual situation and not worth optimizing for at this stage.
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r--Libraries/LibGUI/GToolBar.cpp9
-rw-r--r--Libraries/LibGUI/GToolBar.h2
2 files changed, 5 insertions, 6 deletions
diff --git a/Libraries/LibGUI/GToolBar.cpp b/Libraries/LibGUI/GToolBar.cpp
index 761953e828..75b88bc97a 100644
--- a/Libraries/LibGUI/GToolBar.cpp
+++ b/Libraries/LibGUI/GToolBar.cpp
@@ -18,12 +18,11 @@ GToolBar::~GToolBar()
{
}
-void GToolBar::add_action(NonnullRefPtr<GAction>&& action)
+void GToolBar::add_action(GAction& action)
{
- GAction* raw_action_ptr = action.ptr();
auto item = make<Item>();
item->type = Item::Action;
- item->action = move(action);
+ item->action = action;
auto* button = new GButton(this);
button->set_action(*item->action);
@@ -32,8 +31,8 @@ void GToolBar::add_action(NonnullRefPtr<GAction>&& action)
button->set_icon(item->action->icon());
else
button->set_text(item->action->text());
- button->on_click = [raw_action_ptr](const GButton&) {
- raw_action_ptr->activate();
+ button->on_click = [&action](const GButton&) {
+ action.activate();
};
button->set_button_style(ButtonStyle::CoolBar);
diff --git a/Libraries/LibGUI/GToolBar.h b/Libraries/LibGUI/GToolBar.h
index 375734e586..bff3f9a49e 100644
--- a/Libraries/LibGUI/GToolBar.h
+++ b/Libraries/LibGUI/GToolBar.h
@@ -9,7 +9,7 @@ public:
explicit GToolBar(GWidget* parent);
virtual ~GToolBar() override;
- void add_action(NonnullRefPtr<GAction>&&);
+ void add_action(GAction&);
void add_separator();
bool has_frame() const { return m_has_frame; }