Salome HOME
Fix for bug IPAL9817 : SIGSEGV appears after "InLine" node function edition.
authormkr <mkr@opencascade.com>
Wed, 5 Oct 2005 11:43:02 +0000 (11:43 +0000)
committermkr <mkr@opencascade.com>
Wed, 5 Oct 2005 11:43:02 +0000 (11:43 +0000)
src/SUPERVGUI/SUPERVGUI_Service.cxx
src/SUPERVGUI/SUPERVGUI_Service.h
src/SUPERVGUI/SUPERV_msg_en.po

index 11d0b8fffe58f40ebab06142861639f2ba5b3b61..3afcebbf2ff55fe2c6be16c0feac03eb04271a4e 100644 (file)
@@ -904,21 +904,23 @@ void SUPERVGUI_PythonEditPane::autoIndentLine() {
 
     // get current cursor position and previous line (the one to be analized) 
     int pos, para, i;
+    QString spacesStr;
     myText->getCursorPosition( &para, &pos ); // pos==0, beginning of line
-    QString line = myText->text( para-1 ); // previous paragraph line
+    if ( myText->paragraphLength(para-1) > 0 ) { // mkr : IPAL9817
+      QString line = myText->text( para-1 ); // previous paragraph line
 
-    // construct a string containing all leading space characters of previous line (tabs, etc.)
-    QString spacesStr;
-    i = -1;
-    while ( line[++i].isSpace() ) // append all isSpace() characters at beginning of line to spacesStr
-      spacesStr += line[i];
-
-    // if ':' was found -- add more spaces to spacesStr
-    line = line.stripWhiteSpace();
-    if ( line[ line.length()-1 ] == ':' ) {
-      i = 0;
-      while ( i++ < N ) 
-       spacesStr += ' ';
+      // construct a string containing all leading space characters of previous line (tabs, etc.)
+      i = -1;
+      while ( line[++i].isSpace() ) // append all isSpace() characters at beginning of line to spacesStr
+       spacesStr += line[i];
+      
+      // if ':' was found -- add more spaces to spacesStr
+      line = line.stripWhiteSpace();
+      if ( line[ line.length()-1 ] == ':' ) {
+       i = 0;
+       while ( i++ < N ) 
+         spacesStr += ' ';
+      }
     }
 
     // ok, append spacesStr at the beginning of the current line = make indentation
@@ -975,7 +977,7 @@ SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg( bool isLoop )
   aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 );
   
   QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
-  connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) );
   aBtnLayout->addWidget( aOKBtn );
 
   aBtnLayout->addStretch();
@@ -987,6 +989,16 @@ SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg( bool isLoop )
   aMainLayout->addWidget(aBtnBox);
 }
 
+// mkr : IPAL9817 : to avoid a SIGSEGV when INode_Impl::SetPyFunction(...)
+//                  will call with null python function name
+void SUPERVGUI_EditPythonDlg::clickOnOk()
+{
+  if ( getFuncName().isEmpty() )
+    QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr( "ERROR" ), tr( "MSG_INCORRECT_INDENT" ) );
+  else  
+    accept();
+}
+
 /**
  * Do the following actions for newly created Engine's CNode:
  * 1. Create a presentation for it (CanvasNode)
index 1d9a5576c6b5c9005006def9214220f409b70380..366648ce56b2630b55c84e1278fa9c4c7f5a49a4 100644 (file)
@@ -199,6 +199,9 @@ public:
   void setNextFunction(SUPERV_Strings theStr)
     { myNextPane->setFunction(theStr); }
 
+public slots:
+  void clickOnOk();
+
 private:
   SUPERVGUI_PythonEditPane* myEditPane;
   SUPERVGUI_PythonEditPane* myInitPane;
index 8f6d0b1c39c7e2d9e5dafc8447d584e19deeb928..8d65080af78fd6d58f616cdf4ad145b5c8d8c4c4 100644 (file)
@@ -969,3 +969,6 @@ msgstr "Supervisor"
 
 msgid "TOOL_EXECUTION"
 msgstr "Execution"
+
+msgid "MSG_INCORRECT_INDENT"
+msgstr "Incorrect indent of the python function name (must be 0)!"