Re: Passing structure with a callback
It occurs to me that the problem here may be that all roads lead to gtk_main(). If my current theory is correct, then by creating the emailshare structure in the MainMenu function that structure is not available in main(), and hence is not being passed to the Clear function when the clear icon is clicked. In other words, I'm passing garbage data to Clear because the emailshare structure is local to MainMenu. I'm not entirely sure of how the flow of a GTK program actually works, but I am under the impression that a running program just sits in gtk_main() and waits for something to happen, when something happens it executes the appropriate callback, and then returns to gtk_main() and waits again. If this flow is accurate, then since the widgetshare structure in my little program is created in main(), it is available to everything that's being called by gtk_main(), which is why passing a pointer to that structure works but passing a pointer to emailshare doesn't. Under this scenario the Clear function is being called from main() and not from MainMenu. Is my understanding of how this actually works correct? If so, what is the recommended way to deal with structures like this? Set up everything in main()? Use global structs? If I set up everything in main() then things could get really complicated when dealing with nested containers. -- MELVILLE THEATRE ~ Real D 3D Digital Cinema ~ www.melvilletheatre.com www.creekfm.com - FIFTY THOUSAND WATTS of POW WOW POWER! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Passing structure with a callback
On Tue, Jul 24, 2012 at 12:27:41AM -0600, Frank Cox wrote: Is my understanding of how this actually works correct? Yes. Now please read my reply to your first e-mail... If so, what is the recommended way to deal with structures like this? ...that already answered this too. https://mail.gnome.org/archives/gtk-app-devel-list/2012-July/msg00057.html Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Passing structure with a callback
On Tue, Jul 24, 2012 at 08:43:08AM +0200, David Nečas wrote: Now please read my reply to your first e-mail... I see. So, in case you read the mailing list archives: It's a bit pointless to ask questions in a mailing list if your mailserver blocks all answers. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Passing structure with a callback
On Sun, Jul 22, 2012 at 11:22:07PM -0600, Frank Cox wrote: My widgetshare structure gets passed from main() to MainMenu with no apparent problem, but using the same scheme to pass emailshare from MainMenu to Clear segfaults. This is elementary C. Both structures are created on stack so they cease to exist upon return from the corresponding functions. While main() is never exited while the program is running, MainMenu() is particularly short-lived. Use heap-allocated data. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list