[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 302/473: Fix undefined behavior in slot classes.

noreply at xfce.org noreply at xfce.org
Mon Feb 16 23:57:52 CET 2015


This is an automated email from the git hooks/post-receive script.

gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 2340c799cea8b19b7adb0a4b0a7a3cf733d4c21d
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Dec 14 14:20:13 2013 -0500

    Fix undefined behavior in slot classes.
---
 panel-plugin/slot.h |   78 +++++++++++++++++++++++++++------------------------
 1 file changed, 42 insertions(+), 36 deletions(-)

diff --git a/panel-plugin/slot.h b/panel-plugin/slot.h
index ffb2160..cdc6203 100644
--- a/panel-plugin/slot.h
+++ b/panel-plugin/slot.h
@@ -39,23 +39,24 @@ gulong g_signal_connect_slot(gpointer instance, const gchar* detailed_signal, R(
 		{
 		}
 
-		static R invoke(Slot* slot)
+		static R invoke(gpointer user_data)
 		{
+			Slot* slot = reinterpret_cast<Slot*>(user_data);
 			return (slot->m_instance->*slot->m_member)();
 		}
 
-		static void destroy(Slot* slot)
+		static void destroy(gpointer data, GClosure*)
 		{
-			delete slot;
+			delete reinterpret_cast<Slot*>(data);
 		}
 	};
-	R (*invoke_slot)(Slot*) = &Slot::invoke;
-	void (*destroy_slot)(Slot*) = &Slot::destroy;
+	R (*invoke_slot)(gpointer) = &Slot::invoke;
+	void (*destroy_slot)(gpointer, GClosure*) = &Slot::destroy;
 
 	return g_signal_connect_data(instance, detailed_signal,
 			reinterpret_cast<GCallback>(invoke_slot),
 			new Slot(obj, member),
-			reinterpret_cast<GClosureNotify>(destroy_slot),
+			destroy_slot,
 			after ? GConnectFlags(G_CONNECT_AFTER | G_CONNECT_SWAPPED) : G_CONNECT_SWAPPED);
 }
 
@@ -75,23 +76,24 @@ gulong g_signal_connect_slot(gpointer instance, const gchar* detailed_signal, R(
 		{
 		}
 
-		static R invoke(A1 a1, Slot* slot)
+		static R invoke(A1 a1, gpointer user_data)
 		{
+			Slot* slot = reinterpret_cast<Slot*>(user_data);
 			return (slot->m_instance->*slot->m_member)(a1);
 		}
 
-		static void destroy(Slot* slot)
+		static void destroy(gpointer data, GClosure*)
 		{
-			delete slot;
+			delete reinterpret_cast<Slot*>(data);
 		}
 	};
-	R (*invoke_slot)(A1,Slot*) = &Slot::invoke;
-	void (*destroy_slot)(Slot*) = &Slot::destroy;
+	R (*invoke_slot)(A1,gpointer) = &Slot::invoke;
+	void (*destroy_slot)(gpointer, GClosure*) = &Slot::destroy;
 
 	return g_signal_connect_data(instance, detailed_signal,
 			reinterpret_cast<GCallback>(invoke_slot),
 			new Slot(obj, member),
-			reinterpret_cast<GClosureNotify>(destroy_slot),
+			destroy_slot,
 			after ? G_CONNECT_AFTER : GConnectFlags(0));
 }
 
@@ -111,23 +113,24 @@ gulong g_signal_connect_slot(gpointer instance, const gchar* detailed_signal, R(
 		{
 		}
 
-		static R invoke(A1 a1, A2 a2, Slot* slot)
+		static R invoke(A1 a1, A2 a2, gpointer user_data)
 		{
+			Slot* slot = reinterpret_cast<Slot*>(user_data);
 			return (slot->m_instance->*slot->m_member)(a1, a2);
 		}
 
-		static void destroy(Slot* slot)
+		static void destroy(gpointer data, GClosure*)
 		{
-			delete slot;
+			delete reinterpret_cast<Slot*>(data);
 		}
 	};
-	R (*invoke_slot)(A1,A2,Slot*) = &Slot::invoke;
-	void (*destroy_slot)(Slot*) = &Slot::destroy;
+	R (*invoke_slot)(A1,A2,gpointer) = &Slot::invoke;
+	void (*destroy_slot)(gpointer, GClosure*) = &Slot::destroy;
 
 	return g_signal_connect_data(instance, detailed_signal,
 			reinterpret_cast<GCallback>(invoke_slot),
 			new Slot(obj, member),
-			reinterpret_cast<GClosureNotify>(destroy_slot),
+			destroy_slot,
 			after ? G_CONNECT_AFTER : GConnectFlags(0));
 }
 
@@ -147,23 +150,24 @@ gulong g_signal_connect_slot(gpointer instance, const gchar* detailed_signal, R(
 		{
 		}
 
-		static R invoke(A1 a1, A2 a2, A3 a3, Slot* slot)
+		static R invoke(A1 a1, A2 a2, A3 a3, gpointer user_data)
 		{
+			Slot* slot = reinterpret_cast<Slot*>(user_data);
 			return (slot->m_instance->*slot->m_member)(a1, a2, a3);
 		}
 
-		static void destroy(Slot* slot)
+		static void destroy(gpointer data, GClosure*)
 		{
-			delete slot;
+			delete reinterpret_cast<Slot*>(data);
 		}
 	};
-	R (*invoke_slot)(A1,A2,A3,Slot*) = &Slot::invoke;
-	void (*destroy_slot)(Slot*) = &Slot::destroy;
+	R (*invoke_slot)(A1,A2,A3,gpointer) = &Slot::invoke;
+	void (*destroy_slot)(gpointer, GClosure*) = &Slot::destroy;
 
 	return g_signal_connect_data(instance, detailed_signal,
 			reinterpret_cast<GCallback>(invoke_slot),
 			new Slot(obj, member),
-			reinterpret_cast<GClosureNotify>(destroy_slot),
+			destroy_slot,
 			after ? G_CONNECT_AFTER : GConnectFlags(0));
 }
 
@@ -183,23 +187,24 @@ gulong g_signal_connect_slot(gpointer instance, const gchar* detailed_signal, R(
 		{
 		}
 
-		static R invoke(A1 a1, A2 a2, A3 a3, A4 a4, Slot* slot)
+		static R invoke(A1 a1, A2 a2, A3 a3, A4 a4, gpointer user_data)
 		{
+			Slot* slot = reinterpret_cast<Slot*>(user_data);
 			return (slot->m_instance->*slot->m_member)(a1, a2, a3, a4);
 		}
 
-		static void destroy(Slot* slot)
+		static void destroy(gpointer data, GClosure*)
 		{
-			delete slot;
+			delete reinterpret_cast<Slot*>(data);
 		}
 	};
-	R (*invoke_slot)(A1,A2,A3,A4,Slot*) = &Slot::invoke;
-	void (*destroy_slot)(Slot*) = &Slot::destroy;
+	R (*invoke_slot)(A1,A2,A3,A4,gpointer) = &Slot::invoke;
+	void (*destroy_slot)(gpointer, GClosure*) = &Slot::destroy;
 
 	return g_signal_connect_data(instance, detailed_signal,
 			reinterpret_cast<GCallback>(invoke_slot),
 			new Slot(obj, member),
-			reinterpret_cast<GClosureNotify>(destroy_slot),
+			destroy_slot,
 			after ? G_CONNECT_AFTER : GConnectFlags(0));
 }
 
@@ -219,23 +224,24 @@ gulong g_signal_connect_slot(gpointer instance, const gchar* detailed_signal, R(
 		{
 		}
 
-		static R invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, Slot* slot)
+		static R invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, gpointer user_data)
 		{
+			Slot* slot = reinterpret_cast<Slot*>(user_data);
 			return (slot->m_instance->*slot->m_member)(a1, a2, a3, a4, a5);
 		}
 
-		static void destroy(Slot* slot)
+		static void destroy(gpointer data, GClosure*)
 		{
-			delete slot;
+			delete reinterpret_cast<Slot*>(data);
 		}
 	};
-	R (*invoke_slot)(A1,A2,A3,A4,A5,Slot*) = &Slot::invoke;
-	void (*destroy_slot)(Slot*) = &Slot::destroy;
+	R (*invoke_slot)(A1,A2,A3,A4,A5,gpointer) = &Slot::invoke;
+	void (*destroy_slot)(gpointer, GClosure*) = &Slot::destroy;
 
 	return g_signal_connect_data(instance, detailed_signal,
 			reinterpret_cast<GCallback>(invoke_slot),
 			new Slot(obj, member),
-			reinterpret_cast<GClosureNotify>(destroy_slot),
+			destroy_slot,
 			after ? G_CONNECT_AFTER : GConnectFlags(0));
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list