How to handle a QList<QObject*>?

Dmitry Kazakov dimula73 at gmail.com
Wed Nov 20 14:14:01 GMT 2024


Oh, that sounds a be weird... We should also think about
backward-compatibility now.

On Wed, Nov 20, 2024 at 2:44 PM Halla Rempt <halla at valdyas.org> wrote:

> Hi,
>
> I'm trying to fix an issue I created myself years ago (
> https://bugs.kde.org/show_bug.cgi?id=495802), but I'm currently stumped...
>
> I've written a small C++ library to provide a simplified API to make
> scripting in Krita possible.
>
> In several places, I create a QList<SomeObject*> and return that, like:
>
> header:
>
> QList<Document*> documents() const;
>
> cpp:
>
> QList<Document *> Krita::documents() const
> {
>     QList<Document *> ret;
>     foreach(QPointer<KisDocument> doc, KisPart::instance()->documents()) {
>         ret << new Document(doc, false);
>     }
>     return ret;
> }
>
>
> Document.sip
>
> QList<Document *> documents() const /Factory/;
>
> Now the Document* objects apparently aren't deleted when the list go out
> of scope. I thought the /Factory/ annotation would take care of that...
>
> Is there a generally "right" way of handling this situation?
>
> Thanks,
>
> Halla
>
>
>

-- 
Dmitry Kazakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kimageshop/attachments/20241120/5f16407a/attachment.htm>


More information about the kimageshop mailing list