Re: How to handle a QList<QObject*>?

Dmitry Kazakov <[email protected]> Wed, 20 Nov 2024 15:14:01 +0100
Newsgroups gmane.comp.kde.devel.krita,gmane.comp.python.pyqt-pykde
Message-ID <CAEkBSfUa+p5oVrATP5sqEvRhT4fQsePHWa4CUnfAcGwb5wpUjA@mail.gmail.com>
--0000000000009d583f062758c3c1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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

On Wed, Nov 20, 2024 at 2:44=E2=80=AFPM Halla Rempt <halla-4ZnIdb/[email protected]> wro=
te:

> Hi,
>
> I'm trying to fix an issue I created myself years ago (
> https://bugs.kde.org/show_bug.cgi?id=3D495802), 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
>
>
>

--=20
Dmitry Kazakov

--0000000000009d583f062758c3c1
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Oh, that sounds a be weird... We should also think about b=
ackward-compatibility now.<br></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr" class=3D"gmail_attr">On Wed, Nov 20, 2024 at 2:44=E2=80=AFPM Halla=
 Rempt &lt;<a href=3D"mailto:halla-4ZnIdb/[email protected]">halla-4ZnIdb/[email protected]</a>&gt; w=
rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I&#39;m trying to fix an issue I created myself years ago (<a href=3D"https=
://bugs.kde.org/show_bug.cgi?id=3D495802" rel=3D"noreferrer" target=3D"_bla=
nk">https://bugs.kde.org/show_bug.cgi?id=3D495802</a>), but I&#39;m current=
ly stumped...<br>
<br>
I&#39;ve written a small C++ library to provide a simplified API to make sc=
ripting in Krita possible.<br>
<br>
In several places, I create a QList&lt;SomeObject*&gt; and return that, lik=
e:<br>
<br>
header:<br>
<br>
QList&lt;Document*&gt; documents() const;<br>
<br>
cpp:<br>
<br>
QList&lt;Document *&gt; Krita::documents() const<br>
{<br>
=C2=A0 =C2=A0 QList&lt;Document *&gt; ret;<br>
=C2=A0 =C2=A0 foreach(QPointer&lt;KisDocument&gt; doc, KisPart::instance()-=
&gt;documents()) {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret &lt;&lt; new Document(doc, false);<br>
=C2=A0 =C2=A0 }<br>
=C2=A0 =C2=A0 return ret;<br>
}<br>
<br>
<br>
Document.sip<br>
<br>
QList&lt;Document *&gt; documents() const /Factory/;<br>
<br>
Now the Document* objects apparently aren&#39;t deleted when the list go ou=
t of scope. I thought the /Factory/ annotation would take care of that...<b=
r>
<br>
Is there a generally &quot;right&quot; way of handling this situation?<br>
<br>
Thanks,<br>
<br>
Halla<br>
<br>
<br>
</blockquote></div><div><br clear=3D"all"></div><br><span class=3D"gmail_si=
gnature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature">Dm=
itry Kazakov</div>

--0000000000009d583f062758c3c1--