gtask: free task data and source object only from main-context thread
@chergert
Submitted by Christian Hergert Link to original bug (#793802)
Description
I just noticed an assertion in Builder that would indicative some very bad behavior (especially given how insanely much we use GTask in Builder).
The assertion came from our GDestroyNotify for the GTask task-data being called from a non-main thread (which is the active thread when the task created, so therefore the thread for callbacks).
ide-unsaved-files:ERROR:../src/libide/buffers/ide-unsaved-files.c:92:async_state_free: assertion failed: (IDE_IS_MAIN_THREAD ())
I wanted to check with those here and see if that could indeed happen, and if so, I think we should try really hard to prevent it.
Doing things like ref'ing a GtkWidget as task data could have disastrous behavior (and I know I'm not the only one to do this).