[glom] Document: Avoid useless autosave during constructor.



commit c9d33b108a9d6c6cee9b2cd38142da5a7c7d8838
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Dec 6 20:08:31 2011 +0100

    Document: Avoid useless autosave during constructor.
    
    	* glom/libglom/document/document.cc: Constructor: Avoid triggering
    	autosave during the constructor, though this is stopped anyway by the
    	empty filepath.

 ChangeLog                         |    8 ++++++++
 glom/libglom/document/document.cc |    6 ++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index aa8f59a..3ebe72d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-12-06  Murray Cumming  <murrayc murrayc com>
+
+	Document: Avoid useless autosave during constructor.
+
+	* glom/libglom/document/document.cc: Constructor: Avoid triggering
+	autosave during the constructor, though this is stopped anyway by the 
+	empty filepath.
+
 2011-12-05  Murray Cumming  <murrayc murrayc com>
 
 	Remove unused get_sql_format() methods.
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 4ce8e66..354ae80 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -280,6 +280,9 @@ Document::Document()
   m_is_backup(false),
   m_opened_from_browse(false)
 {
+  //Prevent autosaving during the constructor:
+  set_allow_autosave(false); //Prevent saving while we modify the document.
+
   m_document_format_version = get_latest_known_document_format_version(); //Default to this for new documents.
 
   //Conscious use of virtual methods in a constructor:
@@ -306,6 +309,9 @@ Document::Document()
   set_translation_original_locale(TranslatableItem::get_current_locale()); //By default, we assume that the original is in the current locale. We must do this here so that TranslatableItem::set/get_title() knows.
 
   m_app_state.signal_userlevel_changed().connect( sigc::mem_fun(*this, &Document::on_app_state_userlevel_changed) );
+
+  set_modified(false);
+  set_allow_autosave(true);
 }
 
 Document::~Document()



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