[regexxer/murrayc-update: 5/12] Replace all (deprecated) auto_ptr with unique_ptr.



commit 84c9b5f119ca4aea9de6ee15aad45728b19c9e50
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Feb 29 23:38:25 2016 +0100

    Replace all (deprecated) auto_ptr with unique_ptr.

 src/main.cc       |    8 ++++----
 src/mainwindow.cc |   23 ++++++++---------------
 src/mainwindow.h  |    6 +++---
 src/prefdialog.h  |    2 +-
 4 files changed, 16 insertions(+), 23 deletions(-)
---
diff --git a/src/main.cc b/src/main.cc
index 625b1f7..4900fef 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -90,7 +90,7 @@ private:
   RegexxerOptions();
 
 public:
-  static std::auto_ptr<RegexxerOptions> create();
+  static std::unique_ptr<RegexxerOptions> create();
   ~RegexxerOptions();
 
   Glib::OptionContext& context()    { return context_; }
@@ -125,9 +125,9 @@ RegexxerOptions::~RegexxerOptions()
 {}
 
 // static
-std::auto_ptr<RegexxerOptions> RegexxerOptions::create()
+std::unique_ptr<RegexxerOptions> RegexxerOptions::create()
 {
-  std::auto_ptr<RegexxerOptions> options (new RegexxerOptions());
+  std::unique_ptr<RegexxerOptions> options (new RegexxerOptions());
 
   Glib::OptionGroup&  group = options->group_;
   Regexxer::InitState& init = options->init_state_;
@@ -201,7 +201,7 @@ int main(int argc, char** argv)
   {
     Util::initialize_gettext(PACKAGE_TARNAME, REGEXXER_LOCALEDIR);
 
-    std::auto_ptr<RegexxerOptions> options = RegexxerOptions::create();
+    std::unique_ptr<RegexxerOptions> options = RegexxerOptions::create();
     options->context().parse(argc, argv);
     Glib::RefPtr<Gtk::Application> app =
         Gtk::Application::create(argc, argv, Regexxer::conf_schema);
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index fa8f40c..4096c64 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -572,13 +572,8 @@ void MainWindow::on_hide()
   // necessary since they'd be deleted in the destructor anyway.  But if we
   // have to do a lot of cleanup the dialogs would stay open for that time,
   // which doesn't look neat.
-  {
-    // Play safe and transfer ownership, and let the dtor do the delete.
-    const std::auto_ptr<Gtk::Dialog> temp (about_dialog_);
-  }
-  {
-    const std::auto_ptr<PrefDialog> temp (pref_dialog_);
-  }
+  about_dialog_.reset();
+  pref_dialog_.reset();
 }
 
 void MainWindow::on_style_updated()
@@ -1173,7 +1168,7 @@ void MainWindow::on_about()
   }
   else
   {
-    std::auto_ptr<Gtk::AboutDialog> dialog (new Gtk::AboutDialog());
+    std::unique_ptr<Gtk::AboutDialog> dialog (new Gtk::AboutDialog());
     std::vector<Glib::ustring> authors;
     for (int i = 0; program_authors[i]; i++)
       authors.push_back(program_authors[i]);
@@ -1194,14 +1189,13 @@ void MainWindow::on_about()
     dialog->show();
     dialog->signal_response().connect(sigc::mem_fun(*this, &MainWindow::on_about_dialog_response));
 
-    about_dialog_ = dialog;
+    about_dialog_ = std::move(dialog);
   }
 }
 
 void MainWindow::on_about_dialog_response(int)
 {
-  // Play safe and transfer ownership, and let the dtor do the delete.
-  const std::auto_ptr<Gtk::Dialog> temp (about_dialog_);
+  about_dialog_.reset();
 }
 
 void MainWindow::on_preferences()
@@ -1212,20 +1206,19 @@ void MainWindow::on_preferences()
   }
   else
   {
-    std::auto_ptr<PrefDialog> dialog (new PrefDialog(*window_));
+    std::unique_ptr<PrefDialog> dialog (new PrefDialog(*window_));
 
     dialog->get_dialog()->signal_hide()
         .connect(sigc::mem_fun(*this, &MainWindow::on_pref_dialog_hide));
     dialog->get_dialog()->show();
 
-    pref_dialog_ = dialog;
+    pref_dialog_ = std::move(dialog);
   }
 }
 
 void MainWindow::on_pref_dialog_hide()
 {
-  // Play safe and transfer ownership, and let the dtor do the delete.
-  const std::auto_ptr<PrefDialog> temp (pref_dialog_);
+  pref_dialog_.reset();
 }
 
 void MainWindow::on_conf_value_changed(const Glib::ustring& key)
diff --git a/src/mainwindow.h b/src/mainwindow.h
index b4f27a9..b9db795 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -102,7 +102,7 @@ private:
   class BusyAction;
 
   Glib::RefPtr<Gtk::Application> application_;
-  std::auto_ptr<Gtk::ApplicationWindow>  window_;
+  std::unique_ptr<Gtk::ApplicationWindow>  window_;
   Controller                  controller_;
 
   Gtk::Box*                   vbox_main_;
@@ -147,8 +147,8 @@ private:
 
   std::list<sigc::connection> buffer_connections_;
 
-  std::auto_ptr<Gtk::Dialog>  about_dialog_;
-  std::auto_ptr<PrefDialog>   pref_dialog_;
+  std::unique_ptr<Gtk::Dialog>  about_dialog_;
+  std::unique_ptr<PrefDialog>   pref_dialog_;
 
   Glib::RefPtr<Gio::SimpleActionGroup> match_action_group_;
   Glib::RefPtr<Gio::SimpleActionGroup> edit_action_group_;
diff --git a/src/prefdialog.h b/src/prefdialog.h
index af35a32..90c5a72 100644
--- a/src/prefdialog.h
+++ b/src/prefdialog.h
@@ -50,7 +50,7 @@ public:
   Gtk::Dialog* get_dialog() { return dialog_.get(); }
 
 private:
-  std::auto_ptr<Gtk::Dialog>  dialog_;
+  std::unique_ptr<Gtk::Dialog>  dialog_;
   Gtk::FontButton*            button_textview_font_;
   Gtk::ColorButton*           button_match_color_;
   Gtk::ColorButton*           button_current_color_;


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