[glom] Document: Remove signal_forget().



commit 55b08b6219832dca7a00eea8f6daec54ebe8d9d9
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Feb 4 21:03:58 2016 +0100

    Document: Remove signal_forget().
    
    This shouldn't be necessary anymore. We reset the document in all views
    before we discard the document from the application. If there are any
    circular references we should deal with them via weak_ptr.

 glom/bakery/appwindow_withdoc.cc         |   16 +---------------
 glom/libglom/document/bakery/document.cc |   14 --------------
 glom/libglom/document/bakery/document.h  |   11 -----------
 glom/libglom/document/bakery/view/view.h |    8 --------
 4 files changed, 1 insertions(+), 48 deletions(-)
---
diff --git a/glom/bakery/appwindow_withdoc.cc b/glom/bakery/appwindow_withdoc.cc
index 37dff36..0702c90 100644
--- a/glom/bakery/appwindow_withdoc.cc
+++ b/glom/bakery/appwindow_withdoc.cc
@@ -39,13 +39,7 @@ AppWindow_WithDoc::AppWindow_WithDoc(const Glib::ustring& appname)
 
 AppWindow_WithDoc::~AppWindow_WithDoc()
 {
-  //Delete the document:
-  if (m_document) {
-    //TODO: Should the views have weak ptr?
-    //This will cause Document::signal_forget to be emitted, so the Views will then null their
-    //pointers as well.
-    m_document->emit_forget();
-  }
+  //TODO: Should the views have weak_ptr to m_document?
 }
 
 //static
@@ -160,14 +154,6 @@ bool AppWindow_WithDoc::open_document(const Glib::ustring& file_uri)
       document_history_remove(file_uri);
 
     //re-initialize document.
-    if(m_document)
-    {
-      //TODO: Should the views have weak ptr?
-      //This will cause Document::signal_forget to be emitted, so the Views will then null their
-      //pointers as well.
-      m_document->emit_forget();
-    }
-
     pApp->m_document.reset();
     pApp->init_create_document();
 
diff --git a/glom/libglom/document/bakery/document.cc b/glom/libglom/document/bakery/document.cc
index 1af5d1b..99157cc 100644
--- a/glom/libglom/document/bakery/document.cc
+++ b/glom/libglom/document/bakery/document.cc
@@ -40,12 +40,6 @@ Document::~Document()
 {
 }
 
-void Document::emit_forget()
-{
-  //Tell views to forget the document -  to null their pointers to it. We should maybe use the Document via 
a sharing smartpointer instead.
-  signal_forget_.emit();
-}
-
 Glib::ustring Document::get_file_uri() const
 {
   return m_file_uri;
@@ -507,12 +501,4 @@ Document::type_signal_modified& Document::signal_modified()
   return signal_modified_;
 }
 
-Document::type_signal_forget& Document::signal_forget()
-{
-  return signal_forget_;
-}
-
-
-
-
 } //namespace
diff --git a/glom/libglom/document/bakery/document.h b/glom/libglom/document/bakery/document.h
index 5b3ba7b..0801b31 100644
--- a/glom/libglom/document/bakery/document.h
+++ b/glom/libglom/document/bakery/document.h
@@ -36,9 +36,6 @@ public:
   Document();
   virtual ~Document();
 
-  //TODO: Properly use a weak pointer instead.
-  void emit_forget();
-
   /* Saves the data to disk.
    * Asks the View to update this document before saving to disk,
    * but you should probably ensure that the document is updated more regularly than this,
@@ -110,13 +107,6 @@ public:
    */
   type_signal_modified& signal_modified();
 
-  typedef sigc::signal<void> type_signal_forget;
-
-  /** This signal is emitted when the view should forget the document.
-   * This is used internally, and you should not need to use it yourself.
-   */
-  type_signal_forget& signal_forget();
-
   ///Allow app to update icons/title bar.
 
 protected:
@@ -142,7 +132,6 @@ protected:
   ViewBase* m_pView;
 
   type_signal_modified signal_modified_;
-  type_signal_forget signal_forget_;
 
   bool m_bModified;
   bool m_bIsNew; //see get_is_new().
diff --git a/glom/libglom/document/bakery/view/view.h b/glom/libglom/document/bakery/view/view.h
index e020d31..8cc72eb 100644
--- a/glom/libglom/document/bakery/view/view.h
+++ b/glom/libglom/document/bakery/view/view.h
@@ -55,8 +55,6 @@ public:
   virtual void set_document(const std::shared_ptr<T_Document>& document)
   {
     m_document = document;
-    if(m_document)
-      m_document->signal_forget().connect( sigc::mem_fun(*this, &type_self::on_document_forget) );
   }
 
   ///Just a convenience, instead of get_docuement()->set_modified().
@@ -67,12 +65,6 @@ public:
   }
 
 protected:
-
-  void on_document_forget()
-  {
-    //This should prevent some segfaults:
-    m_document.reset();
-  }
   
   std::shared_ptr<T_Document> m_document;
 };


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