[vtkusers] Deleting vtkoutputwindows used by SetInstance

Shawn Waldon shawn.waldon at kitware.com
Mon Apr 17 09:56:57 EDT 2017


Hi David,

I suspect the problem is that you are creating a VTK smartpointer and then
deleting the object yourself (to transfer ownership according to the
comment).  But when the vtkSmartPointer on the stack is deleted it calls
Delete() on the object it references.  So you are decrementing the
reference count twice and cancelling the vtkOutputWindow's ownership of the
object.  Remove the line IOutputWindow->Delete() and I think it will
resolve the problem.

You can learn more about vtk's smart pointer here [1].

HTH,
Shawn

[1]: http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers

On Fri, Apr 14, 2017 at 3:46 PM, Mwoua <david.levy at leddartech.com> wrote:

> Hello,
> I'm using Qt + VTK on windows.
>
> When I open my VTK window I redirect vtk error message using (in my
> constructor)
>
>         vtkSmartPointer<CustomOutputWindow> lOutputWindow =
> vtkSmartPointer<CustomOutputWindow>::New();
>         vtkOutputWindow::SetInstance(lOutputWindow);
>         lOutputWindow->Delete(); // now SetInstance owns the reference
>
> So when I close my window, I have nothing that is using VTK left, so I
> would
> like to delete my output window. (calling Delete() cause a read access
> violation)
>
> Also, if I try to call SetInstance again, with another CustomOutputWindow,
> I
> also have a read access violation (vtkOutputWindow::Instance->Delete(); in
> file vtkOutputWindow.cxx)
>
> How can I delete my object?
>
>
> PS : setinstance also prevent my display from working on an older computer,
> if I dont use it, I have a message saying that the chipset is old and might
> not work, but besides that it works. If I try to use setinstance, the
> display does not work.
>
> Thanks,
> David
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.
> com/Deleting-vtkoutputwindows-used-by-SetInstance-tp5742892.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170417/4d90b61d/attachment.html>


More information about the vtkusers mailing list