Salome HOME
Fix a bug: an exception is raised when attempting to display root object V3_1_0a3
authorvsr <vsr@opencascade.com>
Mon, 14 Nov 2005 11:43:48 +0000 (11:43 +0000)
committervsr <vsr@opencascade.com>
Mon, 14 Nov 2005 11:43:48 +0000 (11:43 +0000)
src/LIGHTGUI/LIGHTGUI.cxx
src/LIGHTGUI/LIGHTGUI_DataModel.cxx
src/LIGHTGUI/LIGHT_msg_en.po

index 05aa062c0db89f05f8ca3f7ffe0af4510787bdfa..548b8471fa6c7fb2eb48710f383717878164f8b5 100644 (file)
@@ -278,7 +278,7 @@ void LIGHTGUI::onDisplayLine()
   double aX = 0, aY = 0, aZ = 0;
   QString aStrId = QString("LIGHTGUI_%1").arg(aPosition);
 
-  Handle(LIGHTGUI_TextPrs) aPrs = new LIGHTGUI_TextPrs( aLine, gp_Pnt( aX, aY, aZ ) );
+  Handle(LIGHTGUI_TextPrs) aPrs = new LIGHTGUI_TextPrs( aLine.isNull() ? "" : aLine, gp_Pnt( aX, aY, aZ ) );
   aPrs->SetOwner(new SALOME_InteractiveObject( aStrId, "" ) );
   SOCC_Prs* prs = dynamic_cast<SOCC_Prs*>( aViewer->CreatePrs() ); // aStringID is an "entry"
   if ( prs ) {
index 24615657e9ddba708281db6df145b625429a8f2f..5d7befe6ae65bfdf5ea57ef730bee805b6709389 100644 (file)
@@ -309,9 +309,10 @@ bool LIGHTGUI_DataModel::insertLineBefore ( const int thePosition, const QString
   // Insert new line before the item at thePosition in the list,
   // or at the end() if thePosition is out of range
   LIGHTGUI_ModuleObject* modelRoot = dynamic_cast<LIGHTGUI_ModuleObject*>( root() );
-  if ( !modelRoot )
-    return false;
+  LightApp_Study* study = dynamic_cast<LightApp_Study*>( module()->application()->activeStudy() );
   if ( thePosition > 0 ) {
+    if ( !modelRoot )
+      return false;
     LIGHTGUI_DataObject* obj = findObject( thePosition );
     if ( !obj || !obj->parent() )
       return false;
@@ -345,8 +346,16 @@ bool LIGHTGUI_DataModel::insertLineBefore ( const int thePosition, const QString
   }
   else {
     // append new paragraph/line
-    theText.stripWhiteSpace().isEmpty() ? new LIGHTGUI_DataObject( theText, modelRoot ) : 
-                                          new LIGHTGUI_DataObject( theText, modelRoot->lastChild() );
+    if ( modelRoot )
+      theText.stripWhiteSpace().isEmpty() ? new LIGHTGUI_DataObject( theText, modelRoot ) : 
+                                           new LIGHTGUI_DataObject( theText, modelRoot->lastChild() );
+    else {
+      QStringList lines;
+      if ( !theText.stripWhiteSpace().isEmpty() ) 
+       lines.append( theText );
+      buildTree( study->root(), lines );
+    }
+      
   }
   return true;
 }
index 3ea89c2c22b01202f285a84f4f2590fb76015b7f..88ce42dc3049d3bafdd14bfef262f5fc988bfee6 100644 (file)
@@ -149,6 +149,9 @@ msgstr "Wrong selection!"
 msgid "WRN_EDIT_FAILED"
 msgstr "Can't edit line!"
 
+msgid "WRN_ADD_FAILED"
+msgstr "Can't insert line!"
+
 msgid "WRN_UNKNOWN_COMMAND"
 msgstr "Unrecognized command!"
 
@@ -162,4 +165,4 @@ msgid "LIGHT_LINE"
 msgstr "Line"
 
 msgid "LIGHT_ROOT_TOOLTIP"
-msgstr "LIGHT module root object"
\ No newline at end of file
+msgstr "LIGHT module root object"