[QScintilla] Odd crash with autocompletion
Randall Frank
rjfrank at ensight.com
Mon Oct 20 19:52:01 BST 2008
Hello,
I built a little editor for Python scripts using
QScintilla and registered some of my own Python API
for autocompletion. When I run this, the first
autocompletion works just fine, the second time
I trigger the autocomplete popup, I get a crash
looking something like this:
#0 0x00002b95ca782380 in QsciAPIs::positionOrigin (this=0x686880,
context=@0x7fffe05b6c40, path=@0x7fffe05b6b30) at qsciapis.cpp:329
#1 0x00002b95ca782ad4 in QsciAPIs::updateAutoCompletionList (this=0x686880,
context=@0x7fffe05b6c40, list=@0x7fffe05b6c20) at qsciapis.cpp:407
#2 0x00002b95ca779471 in QsciScintilla::startAutoCompletion (this=0x763de0,
acs=QsciScintilla::AcsAPIs, checkThresh=false, single=false)
at qsciscintilla.cpp:660
#3 0x00002b95ca779c3e in QsciScintilla::handleCharAdded (this=0x763de0,
ch=46)
at qsciscintilla.cpp:232
I am building the objects like this:
lexer = new QsciLexerPython();
lexer->setDefaultFont( getDefaultEditorFont() );
lexer->setFont( getDefaultEditorFont() );
API = new QsciAPIs(lexer);
lexer->setAPIs(API);
text->setLexer(lexer);
text->setMarginWidth(0,QString("00000"));
text->setMarginLineNumbers(0,TRUE);
text->setMarginWidth(2,QString("00000"));
QFont my_font2( text->font() );
my_font2.setStyleHint( QFont::TypeWriter );
my_font2.setFixedPitch( TRUE );
text->setEolMode(QsciScintilla::EolUnix);
text->setMarginsFont( my_font2 );
text->setFolding(QsciScintilla::CircledTreeFoldStyle);
text->setIndentationGuides(TRUE);
text->setIndentationsUseTabs(FALSE);
text->setIndentationWidth(4);
text->setAutoIndent(TRUE);
text->setTabIndents(TRUE);
text->setTabWidth(4);
I fill API with code like this:
FILE *fp = fopen("lines","r");
char tstr[100];
while(fgets(tstr,sizeof(tstr)-1,fp)) {
API->add(tstr+8);
}
fclose(fp);
menuAutoComplete->setEnabled(FALSE);
API->prepare();
connect( API, SIGNAL( apiPreparationFinished() ), this,
SLOT( apiPrepared() ));
Where apiPrepared() enables the menuAutoComplete QAction
toggle. Finally, I am enabling autocompletion using a
menu with the following method:
void EnsScriptEditor::toggleAutoComplete( bool on)
{
text->setAutoCompletionSource(on ? QsciScintilla::AcsAPIs :
QsciScintilla::AcsNone);
}
I guess the first question is what am I doing wrong?
The second would be has anyone else see this type of
behavior?
I have a small (single file) example app that exhibits
the crash. The odd part is that it works properly
for the first autocompletion. FYI: I get the same
crash with 64bit Linux and 64bit Windows XP.
I have tried QScintilla commercial 2.2 and 2.3
with Qt 4.4.1.
Thanks.
--
rjf
------------------------------------------------------
Randall Frank rjfrank at ensight.com 919-363-0883
Computational Engineering International www.ceintl.com
2166 North Salem St, Suite 101, Apex, NC 27523-6456
More information about the QScintilla
mailing list