Avoiding wxPython PrintPreview segmentation fault or double free error
Posted 11-28-2008 at 08:23 PM by dr_agon
applies to: Python, wxPython (v.2.8), wxWidgets, wx.PrintPreview, wx.Printout
When creating wx.PrintPreview class, you must pass 2 parameters of wxPrintout class (see doc)
If someone (like me) gets a silly idea of passing the same instance of wxPrintout class as both parameters, on closing the preview frame he will get segmentation fault or double free error.
Example (don't do this!):
Code:
class MyPrintout(wx.Printout): #rest of code printout = MyPrintout(MyParameters) # instance of class based on wx.Printout printpreview = wx.PrintPreview(printout, printout, MyPrintData)
Code:
class MyPrintout(wx.Printout): #rest of code printout_preview = MyPrintout(MyParameters) # first instance of class based on wx.Printout printout_printing = MyPrintout(MyParameters) # second instance of class based on wx.Printout printpreview = wx.PrintPreview(printout_preview, printout_printing, MyPrintData)



