From cceaffca5bfeb0cb54ccad64602391234595abd9 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 4 Jun 2010 17:58:29 +0200 Subject: Keep the Control around for as long needed. --- src/libs/cplusplus/LookupContext.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/libs/cplusplus/LookupContext.cpp') diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 21cecac3098..4e035dbca3a 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -90,13 +90,15 @@ bool ClassOrNamespace::CompareName::operator()(const Name *name, const Name *oth // LookupContext ///////////////////////////////////////////////////////////////////// LookupContext::LookupContext() + : _control(new Control()) { } LookupContext::LookupContext(Document::Ptr thisDocument, const Snapshot &snapshot) : _expressionDocument(Document::create("")), _thisDocument(thisDocument), - _snapshot(snapshot) + _snapshot(snapshot), + _control(new Control()) { } @@ -105,7 +107,8 @@ LookupContext::LookupContext(Document::Ptr expressionDocument, const Snapshot &snapshot) : _expressionDocument(expressionDocument), _thisDocument(thisDocument), - _snapshot(snapshot) + _snapshot(snapshot), + _control(new Control()) { } @@ -113,7 +116,8 @@ LookupContext::LookupContext(const LookupContext &other) : _expressionDocument(other._expressionDocument), _thisDocument(other._thisDocument), _snapshot(other._snapshot), - _bindings(other._bindings) + _bindings(other._bindings), + _control(other._control) { } LookupContext &LookupContext::operator = (const LookupContext &other) @@ -122,6 +126,7 @@ LookupContext &LookupContext::operator = (const LookupContext &other) _thisDocument = other._thisDocument; _snapshot = other._snapshot; _bindings = other._bindings; + _control = other._control; return *this; } @@ -135,7 +140,7 @@ QList LookupContext::fullyQualifiedName(Symbol *symbol) QSharedPointer LookupContext::bindings() const { if (! _bindings) - _bindings = QSharedPointer(new CreateBindings(_thisDocument, _snapshot)); + _bindings = QSharedPointer(new CreateBindings(_thisDocument, _snapshot, control())); return _bindings; } @@ -145,8 +150,10 @@ void LookupContext::setBindings(QSharedPointer bindings) _bindings = bindings; } -Control *LookupContext::control() const -{ return bindings()->control(); } +QSharedPointer LookupContext::control() const +{ + return _control; +} Document::Ptr LookupContext::expressionDocument() const { return _expressionDocument; } @@ -618,10 +625,9 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name) return 0; } -CreateBindings::CreateBindings(Document::Ptr thisDocument, const Snapshot &snapshot) - : _snapshot(snapshot) +CreateBindings::CreateBindings(Document::Ptr thisDocument, const Snapshot &snapshot, QSharedPointer control) + : _snapshot(snapshot), _control(control) { - _control = new Control(); _globalNamespace = allocClassOrNamespace(/*parent = */ 0); _currentClassOrNamespace = _globalNamespace; @@ -631,7 +637,6 @@ CreateBindings::CreateBindings(Document::Ptr thisDocument, const Snapshot &snaps CreateBindings::~CreateBindings() { qDeleteAll(_entities); - delete _control; } ClassOrNamespace *CreateBindings::switchCurrentClassOrNamespace(ClassOrNamespace *classOrNamespace) @@ -673,7 +678,7 @@ void CreateBindings::process(Symbol *symbol) _currentClassOrNamespace->addTodo(symbol); } -Control *CreateBindings::control() const +QSharedPointer CreateBindings::control() const { return _control; } -- cgit v1.2.3