[Interest] QGaphicsItem deletion

Konstantin Shegunov kshegunov at gmail.com
Wed Jun 15 15:59:25 CEST 2016


Hello,


On Wed, Jun 15, 2016 at 4:15 PM, Igor Mironchik <igor.mironchik at gmail.com>
wrote:
>
> Parent of the handles is the same as Line's. But Line own objects of
> handles with QScopedPointer.
>

This doesn't sound right. If the handles are not children to the line, then
the line doesn't own them. Leaving semantics aside, it sounds you're trying
to "hijack" the ownership from the parent by using these scoped pointers.


> So my question is it possible that handle will be deleted before Line, so
> QScopedPointer will try to free already deleted pointer?
>

>From your description I'd guess this is exactly what's happening.

Kind regards.


On Wed, Jun 15, 2016 at 4:15 PM, Igor Mironchik <igor.mironchik at gmail.com>
wrote:

> Hi folks,
>
> Let's say I have QGraphicsItem, let it be Line. This Line has move handles
> - another QGraphicsItems, rectangles. Parent of the handles is the same as
> Line's. But Line own objects of handles with QScopedPointer.
>
> When Line creates in c_tor() it creates handles, so handles adds to the
> scene after Line. When I delete Line from the scene by hand everything is
> fine: Line deletes and QScopedPointers free handles.
>
> But if I close application and scene destroys with d_tor() in which it
> deletes all child items. So my question is it possible that handle will be
> deleted before Line, so QScopedPointer will try to free already deleted
> pointer?
>
> Thank you.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160615/349df25b/attachment.html>


More information about the Interest mailing list