[PyKDE] a bug in virtual handler?

Phil Thompson phil at river-bank.demon.co.uk
Sun Oct 24 11:59:02 BST 1999


Fukuda Masaki wrote:
> 
> Hello folks,
> 
> I'm trying to generate python bindings of my application.
> I got a problem in virtual handler that return class-type.
> I can not get correct return value in C++ side.

...

> In sipVH_xxxx() generated by sip-0.9, do Py_DECREF(resobj)
> before return. I think, when Py_DECREF do, the memory pointed
>  by 'res' released, correct?
> 
> Does anyone have this solution?
> 
> thanks in advanse.
> 
> ------------------------------------------
> Masaki Fukuda <fukuda at wni.co.jp>
> (BCDE)Weathernews, Inc.
> Phone:043-274-5508, FAX:043-274-4957,4955

Good spot. The (very quickly put together) patch to sip should fix it.
This won't be the final solution.

Phil
-------------- next part --------------
diff -ruN sip-0.9.orig/sip/gencode.c sip-0.9/sip/gencode.c
--- sip-0.9.orig/sip/gencode.c	Thu Sep  2 00:44:41 1999
+++ sip-0.9/sip/gencode.c	Sun Oct 24 10:47:27 1999
@@ -2507,7 +2507,14 @@
 		else
 			fprintf(fp,
 "		if (sipCanConvertToCpp(resobj,sipClass_%s))\n"
+"		{\n"
+"			sipThisType *resThis;\n"
+"\n"
 "			res = (%s *)sipConvertToCpp(resobj,sipClass_%s,&iserr);\n"
+"\n"
+"			if ((resThis = sipMapSelfToThis(resobj)) != NULL)\n"
+"				sipResetPyOwned(resThis);\n"
+"		}\n"
 				,rcname,rcname,rcname);
 
 		fputs(


More information about the PyQt mailing list