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 22:11:45 +0900 |
commit | e4efa087f111e66561a464433f530b6c794e0161 (patch) | |
tree | dd820a070d34b941597ac239da1ef872303d1c6c /languages/cpp/cppsupportpart.cpp | |
parent | 0b6a83b773c37ee6949d73346c4a669aa1fc98b8 (diff) | |
download | tdevelop-e4efa087f111e66561a464433f530b6c794e0161.tar.gz tdevelop-e4efa087f111e66561a464433f530b6c794e0161.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>
(cherry picked from commit 46b407f26cf98c494f646609a37d03be4c41e11a)
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(); |