How to handle a QList<QObject*>?

Halla Rempt halla at valdyas.org
Wed Nov 20 14:16:06 GMT 2024


Yes, that stumped me, too...


On woensdag 20 november 2024 15:14:01 Midden-Europese standaardtijd Dmitry Kazakov wrote:
> 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
> >
> >
> >
> 
> 






More information about the kimageshop mailing list