Fix SEGV when hovering on symbols after creating a new project. This resolves issue #40.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/41/head
Michele Calgaro 10 months ago
parent 35fbd60457
commit 46b407f26c
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -2050,14 +2050,13 @@ void CppCodeCompletion::needRecoveryPoints() {
if ( this->d->recoveryPoints.isEmpty() ) {
kdDebug( 9007 ) << "missing recovery-points for file " << m_activeFileName << " they have to be computed now" << endl;
m_pSupport->backgroundParser() ->lock ()
;
m_pSupport->backgroundParser() ->lock();
std::vector<CppCodeCompletion> vec;
TranslationUnitAST * ast = *m_pSupport->backgroundParser() ->translationUnit( m_activeFileName );
ParsedFilePointer pTransUnit = m_pSupport->backgroundParser() ->translationUnit( m_activeFileName );
m_pSupport->backgroundParser() ->unlock();
if ( !ast ) {
if ( !pTransUnit ) {
kdDebug( 9007 ) << "background-parser is missing the translation-unit. The file needs to be reparsed." << endl;
m_pSupport->parseFileAndDependencies( m_activeFileName, true );
// m_pSupport->mainWindow() ->statusBar() ->message( i18n( "Background-parser is missing the necessary translation-unit. It will be computed, but this completion will fail." ).arg( m_activeFileName ), 2000 );
@ -2684,7 +2683,10 @@ void CppCodeCompletion::completeText( bool invokedOnDemand /*= false*/ ) {
///@todo is all this necessary?
if ( !recoveredDecl.get() && !recoveredTypeSpec.get() ) {
TranslationUnitAST * ast = *m_pSupport->backgroundParser() ->translationUnit( m_activeFileName );
ParsedFilePointer pTransUnit = m_pSupport->backgroundParser() ->translationUnit(m_activeFileName);
if (pTransUnit)
{
TranslationUnitAST *ast = *pTransUnit;
if ( AST * node = findNodeAt( ast, line, column ) ) {
kdDebug( 9007 ) << "------------------- AST FOUND --------------------" << endl;
kdDebug( 9007 ) << "node-kind = " << nodeTypeToString( node->nodeType() ) << endl;
@ -2751,6 +2753,7 @@ void CppCodeCompletion::completeText( bool invokedOnDemand /*= false*/ ) {
}
}
}
}
if ( !ctx )
return ;

@ -1699,7 +1699,10 @@ void CppSupportPart::slotNeedTextHint( int line, int column, TQString& textHint
return ;
m_backgroundParser->lock();
TranslationUnitAST* ast = *m_backgroundParser->translationUnit( m_activeFileName );
ParsedFilePointer pTransUnit = m_backgroundParser->translationUnit(m_activeFileName);
if (pTransUnit)
{
TranslationUnitAST* ast = *pTransUnit;
AST* node = 0;
if ( ast && ( node = findNodeAt( ast, line, column ) ) )
{
@ -1720,6 +1723,7 @@ void CppSupportPart::slotNeedTextHint( int line, int column, TQString& textHint
textHint = m_activeEditor->textLine( startLine ).simplifyWhiteSpace();
}
}
}
m_backgroundParser->unlock();
}

Loading…
Cancel
Save