Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Paul Santa Maria
Thank you on all counts! The main problem was my callback (duh! I forgot the "GtkWidget *w" argument!); I also changed all my "gtk_signal_connect()" calls to g_signal_connect()", and all my "gtk_signal_connect_object()" to g_signal_connect_swapped()". It works fine now - thanx again! --- Step

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Wallace Owen
On Wed, 2005-12-14 at 20:47 +, Chris Vine wrote: > On Wednesday 14 December 2005 20:38, Wallace Owen wrote: > > [snip] > Your version isn't portable either. GTK+ callbacks required C linkage, so to > be portable your code should provide C linkage, and static member functions > cannot have C

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Chris Vine
On Wednesday 14 December 2005 20:38, Wallace Owen wrote: [snip] > Warning! > > It may work for you. It's not portable. C++ implementations are free > to use a calling convention different from the C calling convention: In > C, parameters are pushed in reverse order to support varargs. C++ > fu

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Wallace Owen
On Wed, 2005-12-14 at 11:28 -0800, Brian J. Tarricone wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > ... > > IIRC, I believe the functions only have to be static in this case if > they're actually C++ class methods. Plain old C global functions don't > need to be static, though if th

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Wallace Owen
On Wed, 2005-12-14 at 12:49 -0700, Daryl Lee wrote: > Well, thanks for the correction. I will have to go back through my > projects to understand why I thought that. > > On Wed, 2005-12-14 at 11:19 -0800, Stephen Pollei wrote: > > On 12/13/05, Daryl Lee <[EMAIL PROTECTED]> wrote: > ... > > > C++

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Daryl Lee
Well, thanks for the correction. I will have to go back through my projects to understand why I thought that. On Wed, 2005-12-14 at 11:19 -0800, Stephen Pollei wrote: > On 12/13/05, Daryl Lee <[EMAIL PROTECTED]> wrote: ... > > C++ functions do, indeed, have to be "static" to be used as GTK+ > > c

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Brian J. Tarricone
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 12/14/2005 11:19 AM, Stephen Pollei wrote: > On 12/13/05, Daryl Lee <[EMAIL PROTECTED]> wrote: > >>>Are you sure that is the right style for that callback? >>>static void >>>rocket_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) >>>{ >>

Re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Stephen Pollei
On 12/13/05, Daryl Lee <[EMAIL PROTECTED]> wrote: > > Are you sure that is the right style for that callback? > > static void > > rocket_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) > > { > > class city_node *city=static_cast(data); > > global_game.rocket_up(*city); >

re: Reference to a C++ object in GTK+ callbacks

2005-12-14 Thread Andy Grebe
l-list@gnome.org Subject: Reference to a C++ object in GTK+ callbacks Hi - I'm using the GTK+ 2.6.4 that came with Suse 9.3. I'm coding in C++, but using the "raw" GTK+ C libraries. I'm trying to pass a pointer to one of my C++ classes into a callback, so that I can c

Re: Reference to a C++ object in GTK+ callbacks

2005-12-13 Thread Daryl Lee
On Tue, 2005-12-13 at 16:30 -0800, Stephen Pollei wrote: > On 12/13/05, Paul Santa Maria <[EMAIL PROTECTED]> wrote: > > I'm coding in C++, but using the "raw" GTK+ C > > libraries. > I'm doing similiar for a game I'm making. > > >-- > > gboolean > > play_cb (gpointer data) > >

Re: Reference to a C++ object in GTK+ callbacks

2005-12-13 Thread Stephen Pollei
On 12/13/05, Paul Santa Maria <[EMAIL PROTECTED]> wrote: > I'm coding in C++, but using the "raw" GTK+ C > libraries. I'm doing similiar for a game I'm making. >-- > gboolean > play_cb (gpointer data) > { > // Deference the object pointer to do the actual work > AnimationFi

Re: Reference to a C++ object in GTK+ callbacks

2005-12-13 Thread Wallace Owen
AnimationFile must have a public virtual function void start(), and m_animation must actually point to an Hbafile, so that when you cast the void* to AnimationFile* it's going to find a vtable slot for start(). If AnimationFile's start() isn't declared virtual, it won't go through the vtable. With

Re: Reference to a C++ object in GTK+ callbacks

2005-12-13 Thread Andrew J. Montalenti
How about trying gdb, seeing what the value of ani is at the time of the crash. How about a backtrace? It's hard to debug your problem as described. But I have a feeling with some minimal gdb'ing you can find the bug yourself. -Andrew On Tue, 2005-12-13 at 16:00 -0800, Paul Santa Maria wrote:

Reference to a C++ object in GTK+ callbacks

2005-12-13 Thread Paul Santa Maria
Hi - I'm using the GTK+ 2.6.4 that came with Suse 9.3. I'm coding in C++, but using the "raw" GTK+ C libraries. I'm trying to pass a pointer to one of my C++ classes into a callback, so that I can call a method on that class. The code looks like this: 1. less hbaview.h => -- c