Todd wrote:
...but there is no copy constructer that can create the underlying myComponent from the nsCOMPtr<myIComponent>.....

Right. The nsCOMPtr doesn't have a myComponent; it has a myIComponent. There could be several different implementations of myIComponent, in general.

In this case, you have several options:

1)  Explicitly cast comptr.get() to myComponent* if you're sure it's
    a myComponent.
2)  Have a clone() method on myIComponent that clones it.
3)  Use nsRefPtr<myComponent> instead of nsCOMPtr<myIComponent> in
     your code.

There might be other ways too, of course.

In all cases, you MUST implement a copy constructor. Not having one (as you do now) will mean that the refcount is copied too, which is just wrong.

-Boris
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to