diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-01-31 12:59:03 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-02-02 09:51:11 +0900 |
commit | 46b407f26cf98c494f646609a37d03be4c41e11a (patch) | |
tree | 08c2b37c652f945beb3bdd1fa98e2a15682a9e67 /languages/cpp/cppsupportpart.cpp | |
parent | 35fbd60457d1e51e6a0df5d181d1a0f00ad75a2c (diff) | |
download | tdevelop-46b407f26cf98c494f646609a37d03be4c41e11a.tar.gz tdevelop-46b407f26cf98c494f646609a37d03be4c41e11a.zip |
Fix SEGV when hovering on symbols after creating a new project. This resolves issue #40.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'languages/cpp/cppsupportpart.cpp')
-rw-r--r-- | languages/cpp/cppsupportpart.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/languages/cpp/cppsupportpart.cpp b/languages/cpp/cppsupportpart.cpp index 01b34a43..c94539de 100644 --- a/languages/cpp/cppsupportpart.cpp +++ b/languages/cpp/cppsupportpart.cpp @@ -1699,25 +1699,29 @@ void CppSupportPart::slotNeedTextHint( int line, int column, TQString& textHint return ; m_backgroundParser->lock(); - TranslationUnitAST* ast = *m_backgroundParser->translationUnit( m_activeFileName ); - AST* node = 0; - if ( ast && ( node = findNodeAt( ast, line, column ) ) ) + ParsedFilePointer pTransUnit = m_backgroundParser->translationUnit(m_activeFileName); + if (pTransUnit) { + TranslationUnitAST* ast = *pTransUnit; + AST* node = 0; + if ( ast && ( node = findNodeAt( ast, line, column ) ) ) + { - while ( node && node->nodeType() != NodeType_FunctionDefinition ) - node = node->parent(); + while ( node && node->nodeType() != NodeType_FunctionDefinition ) + node = node->parent(); - if ( node ) - { - int startLine, startColumn; - int endLine, endColumn; - node->getStartPosition( &startLine, &startColumn ); - node->getEndPosition( &endLine, &endColumn ); + if ( node ) + { + int startLine, startColumn; + int endLine, endColumn; + node->getStartPosition( &startLine, &startColumn ); + node->getEndPosition( &endLine, &endColumn ); - if ( !node->text().isNull() ) - textHint = node->text(); - else - textHint = m_activeEditor->textLine( startLine ).simplifyWhiteSpace(); + if ( !node->text().isNull() ) + textHint = node->text(); + else + textHint = m_activeEditor->textLine( startLine ).simplifyWhiteSpace(); + } } } m_backgroundParser->unlock(); |