// get current cursor position and previous line (the one to be analized)
int pos, para, i;
+ QString spacesStr;
myText->getCursorPosition( ¶, &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
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();
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)