Gtk-app-devel-list Archive

List Statistics

  • Total Threads: 1015
  • Total Posts: 1266

Phrases Used to Find This Thread

  #1  
23-07-2012 06:29 AM
Gtk-app-devel-list member admin is online now
User
 

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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)

  #2  
24-07-2012 07:27 AM
Gtk-app-devel-list member admin is online now
User
 

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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)
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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)

  #3  
24-07-2012 07:43 AM
Gtk-app-devel-list member admin is online now
User
 

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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)
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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)
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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)

  #4  
24-07-2012 08:05 AM
Gtk-app-devel-list member admin is online now
User
 

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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)
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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)
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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
)
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-
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





NewsArc Lists  |  Culture Pages   |  Computing Archive  |  Media-Pages
Link to this page on your blog or website by copying the HTML code below and pasting it into your site: