[Kde-bindings] KDE/kdebindings/csharp/qyoto/src

Arno Rehn kde at arnorehn.de
Sat Aug 11 18:20:51 UTC 2007


SVN commit 698990 by arnorehn:

* If a marshaller is given a zero pointer, return zero and don't free
  the GCHandle.

CCMAIL: kde-bindings at kde.org



 M  +5 -7      SmokeMarshallers.cs  
 M  +38 -2     handlers.cpp  


--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeMarshallers.cs #698989:698990
@@ -211,16 +211,14 @@
 #region marshalling functions
 
 		public static void FreeGCHandle(IntPtr handle) {
-#if DEBUG
-			if ((QDebug.DebugChannel() & QtDebugChannel.QTDB_GC) != 0 ) {
-				if (handle == IntPtr.Zero) {
-					Console.WriteLine("In FreeGCHandle(IntPtr): handle == 0");
-					return;
-				}
+			if (handle == IntPtr.Zero) {
+				Console.WriteLine("In FreeGCHandle(IntPtr): handle == 0 - This should not happen!");
+				return;
 			}
+#if DEBUG
 			DebugGCHandle.Free((GCHandle) handle);
 #else
-			if (handle != IntPtr.Zero) ((GCHandle) handle).Free();
+			((GCHandle) handle).Free();
 #endif
 		}
 		
--- trunk/KDE/kdebindings/csharp/qyoto/src/handlers.cpp #698989:698990
@@ -983,7 +983,7 @@
 			delete s;
 		}
 
-		(*FreeGCHandle)(m->var().s_voidp);
+		if (m->var().s_voidp != 0) (*FreeGCHandle)(m->var().s_voidp);
 	}
 	break;
       case Marshall::ToObject:
@@ -1153,7 +1153,6 @@
 	{
 		if (m->var().s_class == 0) {
 			m->item().s_class = 0;
-			(*FreeGCHandle)(m->var().s_class);
 			return;
 		}
 
@@ -1209,6 +1208,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject: 
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			QMap<int, QVariant>* map = (QMap<int, QVariant>*) (*DictionaryToQMap)(m->var().s_voidp, 0);
 			m->item().s_voidp = (void*) map;
 			m->next();
@@ -1251,6 +1254,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject: 
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			QMap<QString, QString>* map = (QMap<QString, QString>*) (*DictionaryToQMap)(m->var().s_voidp, 1);
 			m->item().s_voidp = (void*) map;
 			m->next();
@@ -1293,6 +1300,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject: 
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			QMap<QString, QVariant>* map = (QMap<QString, QVariant>*) (*DictionaryToQMap)(m->var().s_voidp, 2);
 			m->item().s_voidp = (void*) map;
 			m->next();
@@ -1339,6 +1350,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject: 
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			QStringList *stringlist = (QStringList*) (*StringListToQStringList)(m->var().s_voidp);
 			
 			m->item().s_voidp = (void*) stringlist;
@@ -1384,6 +1399,11 @@
     switch(m->action()) {
       case Marshall::FromObject:
 	{
+	    if (m->var().s_voidp == 0) {
+		m->item().s_voidp = 0;
+		return;
+	    }
+
 	    void* list = m->var().s_voidp;
 	    void* valuelist = (*ListWizardButtonToQListWizardButton)(list);
 	    m->item().s_voidp = valuelist;
@@ -1414,6 +1434,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject:
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			ItemList *cpplist = new ItemList;
 			QList<void*>* list = (QList<void*>*) (*ListToPointerList)(m->var().s_voidp);
 			
@@ -1488,6 +1512,10 @@
     switch(m->action()) {
       case Marshall::FromObject:
 	{
+	    if (m->var().s_voidp == 0) {
+		m->item().s_voidp = 0;
+		return;
+	    }
 	    void* list = m->var().s_voidp;
 	    void* valuelist = (*ListIntToQListInt)(list);
 	    m->item().s_voidp = valuelist;
@@ -1560,6 +1588,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject:
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			ItemList *cpplist = new ItemList;
 			QList<void*>* list = (QList<void*>*) (*ListToPointerList)(m->var().s_voidp);
 
@@ -1637,6 +1669,10 @@
 	switch(m->action()) {
 		case Marshall::FromObject:
 		{
+			if (m->var().s_voidp == 0) {
+				m->item().s_voidp = 0;
+				return;
+			}
 			QList<QRgb>* cpplist = (QList<QRgb>*) (*ListUIntToQListQRgb)(m->var().s_voidp);
 			m->item().s_voidp = cpplist;
 			m->next();



More information about the Kde-bindings mailing list