[Gtk-sharp-list] glade# cross platform

Dave Joyner d4ljoyn@yahoo.com
Thu, 7 Aug 2003 04:01:56 -0700 (PDT)


--0-1861489592-1060254116=:25035
Content-Type: text/plain; charset=us-ascii

I'm trying to make sure that ui elements work on ..net, mono windows, and mono linux.
The .NET runtime requires that callback delegates use the stdcall calling convention. This is noted in the msdn, the mono FAQ, and there is a bugzilla entry for this topic as well.
 
The libglade callback for autoconnecting signal handlers doesn't use this convention, so .NET users might encounter strange behavior -- I've noticed that either not all handlers are actually connected or you'll get NullReference exception from gtk_main().  It's a stack corruption so the behavior is undefined.
 
I've confirmed this by changing the function signature in libglade-2.0.1 under windows, glade-xml.h:
 
typedef void (__stdcall *GladeXMLConnectFunc) (const gchar *handler_name,
         GObject *object,
         const gchar *signal_name,
         const gchar *signal_data,
         GObject *connect_object,
         gboolean after,
         gpointer user_data);
 
which represents this delegate in gtk#, XML.cs (XML.custom).
 
  delegate void RawXMLConnectFunc (string handler_name, IntPtr objekt, 
               string signal_name, string signal_data, 
               IntPtr connect_object, int after, IntPtr user_data);
   
Unfortunately, this breaks on mono windows.  So I currently have two versions of libglade -- one with the above modification that I place in the executable directory of a .NET application, the other in the windows PATH which is picked up by mono.
 
This is not an issue with  Linux.  I haven't come up with good permanent approach to this problem.  Can anyone else confirm this ?  If so, any solutions ?
 
Thank you
Dave Joyner


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
--0-1861489592-1060254116=:25035
Content-Type: text/html; charset=us-ascii

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I'm trying to make sure that ui elements work on 
..net, mono windows, and mono linux.</FONT></DIV>
<DIV><FONT face=Arial size=2>The .NET runtime requires that callback delegates 
use the stdcall calling convention. This is noted in the msdn, the mono FAQ, and 
there is a bugzilla entry for this topic as well.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>The libglade callback for autoconnecting signal 
handlers doesn't use this convention, so .NET users might encounter strange 
behavior -- I've noticed that either not all handlers are actually connected or 
you'll get NullReference exception from gtk_main().&nbsp; It's a stack 
corruption so the behavior is undefined.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I've confirmed this by changing the 
function&nbsp;signature&nbsp;in libglade-2.0.1 under windows, 
glade-xml.h:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>typedef void (__stdcall *GladeXMLConnectFunc) 
(const gchar *handler_name,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
GObject *object,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const gchar 
*signal_name,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const gchar 
*signal_data,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GObject 
*connect_object,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gboolean 
after,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gpointer 
user_data);</FONT></DIV><FONT face=Arial size=2>
<DIV>&nbsp;</DIV>
<DIV>which represents this delegate in gtk#, XML.cs (XML.custom).</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;delegate void RawXMLConnectFunc (string handler_name, IntPtr 
objekt, 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
string signal_name, string signal_data, 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
IntPtr connect_object, int after, IntPtr user_data);<BR>&nbsp;&nbsp;&nbsp;</DIV>
<DIV>Unfortunately, this breaks on&nbsp;mono windows.&nbsp; So I currently have 
two versions of libglade -- one with the above modification that I place in the 
executable directory of a .NET application, the other in the windows PATH which 
is picked up by mono.</DIV>
<DIV>&nbsp;</DIV>
<DIV>This is not an issue with &nbsp;Linux.&nbsp; I haven't come up with good 
permanent approach to this problem.&nbsp; Can anyone else confirm this ?&nbsp; 
If so, any solutions ?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you</DIV>
<DIV>Dave Joyner</FONT></DIV></BODY></HTML>
<p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software
--0-1861489592-1060254116=:25035--