CVS commit by raggi: hotfix: background parser deadlock M +24 -8 cppcodecompletion.cpp 1.89 --- kdevelop/parts/cppsupport/cppcodecompletion.cpp #1.88:1.89 @@ -376,8 +376,10 @@ CppCodeCompletion::slotTextChanged() QString ch2 = strCurLine.mid( nCol-2, 2 ); - m_ccLine = nLine; - m_ccColumn = nCol; + m_ccLine = 0; + m_ccColumn = 0; if ( ch == "(" || ch == "." || ch2 == "->" || ch2 == "::" ){ + m_ccLine = nLine; + m_ccColumn = nCol; m_ccTimer->start( 500, true ); } @@ -602,4 +604,8 @@ CppCodeCompletion::completeText( ) QString expr, word; + // sync + while( m_pSupport->backgroundParser()->filesInQueue() > 0 ) + m_pSupport->backgroundParser()->isEmpty().wait(); + m_pSupport->backgroundParser()->lock(); AST* ast = m_pSupport->backgroundParser()->translationUnit( m_activeFileName ); @@ -732,4 +738,5 @@ CppCodeCompletion::completeText( ) if( FunctionDefinitionAST* def = functionDefinition(node) ){ + kdDebug(9007) << "------> found a function definition" << endl; int startLine, startColumn; @@ -737,7 +744,12 @@ CppCodeCompletion::completeText( ) QString contents = getText( startLine, startColumn, line, showArguments ? column-1 : column ); + + kdDebug(9007) << "------> computed context" << endl; + // kdDebug(9007) << "contents = |" << contents << "|" << endl; int start_expr = expressionAt( contents, contents.length() - 1 ); + + kdDebug(9007) << "------> found expression at " << start_expr << endl; // kdDebug(9007) << "start_expr = " << start_expr << endl; if( start_expr != int(contents.length()) - 1 ){ @@ -775,10 +787,10 @@ CppCodeCompletion::completeText( ) } - m_pSupport->backgroundParser()->unlock(); - type = typeName( evaluateExpression(expr, ctx) ); delete( ctx ); ctx = 0; } + + m_pSupport->backgroundParser()->unlock(); } @@ -853,4 +865,8 @@ void CppCodeCompletion::slotFileParsed( if( fileName != m_activeFileName || !m_pSupport || !m_activeEditor ) return; + + // sync + while( m_pSupport->backgroundParser()->filesInQueue() > 0 ) + m_pSupport->backgroundParser()->isEmpty().wait(); m_pSupport->backgroundParser()->lock();