Commits

Ronald Oussoren  committed 6f19cf7

Fix refcounting issue in manual wrapper

The custom wrapper incorrectly assumed that the returned value
was owned by the caller and therefore called CFRetain too much.

This caused crashes on OSX 10.8 (and for some reason happened to
work fine on earlier OSX releases)

  • Participants
  • Parent commits 82cdeb7

Comments (0)

Files changed (1)

File pyobjc-framework-CoreText/Modules/_manual.m

 	} 
 
 	result = Py_BuildValue("NN", PyBool_FromLong(b), PyObjC_IdToPython((NSObject*)output));
-	CFRelease(output);
 	return result;
 }
 
 
 	if (py_settings == Py_None) {
 		/* Handle simple case */
+		if (len != 0) {
+			PyErr_SetString(PyExc_ValueError, "settings list is 'None', length is not 0");
+			return NULL;
+		}
 		PyObjC_DURING
-			style = CTParagraphStyleCreate(NULL, len);
+			style = CTParagraphStyleCreate(NULL, 0);
 
 		PyObjC_HANDLER
 			style = NULL;
 			return Py_None;
 		}
 
+		CFShow(style);
+		printf("refcount: %d\n", (int)[(NSObject*)style retainCount]);
+
 		result = PyObjC_ObjCToPython(@encode(CTParagraphStyleRef), &style);
+		printf("refcount: %d\n", (int)[(NSObject*)style retainCount]);
 		CFRelease(style);
+		printf("refcount: %d\n", (int)[(NSObject*)style retainCount]);
 		return result;
 	}