Hello,
Below is a small class using ctypes and libspectre to read a
postscript file.
My program is a PyQT 4.4 application and when the user clicks on a
entry in a QTableWidget, i run
PostScriptImage ( filename_as_con tained_in_click ed_tableWidgetI tem )
However on i get a segfault while trying document_load.
Surprisingly, before i run sys.exit(app.ex ec_()) (i.e before the app
starts) if run PostScriptImage (command_line_s pecified_ps_fil e) it
works!
I know the ctypes so file works with QT since i wrote an application
using it, but i hadn't separated the ctypes stuff into separate class
(i.e the spectre code was in the widget method).
Any ideas why the crash?
Regards
Saptarshi
--Python Code--
class PostScriptImage :
def __init__(self,f ilename):
print "Doc New"
self.document=l ibspec.spectre_ document_new()
print "Load Doc" , filename
#############cr ashed in the following
line########### ##############
libspec.spectre _document_load( self.document,f ilename)
print "Done load doc"
if libspec.spectre _document_statu s(self.document ):
return False
self.scale=[1.0,1.0]
self.quicksetup ()
def quicksetup(self ):
print "RC"
rc=libspec.spec tre_render_cont ext_new()
print "Get 0th Page"
page=libspec.sp ectre_document_ get_page (self.document, 0)
if libspec.spectre _document_statu s(self.document ):
raise Exception("Spec tre:Setup Document Error")
w= c_int()
h= c_int()
print "Page Size"
libspec.spectre _page_get_size( page, byref(w),byref( h))
self.initialSiz e=(h.value*1.0, w.value*1.0)
self.initialAsp ect=float(h.val ue)/float(w.value)
self.npages=lib spec.spectre_do cument_get_n_pa ges(self.docume nt)
Below is a small class using ctypes and libspectre to read a
postscript file.
My program is a PyQT 4.4 application and when the user clicks on a
entry in a QTableWidget, i run
PostScriptImage ( filename_as_con tained_in_click ed_tableWidgetI tem )
However on i get a segfault while trying document_load.
Surprisingly, before i run sys.exit(app.ex ec_()) (i.e before the app
starts) if run PostScriptImage (command_line_s pecified_ps_fil e) it
works!
I know the ctypes so file works with QT since i wrote an application
using it, but i hadn't separated the ctypes stuff into separate class
(i.e the spectre code was in the widget method).
Any ideas why the crash?
Regards
Saptarshi
--Python Code--
class PostScriptImage :
def __init__(self,f ilename):
print "Doc New"
self.document=l ibspec.spectre_ document_new()
print "Load Doc" , filename
#############cr ashed in the following
line########### ##############
libspec.spectre _document_load( self.document,f ilename)
print "Done load doc"
if libspec.spectre _document_statu s(self.document ):
return False
self.scale=[1.0,1.0]
self.quicksetup ()
def quicksetup(self ):
print "RC"
rc=libspec.spec tre_render_cont ext_new()
print "Get 0th Page"
page=libspec.sp ectre_document_ get_page (self.document, 0)
if libspec.spectre _document_statu s(self.document ):
raise Exception("Spec tre:Setup Document Error")
w= c_int()
h= c_int()
print "Page Size"
libspec.spectre _page_get_size( page, byref(w),byref( h))
self.initialSiz e=(h.value*1.0, w.value*1.0)
self.initialAsp ect=float(h.val ue)/float(w.value)
self.npages=lib spec.spectre_do cument_get_n_pa ges(self.docume nt)
Comment