[gnote] Move semantics for add_child_widget



commit ca1e8b76b0d4c4c43626ab5c48a41b68bf260a95
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Tue Apr 19 22:48:26 2022 +0300

    Move semantics for add_child_widget

 src/note.cpp       | 5 ++---
 src/note.hpp       | 8 +++-----
 src/notebuffer.cpp | 4 ++--
 3 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index 64ce710e..dc9b8c83 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -474,10 +474,9 @@ namespace gnote {
     queue_save(OTHER_DATA_CHANGED);
   }
 
-  void Note::add_child_widget(const Glib::RefPtr<Gtk::TextChildAnchor> & child_anchor,
-                              Gtk::Widget * widget)
+  void Note::add_child_widget(Glib::RefPtr<Gtk::TextChildAnchor> && child_anchor, Gtk::Widget *widget)
   {
-    m_child_widget_queue.push(ChildWidgetData(child_anchor, widget));
+    m_child_widget_queue.push(ChildWidgetData(std::move(child_anchor), widget));
     if(has_window()) {
       process_child_widget_queue();
     }
diff --git a/src/note.hpp b/src/note.hpp
index 5b925400..00e87c78 100644
--- a/src/note.hpp
+++ b/src/note.hpp
@@ -107,8 +107,7 @@ public:
   virtual void queue_save(ChangeType c) override;
   using NoteBase::remove_tag;
   virtual void remove_tag(Tag &) override;
-  void add_child_widget(const Glib::RefPtr<Gtk::TextChildAnchor> & child_anchor,
-                        Gtk::Widget * widget);
+  void add_child_widget(Glib::RefPtr<Gtk::TextChildAnchor> && child_anchor, Gtk::Widget *widget);
 
   using NoteBase::set_title;
   virtual void set_title(const Glib::ustring & new_title, bool from_user_action) override;
@@ -181,9 +180,8 @@ private:
 
   struct ChildWidgetData
   {
-    ChildWidgetData(const Glib::RefPtr<Gtk::TextChildAnchor> & _anchor,
-                    Gtk::Widget *_widget)
-      : anchor(_anchor)
+    ChildWidgetData(Glib::RefPtr<Gtk::TextChildAnchor> && _anchor, Gtk::Widget *_widget)
+      : anchor(std::move(_anchor))
       , widget(_widget)
       {
       }
diff --git a/src/notebuffer.cpp b/src/notebuffer.cpp
index 6572ce8a..79b58d5a 100644
--- a/src/notebuffer.cpp
+++ b/src/notebuffer.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2010-2017,2019-2021 Aurimas Cernius
+ * Copyright (C) 2010-2017,2019-2022 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -749,7 +749,7 @@ namespace gnote {
         if (data.adding && !data.tag->get_widget_location()) {
           Glib::RefPtr<Gtk::TextChildAnchor> childAnchor = buffer->create_child_anchor(iter);
           data.tag->set_widget_location(location);
-          m_note.add_child_widget(childAnchor, data.widget);
+          m_note.add_child_widget(std::move(childAnchor), data.widget);
         }
         else if (!data.adding && data.tag->get_widget_location()) {
           Gtk::TextIter end_iter = iter;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]