[glom: 12/12] * glom/libglom/document/document.cc: load_after(), save_before():



commit ac0a09023efea7e0485556237b9e3f4349f70e55
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Oct 16 11:34:08 2009 +0200

    * glom/libglom/document/document.cc: load_after(), save_before():
    Avoid crashes when load/saving singular_titles.

 ChangeLog                         |    5 +++++
 glom/libglom/document/document.cc |    5 ++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1785880..09cad72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-10-16  Murray Cumming  <murrayc murrayc com>
 
+	* glom/libglom/document/document.cc: load_after(), save_before(): 
+	Avoid crashes when load/saving singular_titles.
+
+2009-10-16  Murray Cumming  <murrayc murrayc com>
+
 	Maemo: Allow Relationships to have singular titles too. Use them.
 	
 	* glom/libglom/data_structure/has_title_singular.[h|cc]: Added this new 
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index a52fe84..864c72e 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -2324,6 +2324,9 @@ void Document::load_after_translations(const xmlpp::Element* element, Translatab
   if(has_title_singular)
   {
     const xmlpp::Element* nodeTitleSingular = get_node_child_named(element, GLOM_NODE_TABLE_TITLE_SINGULAR);
+    if(!has_title_singular->m_title_singular)
+     has_title_singular->m_title_singular = sharedptr<TranslatableItem>::create();
+
     load_after_translations(nodeTitleSingular, *(has_title_singular->m_title_singular));
   }
 }
@@ -3240,7 +3243,7 @@ void Document::save_before_translations(xmlpp::Element* element, const Translata
   //If it has a singular title, then save that too:
   const HasTitleSingular* has_title_singular = 
     dynamic_cast<const HasTitleSingular*>(&item);
-  if(has_title_singular)
+  if(has_title_singular && has_title_singular->m_title_singular)
   {
     xmlpp::Element* nodeTitleSingular = element->add_child(GLOM_NODE_TABLE_TITLE_SINGULAR);
     save_before_translations(nodeTitleSingular, *(has_title_singular->m_title_singular));



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