Commit 7948e089 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

metadata: vlc: Fix potential use of dangling reference

There was a slight window in which the event callback was still
registered, but the mutex & condition_variable were destroyed
parent e160b239
......@@ -36,15 +36,15 @@ namespace medialibrary
bool medialibrary::MetadataCommon::startPlayback( VLC::Media& media, VLC::MediaPlayer& mp )
{
// Use a copy of the event manager to automatically unregister all events as soon
// as we leave this method.
bool hasVideoTrack = false;
bool failedToStart = false;
bool hasAnyTrack = false;
bool success = false;
auto em = mp.eventManager();
compat::Mutex mutex;
compat::ConditionVariable cond;
// Use a copy of the event manager to automatically unregister all events as soon
// as we leave this method.
auto em = mp.eventManager();
em.onESAdded([&mutex, &cond, &hasVideoTrack, &hasAnyTrack]( libvlc_track_type_t type, int ) {
std::lock_guard<compat::Mutex> lock( mutex );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment