From 7c71b1bf38add9ae086d4af254ba97e94a3e518e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 16 Feb 2009 11:20:11 +0100 Subject: [PATCH] Fixed crash on updating function argument widget Crashed for example in the case of template instantiation. To make sure the Function* stays valid, we need to not only keep around the Snapshot but the whole LookupContext. Done with Roberto Raggi. --- src/plugins/cpptools/cppcodecompletion.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index bca1d576e9f..f06b88ec303 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -78,7 +78,7 @@ class FunctionArgumentWidget : public QLabel { public: FunctionArgumentWidget(); - void showFunctionHint(Function *functionSymbol, const Snapshot &snapshot); + void showFunctionHint(Function *functionSymbol, const LookupContext &context); protected: bool eventFilter(QObject *obj, QEvent *e); @@ -95,7 +95,7 @@ private: QFrame *m_popupFrame; Function *m_item; - Snapshot m_snapshot; + LookupContext m_context; }; class ConvertToCompletionItem: protected NameVisitor @@ -215,10 +215,10 @@ FunctionArgumentWidget::FunctionArgumentWidget() } void FunctionArgumentWidget::showFunctionHint(Function *functionSymbol, - const Snapshot &snapshot) + const LookupContext &context) { m_item = functionSymbol; - m_snapshot = snapshot; + m_context = context; m_startpos = m_editor->position(); // update the text @@ -1041,7 +1041,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) QTC_ASSERT(function, return); m_functionArgumentWidget = new FunctionArgumentWidget(); - m_functionArgumentWidget->showFunctionHint(function, typeOfExpression.snapshot()); + m_functionArgumentWidget->showFunctionHint(function, typeOfExpression.lookupContext()); } } else if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) { QString toInsert = item.m_text;