How to handle a QList<QObject*>?

Halla Rempt halla at valdyas.org
Wed Nov 20 13:43:58 GMT 2024


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




More information about the kimageshop mailing list