Re: Exit from a window but the process still alive.




Hello, I just solved it. It was (as always) my mistake. I wasn't calling gtk_main_quit() cause I thought that it was called by the system (I guess that's my Windows API background) when the delete or destory events were called. Also, I was connecting these signals to handlers BEFORE creating the Gtk_Window object, so the pointer to the window at the g_signal_connect() was null and the functions got connected to nothing. Now, I connected them right and call the gtk_main_quit at the functions, and everything works fine.

Thank you very much, it was your email yesterday that made me look the whole thing right.

David Necas (Yeti) wrote:

On Tue, Sep 21, 2004 at 03:50:31PM +0200, Bruno G. San Alejo wrote:
Thanks, I connected the signal, but digging up at how an Gtk_Object gets destroyed I came accross the "finalize" method. It says that it's the last method invoked when destroying an object and it's only called when it's reference count is zero. I think that's the problem cause I'm setting the Gtk_window pointer to NULL and freeing it,

Ugh? You should never call free() or g_free() on object
pointers. Just dereference objects with g_object_unref(),
and for widgets normally don't even do that, but destroy
them with gtk_widget_destroy().

and when tracing the program it just doesn't get to that part (probably due to the optimization stuff). But I think that the problem is tha the pointer to the window never gets freed really. Also, there are severeal pointers to different window componets laying around and I'm not freeing those either because they have been made by Glade. I think the problem is that I should be doing some cleaning up at the destroy signal handler, as you said, but I don't know what clean up I must do or how.

This sounds complicated and quite different from the trivial
code you posted before.

I don't know what the Glade code does, however if the window
is closed its "destroy" method should be called, and if you
call gtk_main_quit() in its handler the program should
return from gtk_main(), and thus exit.  If your code is too
conceptually different from Gtk+ "Hello Wordl" or what you
posted, post something more accurate.

Yeti


--
Do not use tab characters. Their effect is not predictable.



--
---------------------------------------------------
"Nunca antes en toda la Historia hemos visto compañias proteger los modelos de negocios basados en tecnologia obsoleta contra la destruccion creativa de nuevas tecnologias. ... El telegrafo no impidio el telefono, el tren no impidio el automovil."
---Howard Rheingold.

"Never before in history have we been able to see incumbent businesses protect business models based on old technology against creative destruction by new technologies. ... The telegraph didn't prevent the telephone, the railroad didn't prevent the automobile."
---Howard Rheingold.
---------------------------------------------------





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