Remove TopContext with all declarations

David nolden zwabel at googlemail.com
Tue Jan 27 08:14:23 UTC 2009


Am Dienstag 27 Januar 2009 00:23:21 schrieb Milian Wolff:
> Am Montag 26 Januar 2009 schrieb Milian Wolff:
> > Hi there!
> >
> > I'm working on the PHP plugin and encountered a strange bug/feature I
> > cannot get fixed.
>
> I think I an idea on what could be the issue:
> > In the completion test (completion/tests/test_completion.cpp) I parse
> > some PHP-Code and get a TopDUContext. Once the test is done, I call
> > release(top) which essentially calls 
> > DUChain::self()->removeDocumentChain(top).
>
> Essentially, this problem occurred because one of  the earlier tests failed
> and thus the release(top) was never called...
>
> Nothing I can do except making sure all tests pass, right?

C++ gives us a simple tool for this:

struct DUChainReleaser {
DUChainReleaser(TopDUContext* top) : m_top(top) {
}
~DUChainRelease() {
release(m_top);
}
TopDUContext* m_top;
};


In your test:

top = parse
lock
DUChainReleaser autoRelease(top);
do whatever you want




More information about the KDevelop-devel mailing list