Re: Re: Re: Calling a module with a gpointer to data.




  Jim, 

 I solved the problem.

 First off, I am getting a lot of Gkt Errors due to the pixmap. - I am just
taking that you did not send the pixmaps to me, but you know how to solve that
prblem.

  Now, to the important stuff.

 You have:
G_MODULE_EXPORT void
sayHello( gpointer data)
{
   printf(" %s" data);  /* -- and here is where things "blow up." */
}

 -- You are passing the pointer correctly -- however, you are assigning this
function as if it was a GtkSignalFunc -- ( you are casting it; therefore, the C
compiler does not tell you anything about the mistake., it just assumes you are
the boss.)

   To be a  GtkSignalFunc , the function signature must be : 
   sayHello(GtkWidget* w, gpointer data) --  I made that change and BINGO !! it
worked.

   You also have something like:
typedef void* (mod_func) (gpointer data);  /* Return and accept void, so we can
                          pass any data in/out */

This is unecessary -- I removed on the code I am sending to you -- since you
already have GtkSignalFunc (Which is the same thing.) -- In fact, wrong, since
the connect signal takes a GtkSignalFunc type; which is different from the
above decl.


 -- Run the program that I am sending -- You will see that "sayHello" will
work, but "sayGoodbye" will not work-- I left it unchanged since it is the same
change you need to make -- I left it as exercise :P)


   Take care and thanks for sending the code and the explanation.

Harring Figueiredo.



-- Jim Parker <hopeye cfl rr com> wrote:
Do not know the spot in the code, but I know the steps to reproduce.

If you compile and run ...

Under the file menu, there is a menu choice "load modules" Select this and
the module is loaded and it creates a new sub menu "plug-ins"  Under this
new menu they is the another sub-menu "sayHello" (or somethin along those
lines) and 2 choices.

These choices call fuctions from the module library.  Selecting either of
the choices calls the correct function, but the data pointer is corrupt (ie
it prints out garbage characters).

I build the menu with functions in the misc.c file.  The loading and
unloading of the modules are in plugin.c, and module code is in sayhello.c
and sayhello.h

Thanks for looking at my code.

cheers,
Jim Parker

On Wed, 31 Jul 2002, Harring Figueiredo wrote:
Date: Wed, 31 Jul 2002 08:00:22 -0700 (PDT)
To: hopeye cfl rr com, GTK+ mailing list <gtk-app-devel-list gnome org>
From: Harring Figueiredo <harringf yahoo com>
Sender: gtk-app-devel-list-admin gnome org
Subject: Re: Re: Calling a module with a gpointer to data.


 Jim,

 I got your code.

 Could you walk me or point me to the place where the problem is ?

  i.e --  on line 32 of file blah.c I get a core dump or on line 56 of
file
blah.c I show the widget but it never goes to the screen ?

  Thanks.

By the way -- I have helped you before on the Plugin part right ? I
noticed
that you are in Central Fl. -- I am in Orlando. :P)


Harring

--- Jim Parker <hopeye cfl rr com> wrote:
Ok here is the code.

I did not understand your comment about the stack versus the heap.

Thanks for your help

cheers
Jim Parker

On Mon, 29 Jul 2002, Harring Figueiredo wrote:
Date: Mon, 29 Jul 2002 20:56:12 -0700 (PDT)
To: hopeye cfl rr com, GTK+ mailing list
<gtk-app-devel-list gnome org>
From: Harring Figueiredo <harringf yahoo com>
Sender: gtk-app-devel-list-admin gnome org
Subject: Re: Calling a module with a gpointer to data.


Could you provide the code ?

 It seems - from the description -that you are passing a "string"
greated
on
the stack, and not on the heap.

Harring

--- Jim Parker <hopeye cfl rr com> wrote:
G'Day !

My application uses plug-ins to extend the functionality.  When I
load
a
plug-in I build a menu structure in the normal way.  But when I
attach
a
callback to the menu.  The data pointer seems to be corrupt.

Currently I am just passing a text string.  But when I call the
function it
does not print properly (garbage characters).  It works great for
the
menu
items that were created in the main program.

Do I need to do something differently ?

cheers,
Jim Parker

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

ATTACHMENT part 2 application/octet-stream name=plugin.tar.gz



__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com



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