Bug#646374: freecad: Running the Python command 'Draft_Line' failed

Werner Mayer werner.wm.mayer at gmx.de
Wed Mar 14 08:00:15 UTC 2012


Hi,

when using a SWIG-wrapped library we have to use the right binding (swigpyrun.h) for this version because the internal structure changes more or less completely for every minor release of SWIG.

And so far the SWIG-wrapped library doesn't seem to have a method to query by which SWIG version it was built.

Therefore I have implemented a way to read-in the generated .py file and get the version number from there. This (first) solution, however, failed for SWIG 2.0.

Now this is fixed in FreeCAD 0.13 but you can easily backport this to 0.12.
http://free-cad.git.sourceforge.net/git/gitweb.cgi?p=free-cad/free-cad;a=blobdiff;f=src/Base/Interpreter.cpp;h=6e31a38103caf9735f074544dcf650b539d0a1ef;hp=a1bd56a9a139f22b6e7c85a23f787d170b0fbbb0;hb=0e7df97961dbd238094b9223efd217502fe1c747;hpb=10b0601c54ab3d70c11503a0a0ba909ecda99d3b

and

http://free-cad.git.sourceforge.net/git/gitweb.cgi?p=free-cad/free-cad;a=blobdiff;f=src/Base/Interpreter.cpp;h=0a8c4b9e8b6c69582d5ad07112d15eb71a8a01e8;hp=6e31a38103caf9735f074544dcf650b539d0a1ef;hb=1f690c0c817500159c078f2d91ee15a7ebda3cc9;hpb=06d708c86ea7bcf1078dca5799949260ed72d619

If for Debian only one SWIG version is used you can simplify the methods createSWIGPointerObj and convertSWIGPointerObj a lot.


PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const char* TypeName, void* Pointer, int own)
{
    int result = 0;
    PyObject* proxy=0;
    PyGILStateLocker locker;
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
    result = Swig_python::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own);
#else
    result = -1; // indicates error
#endif

    if (result == 0)
        return proxy;

    // none of the SWIG's succeeded
    throw Base::Exception("No SWIG wrapped library loaded");
}


bool InterpreterSingleton::convertSWIGPointerObj(const char* Module, const char* TypeName, PyObject* obj, void** ptr, int flags)
{
    int result = 0;
    PyGILStateLocker locker;
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
        result = Swig_python::convertSWIGPointerObj_T(TypeName, obj, ptr, flags);
#else
        result = -1; // indicates error
#endif

    if (result == 0)
        return true;

    // none of the SWIG's succeeded
    throw Base::Exception("No SWIG wrapped library loaded");
}

However, I haven't tested this so far.

Cheers,
Werner
 
-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a





More information about the debian-science-maintainers mailing list