<p dir="ltr">Hi again, </p>
<p dir="ltr">How would you handle the case of a user adding an interface on a class marked as reference counted (like a tstringlist descendant, TArcStringList) and then inherits from that and implements the IUnknown TFooStringlist =class (TArcStringlist, IInterface).</p>
<p dir="ltr">Will he be able to hook on the addref and release methods of the arc object ? Or at the least use the refcount variable? Will it be done automatically by the compiler (by using the same method names maybe) ?</p>
<p dir="ltr">Thanks,<br>
Chriss<br>
</p>
<div class="gmail_quote">Στις 25 Σεπ 2014 6:36 μ.μ., ο χρήστης "Sven Barth" <<a href="mailto:pascaldragon@googlemail.com">pascaldragon@googlemail.com</a>> έγραψε:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On <a href="tel:25.09.2014%2017" value="+12509201417" target="_blank">25.09.2014 17</a>:23, Chriss Kalogeropoulos wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Sven,<br>
<br>
Can you comment on how are you going to handle the case of<br>
TInterfacedObject and descendants? Are you going to use the same Addref<br>
& Release method ? How can you guarantee that the same counter will be<br>
updated in case of IUnknown implementations that introduce their own<br>
refcount variable (possibly with different name)?<br>
</blockquote>
<br>
There are two cases considering my RFC:<br>
- an user uses TARCObject, then maybe we can provide a TARCInterfacedObject as well, which just implements AddRef and Release of IUnknown accordingly<br>
- an user adds the refcounted modifier to an existing class type of which one of the parents used a reference counted interface as well; the best here would be to reimplement AddRef and Release to use the reference counting methods provided by the ARC class.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Are you going to check that the class is already destroyed (because the<br>
arc has killed the instance) on IInterface.Release so that we should not<br>
get access violations on scenarios that mix ref counted classes and<br>
interfaces ?<br>
</blockquote>
<br>
This is not possible as in that case the reference would already be gone. But if you implemented the IUnknown reference counting using the ARC one then there shouldn't be any stray Release calls anyway, except a C++ (or another language that has no automatic reference counting for IUnknown) library has a bug regarding reference counting.<br>
<br>
Regards,<br>
Sven<br>
______________________________<u></u>_________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" target="_blank">http://lists.freepascal.org/<u></u>cgi-bin/mailman/listinfo/fpc-<u></u>devel</a><br>
</blockquote></div>