Re: [PyQt] [SIP] Python crash with QString
Well, my educated guess is it's because PyQt4 is being compiled with VS2010, but the Python binaries are all compiled under VS2008. I've had issues before trying to use sip/PyQt4 compiled with VS2010, with Python compiled with 2008, in that strings would end up being blank or having odd crashes going from C++ to Python. To keep it short, I do not recommend you mix dlls created with VS2010 with Python built under VS2008, it has tended to cause issues at least for me. On Fri, Sep 9, 2011 at 9:20 PM, Jens Thoms Toerring wrote: > Hi Demetrius, > > On Fri, Sep 09, 2011 at 09:04:28PM +, Demetrius Cassidy wrote: > > Is Python also compiled with VS2010? > > Honestly, I can't tell - I got that installation and was told > to use it as it is. My guess is that the Python version (2.7) > was simply a binary download, gotten from somewhere I have no > ideas about. Is there a way to find out about that? And would > that make a lot of a difference? All I can tell at the moment > is that a lot of other stuff that to me looks much nore complex > to me seems to work. Please keep in mind that my experience with > Windows is basically non-existent, so I need quite a bit of > handholding and probably will have to ask really stupid ques- > tions... > Thanks and best regards, Jens > -- > \ Jens Thoms Toerring j...@toerring.de > \___ http://toerring.de > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [SIP] Python crash with QString
Hi, I've got a SIP wrapper for a C++ library and have some issue with running under Win32 after compiling with Visual Studio 10. Within the library I have a number of functions that return QString objects or (mostly const) references. Under Linux every- thing works fine, e.g. if I do in a Python script print yaba.Version.text( ) I get the version string (which is a QString returned by the wrapped library) output to the screen. Under Windows Python crashes after outputting the string with an access violation (C005). The crash seems to happen whenever I use a QString object (or reference) returned by the library wrapped with SIP, e.g. also print yaba.Version.text( ).length( ) crashes. The same happens with all other methods of the QString class I tried. I can avoid the crash in this case by assigning the QString object to another Python variable first, i.e. with dummy = yaba.Version.text( ) print dummy it seems to work. To confirm that this is a problem with QString I then wrote an extremely simple library, containing just a single class with a single (static) method that returns a QString, plus an equally simple SIP wrapper for it. Again, everything works fine under Linux but crashes under Windows the first time the QString (or PyQt4.QtCore.QString) object is used. And with this much simplified library even the "trick" of copying the QString to a local variable first doesn't work anymore. The error is again an access violation and as far as I can tell it seems to be an attempt to write to address 0x0. The SIP version I'm using under Windows is 4.12.2 (under Linux it's 4.10.1). The Windows version is 7 Professional 32-bit and the compiler Visual Studio 10. Has anyone an idea what could be behind this? Since I have nearly no experience with Windows and, after having struggled for two weeks to get the whole stuff to built, I'm not too keen on spending what's probably's going to be another month to learn how to obtain a debug built under this environment, thus I can at the moment only report my observations and no more details... To check for possible memory problems with the simple library (though I can't see where any could come from) I also run the Linux version under valgrind and just got the usual complaints about stuff from what looks like somewhere deep in the inter- nals Python, but nothing that would let me suspect that there's anything broken in the library. I append the relevant code of the simple library and SIP wrap- per below (with qs_lib.hpp and qs_lib.cpp being the code for the library to be SIP-wrapped, qs_sip.sip the SIP wrapper and qs.py the script that crashes Python) in the hope that it is of any help. Best regards, Jens - qs_lib.hpp -- #ifndef QS_HPP_ #define QS_HPP_ #if ! defined _MSC_VER // this isn't MS Visual Studio #define DLL_STUFF #else #if defined BUILDING_LIB #define DLL_STUFF __declspec( dllexport ) #else #define DLL_STUFF __declspec( dllimport ) #endif #endif #include class DLL_STUFF QS { public: static QString text( ); }; #endif - qs_lib.cpp -- #include "qs_lib.hpp" QString QS::text( ) { return QString( "Hello world" ); } - qs_sip.sip -- %Module qs_sip 0 %Import QtCore/QtCoremod.sip %Import QtGui/QtGuimod.sip class QS { %TypeHeaderCode #include "qs_lib.hpp" %End public: static QString text( ); }; - qs.py -- import qs_sip as qs print qs.QS.text( ) -- \ Jens Thoms Toerring j...@toerring.de \___ http://toerring.de ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt