[nautilus-python] Fix to get the PyCapsule patch to work even if there is no PyCapsule object set up for pygtk.



commit 95a1b8927fa6655dc22ee896f2708b575682dcf2
Author: Adam Plumb <adamplumb gmail com>
Date:   Fri Mar 4 09:21:20 2011 -0500

    Fix to get the PyCapsule patch to work even if there is no PyCapsule object set up for pygtk.

 src/nautilus-python.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/src/nautilus-python.c b/src/nautilus-python.c
index f348edd..27df331 100644
--- a/src/nautilus-python.c
+++ b/src/nautilus-python.c
@@ -82,23 +82,23 @@ np_init_pygtk(void)
 		{
 			_PyGtk_API = (struct _PyGtk_FunctionStruct*)capsule;
 		}
-		else
-		{
-#else
-		PyObject *module_dict = PyModule_GetDict(pygtk);
-		PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
-		if (PyCObject_Check(cobject))
-		{
-			_PyGtk_API = (struct _PyGtk_FunctionStruct*)
-				PyCObject_AsVoidPtr(cobject);
-		}
-		else
-		{
 #endif
-		    PyErr_SetString(PyExc_RuntimeError,
-		                    "could not find _PyGtk_API object");
-			PyErr_Print();
-			return FALSE;
+		if (!_PyGtk_API)
+		{
+			PyObject *module_dict = PyModule_GetDict(pygtk);
+			PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API");
+			if (PyCObject_Check(cobject))
+			{
+				_PyGtk_API = (struct _PyGtk_FunctionStruct*)
+					PyCObject_AsVoidPtr(cobject);
+			}
+			else
+			{
+				PyErr_SetString(PyExc_RuntimeError,
+				                "could not find _PyGtk_API object");
+				PyErr_Print();
+				return FALSE;
+			}
 		}
     }
     else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]