<br>Right now we have the concept of global context and the concept of local context. <br>runners copy the global context in a local context, work with it and when finished, use a SearchContext::addMatchesTo(SeachContext ) to add the matches to the global shared context. <br>
This means copies here and there, to avoid that, we can share data. <br>If we try to have shared data, we do not need to detach from the shared object when:<br>-reading<br clear="all">-Adding matches<br>-Adding completions<br>
<br>We need to detach when:<br>
- modifying the term. Which modifies the type and mime. And surely will
render matches and completions obsolete. So, instead of making a
context from other context it will be better just to initialize an
unrelated context. Modified term means a new context so we don't
support detaching in that case.<br><br>
- deleting/clearing matches or completions. One context will not delete
other context matches. So what we want is to clear one given context
matches. Or what is the same: create a new context with already given
term, type and mime. Create a copy constructor that copies that info
and initialized a private clear matches /completions lists. <br>
<br><br>So basically, detach can be avoided. We can always
context1.addMatches( context2.matches()) if it is needed to add matches
from any new context to an older one. (addMatchesTo will be deleted
also).<br>So SearchContext will use internally a QExplicitilySharedDataPointer and I think there is no need to write a copy constructor but if it does I guess it will be like:<br><br>SearchContext::SearchContext(const SearchContext &other, QObject *parent)<br>
: QObject(parent), <br> d(new Private(Shared))<br>{<br> other.d->lockForRead();<br> //d=other.d;<br> other.d->unlock<br>}<br clear="all"><br>-- <br>Jordi Polo Carres<br>NLP laboratory - NAIST<br>
<a href="http://www.bahasara.org">http://www.bahasara.org</a><br>