[PATCH] Use gtk_tree_model_get_value() to get the index and date of a dive

Dirk Hohndel dirk at hohndel.org
Thu Sep 20 07:56:54 PDT 2012


On Sep 20, 2012, at 5:42 AM, Jef Driesen wrote:
>> Anyway, none of this is needed. subsurface isn't really multi-threaded
>> anyway. The only time you have threads happening is when downloading
>> from a dive computer, and during that time the only thing subsurface
>> does is to call process_ui_events() in the other thread.
>> 
>> That assumes that the gtk main loop itself doesn't use gmtime(), or
>> course, but that had better be a fairly safe assumption.
> 
> That's not entirely correct. When you call process_ui_events() on the main thread, any gtk+ callback can be executed in response to some GUI events. For example the screen can be repainted. But if the listview gets repainted, the date_data_func() will get called to render the dive datetime. And that function does call gmtime().

Correct. One thing we could do is pre-render the time when it gets updated. But I much prefer to simply use a less fragile function for the conversion.

> BTW, I'm not sure whether you are aware of the fact that you shouldn't call gtk+ functions from threads other than the main thread. Doing this happens to work on X11, but it's known to break on windows. Subsurface is breaking this rule when updating the progress bar from the libdivecomputer thread. The correct way to do this is to update the progress bar from the main thread with a call to the g_idle_add function.

Linus, is this something you could fix in the next few days? This is your code and it might be easier for you to come up with an elegant fix.

/D


More information about the subsurface mailing list