the change of addresses



Hi there!

I got a problem here:

My main-window gets initialized by a function returning a pointer to a
struct with all main-window widgets in it (but this is private, the struct is
owned by the function, only the pointer gets returned).

  struct sim_simfm_win_t *
  sim_win_simfm_new (void);

The next step is to connect the callbacks, this is done with another
function:

  int
  sim_win_simfm_connect_callbacks (struct sim_simfm_win_t *win_simfm);

One of the callabcks (the callback for the delete_event) is for destroying
the main-window and all struct childs (manually). I connected the callback
like this:

g_signal_connect (G_OBJECT (win_simfm->main_window),
  "delete_event",
  G_CALLBACK (sim_callbacks_win_simfm_delete),
  (gpointer) win_simfm);

As the 4th parameter I use the win_simfm pointer, because I have to destroy
the struct and all the childs. So, the callback function should call a
function like this:

sim_win_simfm_destroy ( (struct sim_win_simfm_t *) win_simfm);

where win_simfm is the 4th parameter passed to the "g_signal_connect"
funtion.

And now the problem: The adress I got the first time from
"sim_win_simfm_new" and the address I pass to the "sim_win_simfm_signal_connect" function is
(of corse) the same. But when the signal gets emitted, the address that gets
passed to "sim_win_simfm_destroy" is DIFFRENT. So a segfault accures because
the destroy-func tries to destroy the struct which is not there (on this
address in memory). Why? What have did I do wrong? Why the address changes when the
singnal gets emitted?

Thanks

-- 
Simon Fuhrmann | NightSlayer gmx de | www.dismember.de

GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net




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