[PyKDE] Another little big (I think...)

Phil Thompson phil at river-bank.demon.co.uk
Tue Dec 7 13:55:42 GMT 1999


Toby Sargeant wrote:
> 
> In sipGetThis, there is the code fragment:
> 
>         if (thisObj != NULL)
>         {
>                 // sipParseArgs() will decrement the reference count.
> 
>                 Py_INCREF(arg);
>                 return (sipThisType *)thisObj;
>         }
> 
> The comment appears not to be true, and the arg tuple passed to sipParseArgs
> never gets gc'ed as a result of the incref. commenting it out fixed the
> problem.
> 
> Toby.

In pre5 I provided the wrong fix to a bug which made the comment
untrue.  The attached patches reverse the wrong fix in siplib.cpp and
apply the correct fix to gencode.c.

I haven't tested these.

Phil
-------------- next part --------------
--- Homepage/software/private/sip-0.10pre5/siplib/siplib.cpp	Wed Dec  1 20:34:17 1999
+++ src/sip/siplib/siplib.cpp	Mon Dec  6 19:49:28 1999
@@ -143,11 +143,11 @@
 
 	// See if we need to dispose of the arguments on a successful parse.
 
-	decref = false;
+	decref = true;
 
 	if (*fmt == '-')
 	{
-		decref = true;
+		decref = false;
 		++fmt;
 	}
 

-------------- next part --------------
--- Homepage/software/private/sip-0.10pre5/sip/gencode.c	Wed Dec  1 23:24:06 1999
+++ src/sip/sip/gencode.c	Mon Dec  6 19:58:22 1999
@@ -4274,10 +4274,11 @@
 	char *cname, *cmname;
 	char *pmname = md -> pyname -> module -> name -> text;
 	char *pname = md -> pyname -> text;
-	int noIntro;
+	int noIntro, noDecr;
 	overDef *od;
 
 	noIntro = TRUE;
+	noDecr = TRUE;
 
 	for (od = md -> overloads; od != NULL; od = od -> next)
 	{
@@ -4316,6 +4317,7 @@
 "{\n"
 						,cname,pname);
 				else
+				{
 					prcode(fp,
 "\n"
 "static PyObject *sipDo_%s_%s(PyObject *sipThisObj,PyObject *sipArgs)\n"
@@ -4325,6 +4327,9 @@
 "	if ((sipThis = sipGetThis(sipThisObj,&sipArgs,sipClass_%s)) == NULL)\n"
 "		return NULL;\n"
 						,cname,pname,cname);
+
+					noDecr = FALSE;
+				}
 			}
 		}
 
@@ -4343,7 +4348,7 @@
 		{
 			int needSecCall;
 
-			needSecCall = generateArgParser(&od -> args,(cvd == NULL),FALSE,fp);
+			needSecCall = generateArgParser(&od -> args,noDecr,FALSE,fp);
 			generateFunctionCall(pt,cvd,md,od,FALSE,fp);
 
 			if (needSecCall)
@@ -4354,7 +4359,7 @@
 "	{\n"
 					);
 
-				generateArgParser(&od -> args,(cvd == NULL),TRUE,fp);
+				generateArgParser(&od -> args,noDecr,TRUE,fp);
 				generateFunctionCall(pt,cvd,md,od,TRUE,fp);
 			}
 		}



More information about the PyQt mailing list