Comment 6 for bug 1076002

Revision history for this message
Victor Martinez (victored) wrote :

This is the thread-safety issue I was talking about the other day. It seems a draw operation is being triggered from a thread other than GTK+'s main thread (which is the same default thread of the app). This happens after calling LibraryManager.update_media(), so we must check that no UI handler is fired from a separate thread.

The code to blame is the following:

LINE 587 - LibraryManager.vala:

    private async void update_smart_playlists_async () {
        SourceFunc callback = update_smart_playlists_async.callback;

        // Playlist.update_library() will fire the playlists' media_added() and media_removed() signals, which
        // trigger an update in PlaylistViewWrapper (this is the source of the redraw).
        Threads.add (() => {
            lock (_smart_playlists) {
                foreach (var p in smart_playlists ()) {
                    lock (_media) {
                        p.update_library (media ());
                    }
                }
            }
            Idle.add ((owned) callback);
        });

        yield;
    }

We should use Idle.add instead of Threads.add, which is not equivalent, but we must not do this from other thread anyway.