Re: [wxVTK] wxAuiNotebook with wxVTK
Brought to you by:
malat
From: Mathieu M. <mat...@gm...> - 2008-04-08 15:07:41
|
Hi Kerry, I never realized that wxWindows now has a ::Destroy, http://docs.wxwidgets.org/2.8.6/wx_wxwindow.html#wxwindow My guess is that VTK->Delete() & wxWidgets::Destroy() might now have conflicting behavior. What I do not understand is that no one before experienced the issue. Is this wx->Destroy() really that new ? The thing that I still do not understand is why don't you do something like that: wxVTKObject->Delete(); wxVTKObject = NULL; // tell wx not do manipulate this pointer anymore I have not looked at this wxAUI thingy... HTH -Mathieu On Mon, Apr 7, 2008 at 10:56 PM, KR Loux <lo...@gm...> wrote: > Hello, > > I am using a wxAuiNotebook which has a page that is a > wxVTKRenderWindowInteractor. Everything works fine until I either close the > page or exit the application, at which time the application will crash or I > get an error in the VTK debug window about trying to delete an object with a > non-zero reference count, depending on how I handle deleting the > wxVTKRenderWindowInteractor (wxVTK from here on). For simplicity, I'll > focus on just the case of closing the application. If in the main frame's > destructor, I do nothing to remove the wxVTK object, I get the error about > deleting an object with a non-zero ref. count (makes sense). I added the > wxVTKObject->Delete(), which does reduce the reference count to zero, but > this causes a crash in wxObject (this is called from > wxAuiNotebook::DeletePage()): > > bool wxObject::IsKindOf(wxClassInfo *info) const > { > wxClassInfo *thisInfo = GetClassInfo();// Crashes on this line > return (thisInfo) ? thisInfo->IsKindOf(info) : false ; > } > > I think I am successfully deleting the wxVTK object with the ->Delete() > function, and then the notebook is trying to access it again in it's > destructor. Is this something anyone has experienced before? Has anyone > found a solution? > > I came up with a method that compiles and runs just fine, but I have doubts > about whether or not this is a good (safe?) approach. I have not tested for > memory leaks, but I suspect that if this method doesn't work, that will be > why. Below is the code for my main frame's destructor: > > MainFrame::~MainFrame() > { > m_mgr.UnInit(); > > if (wxVTKObject) > { > wxVTKObject->Delete();// Delete the wxVTKRenderWindowInteractor the > proper way > wxWindow *Dummy = new wxWindow();// Create a dummy wxWindow > > // Assign the pointer for the wxVTKRenderWindowInteractor to point > to a wxWindow > // object instead. Now when the wxAuiNotebook is deleted, this will > point to > // something than can be deleted? > wxVTKObject = (wxVTKRenderWindowInteractor*)Dummy; > } > } > > Is this OK? Is there a better way? > > I'm using wxWidgets 2.8.7 and VTK 5.0 in MSW. > > > Thank you for your help, > > Kerry > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Register now and save $200. Hurry, offer ends at 11:59 p.m., > Monday, April 7! Use priority code J8TLD2. > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Wxvtk-users mailing list > Wxv...@li... > https://lists.sourceforge.net/lists/listinfo/wxvtk-users > > -- Mathieu |