[vtkusers] Multiple wxVTKRenderWindow: Segmentation fault (core dumped)
Uwe Rempler
rempler at mechbau.uni-stuttgart.de
Tue Jan 27 07:52:40 EST 2004
Charl P. Botha wrote:
> On Thu, 2004-01-22 at 12:57, Uwe Rempler wrote:
>
>
>
>> thank you very much for your fast reply
>> got just a few more "little" questions:
>> did you just open the windows or did you also try to close them?
>>
>
>
> Open a few, close a few, open a few. It doesn't break here.
>
>
>
>> do you run your software also with just one MainLoop()?
>>
>
>
> Of course.
>
>
>
>> do you open multiple windows by creating new instances of wxFrame() -
>> like in my sample code?
>>
>
>
> I do something similar. In essence, each wxVTKRenderWindowInteractor
> has its own frame. The user is free to open and destroy as many of
> those as he/she wants.
>
>
>
>> which debugger do you use?
>>
>
>
> gdb
>
>
>
>> would you please try to open two windows in a row and close the first
>> opened before the second one - sometimes opening a couple of windows
>> works for me just fine but when i try to close then not in the right
>> order *bam* core dump
>>
>
>
> It didn't break.
>
>
>
>> it also works whem i'm quiting the application (after creating some
>> windows) with the exit button - EndMainLoop() ...
>>
>
>
> Okay. This (and the other segfaults you're seeing) could have something
> to do with the way in which you destroy your windows. The
> wxVTKRenderWindow doesn't automatically get destroyed when you destroy
> the parent window. You have to dissociate the renderwindow from wx
> before you Destroy the wxFrame. Do this by calling WindowRemap on the
> encapsulated vtkRenderWindow so it dissociates and creates its OWN
> window. Then destroy the wx part and the VTK part separately by calling
> Destroy on the wx part, and making sure that you have no refs left to
> the vtk part.
>
> I have been making changes to VTK (primarily the Finalize() and
> Initialize() additions to the various RenderWindows), but this is a
> long-term plan. At the moment, I'm waiting for a Mac expert to make the
> required changes on the Mac RenderWindows before I can take
> Finalize/Initialize up to the abstract interface. At that stage, it
> will be easier to destroy a wxWindow containing a renderwindow.
>
> Good luck,
> Charl
>
>
>
hi list,
still have problems using multiple instances of wxVTKRenderWindow()...
i tried to compile the CVS-version of VTK and wxPython but i couldn't
manage to create new wxPython libs with gtk v2.x (just gtk v1.2) - VTK
v4.5.0 works just fine... so in the moment i depend on wxPython v2.4.2.4
made a few changes in my code to dissociate the VTK-part from the
wx-part just as charl suggested it but i still can't do a clean exit on
a single window...
besides when i'm trying to start the app i'm getting strange
error-messesages from time to time (not always just about every second
or third try...?):
#
------------------------------------------------------------------------------
Gdk-ERROR **: BadWindow (invalid Window parameter)
serial 214 error_code 3 request_code 15 minor_code 0
or sometimes:
#
------------------------------------------------------------------------------
Gdk-ERROR **: BadDrawable (invalid Pixmap or Window parameter)
serial 212 error_code 9 request_code 14 minor_code 0
closing a window provides:
#
------------------------------------------------------------------------------
Gdk-ERROR **: BadValue (integer parameter out of range for operation)
serial 8 error_code 2 request_code 78 minor_code 0
would you please try to run the following code (maybe without the
cvs_vtk-import-part on your machines - do you get the same
error-messages? could this be a local problem on my system? i found some
mailings in which these errors were identified as a xlib-bug - but the
discussions are dated around 03/2003...
#!/usr/bin/python
#
------------------------------------------------------------------------------
import sys
import os
#
------------------------------------------------------------------------------
# implement CVS-VTK
new_path = []
zaehler = 1
for i in sys.path:
zaehler = zaehler + 1
if i != '/usr/lib/python2.3/site-packages/vtk_python':
new_path.append(i)
new_path.append('/scratch/local/rempler/download/CVS_VTK/VTK/Wrapping/Python')
new_path.append('/scratch/local/rempler/download/CVS_VTK/VTK/bin')
sys.path = new_path
#
------------------------------------------------------------------------------
import wxPython.wx
import wx
#
------------------------------------------------------------------------------
# check which VTK-version
import vtk
print "VTK-Version:"; print '-' * len('VTK-Version:'); print
vtk.vtkVersion.GetVTKVersion()
print
#
------------------------------------------------------------------------------
from vtk.wx.wxVTKRenderWindow import *
#
------------------------------------------------------------------------------
[wxID_PANMAINWIN, wxID_PANMAINWINBUTTON1,
wxID_PANMAINWINBUTTON2,
] = map(lambda _init_ctrls: wxNewId(), range(3))
[wxID_PANVISWIN, wxID_PANVISWINBTNCLOSE,
] = map(lambda _init_ctrls: wxNewId(), range(2))
#
------------------------------------------------------------------------------
class PanVisWin(wxFrame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wxFrame.__init__(self, id=wxID_PANVISWIN,
name='PanVisualizeWindows', parent=prnt, pos=wxPoint(640,
393),
size=wxSize(600, 600), style=wxDEFAULT_FRAME_STYLE,
title='PanVisWin')
self.SetClientSize(wxSize(600, 600))
self.button1 = wxButton(id=wxID_PANVISWINBTNCLOSE, label='Close',
name='button1', parent=self, pos=wxPoint(500, 500),
size=wxSize(100, 100), style=0)
EVT_BUTTON(self.button1, wxID_PANVISWINBTNCLOSE,
self.OncloseButton)
# ----------------------------- VTK BEGIN
------------------------------
self.widget = wxVTKRenderWindow(self, -1, pos=wxPoint(100, 100),
size=wxSize(400,400))
self.ren = vtkRenderer()
self.widget.GetRenderWindow().AddRenderer(self.ren)
self.cone = vtkConeSource()
self.cone.SetResolution(8)
self.coneMapper = vtkPolyDataMapper()
self.coneMapper.SetInput(self.cone.GetOutput())
self.coneActor = vtkActor()
self.coneActor.SetMapper(self.coneMapper)
self.ren.AddActor(self.coneActor)
# ------------------------------- VTK END
------------------------------
def __init__(self, parent):
self._init_ctrls(parent)
def OncloseButton(self, event):
self.VisWinClose()
def VisWinClose(self):
self.widget.GetRenderWindow().WindowRemap() # remap vtkrenderwindow
# open
vtkrenderwindow seperatly
self.widget.GetRenderWindow().Destroy() # destroy
vtkrenderwindow
self.Destroy() # destroy wxwindow
#
------------------------------------------------------------------------------
class PanMainWin(wxFrame):
def _init_ctrls(self, prnt):
reload(vtk.wx.wxVTKRenderWindow)
wxFrame.__init__(self, id=wxID_PANMAINWIN,
name='PanMainWin', parent=prnt, pos=wxPoint(374, 482),
size=wxSize(1008, 60), style=wxDEFAULT_FRAME_STYLE,
title='pan at develop')
self.SetClientSize(wxSize(1008, 29))
self.button1 = wxButton(id=wxID_PANMAINWINBUTTON1, label='New',
name='button1', parent=self, pos=wxPoint(0, 0),
size=wxSize(80,
29), style=0)
self.button2 = wxButton(id=wxID_PANMAINWINBUTTON2, label='Exit',
name='button2', parent=self, pos=wxPoint(80, 0),
size=wxSize(80,
29), style=0)
EVT_BUTTON(self.button1, wxID_PANMAINWINBUTTON1,
self.OnnewButton)
EVT_BUTTON(self.button2, wxID_PANMAINWINBUTTON2,
self.OnexitButton)
def __init__(self, parent, app):
self.app = app
self._init_ctrls(parent)
def OnnewButton(self, event):
self.MainWinNew()
def OnexitButton(self, event):
self.MainWinQuit()
def MainWinNew(self):
self.app.NewRenderWindow()
def MainWinQuit(self):
self.app.PanQuit()
#
------------------------------------------------------------------------------
class PanApp(wxApp):
def OnInit(self):
wxInitAllImageHandlers()
self.main = create(None, self)
self.SetTopWindow(self.main)
self.main.Show();self.main.Hide();self.main.Show()
return True
def PanQuit(self):
self.ExitMainLoop()
def NewRenderWindow(self):
self.VisWin = createVisWin(None)
self.VisWin.Show();self.main.Hide();self.main.Show()
#
------------------------------------------------------------------------------
def main():
application = PanApp(0)
application.MainLoop()
def create(parent, app):
return PanMainWin(parent, app)
def createVisWin(parent):
return PanVisWin(parent)
#
------------------------------------------------------------------------------
if __name__ == '__main__':
main()
is there any other way to dissociate VTK and wx to do a seperate close()?
i would be grateful for any proposition
greetings
uwe
More information about the vtkusers
mailing list