- // FIXME: threading
- int row = playlist_clips->get_currently_playing();
- if (row != -1 && row < int(playlist_clips->size()) - 1) {
- return *playlist_clips->clip(row + 1);
- } else {
- return Clip();
- }
+ // playlist_clips can only be accessed on the main thread.
+ // Hopefully, we won't have to wait too long for this to come back.
+ promise<Clip> clip_promise;
+ future<Clip> clip = clip_promise.get_future();
+ post_to_main_thread([this, &clip_promise] {
+ int row = playlist_clips->get_currently_playing();
+ if (row != -1 && row < int(playlist_clips->size()) - 1) {
+ clip_promise.set_value(*playlist_clips->clip(row + 1));
+ } else {
+ clip_promise.set_value(Clip());
+ }
+ });
+ return clip.get();