Re: passing args



"DINH V. Hoà" <dinh enserb fr> writes:

> ok, the way I gave won't work but yours won't work too.
>
> because, data will be freed as much as the function is called. (the
> function is called periodically with gtk_timeout_add).

You are absolutly right.
I was confused by the name of the function (I don't use it very
often). So I thought it has something to do with the timeout in the
poll-call, which will only trigger once. Something like the
task_queues in kernel-land.

So i've learned again to always RTFM before answering.

> then the a better solution is :
>  {
>    struct struct_arg1_arg2 *data;
>  
>    data = malloc (sizeof (struct struct_arg1_arg2));
>    g_assert (data != 0);
>    /* init data */
>    gtk_timeout_add (interval, function, &data);
>  }

You have also to store also the return value of gtk_timeout_add if you 
ever want to get rid of the timer.

Is there a way to add a timeout, wich is only triggered once?
If not are there any plans to put something like this in a new version 
of gtk?

bye
juergen




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