From f9608af936c39c57633129a62472d315aef62d9c Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 14 Nov 2020 07:02:47 +0100 Subject: Fix crash on video navigating to related video and then back and forth --- src/QuickMedia.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 6e9fcf3..c01ce59 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1817,8 +1817,6 @@ namespace QuickMedia { } }; - bool fullscreen = false; - while (current_page == PageType::VIDEO_CONTENT && window.isOpen()) { while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) { @@ -1844,7 +1842,6 @@ namespace QuickMedia { current_page = previous_page; } else if(pressed_keysym == XK_f && pressing_ctrl) { window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE); - fullscreen = !fullscreen; } else if(pressed_keysym == XK_r && pressing_ctrl) { if(!cursor_visible) window.setMouseCursorVisible(true); @@ -1874,14 +1871,16 @@ namespace QuickMedia { bool page_changed = false; page_loop(tabs, 1, [this, &video_player, &page_changed]() { window.setMouseCursorVisible(true); - video_player->quit_and_save_watch_later(); - while(true) { - VideoPlayer::Error update_err = video_player->update(); - if(update_err != VideoPlayer::Error::OK) - break; - std::this_thread::sleep_for(std::chrono::milliseconds(20)); + if(video_player) { + video_player->quit_and_save_watch_later(); + while(true) { + VideoPlayer::Error update_err = video_player->update(); + if(update_err != VideoPlayer::Error::OK) + break; + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } + video_player.reset(); } - video_player.reset(); page_changed = true; }); @@ -1955,8 +1954,7 @@ namespace QuickMedia { } window.setMouseCursorVisible(true); - if(fullscreen) - window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET); + window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET); auto window_size_u = window.getSize(); window_size.x = window_size_u.x; -- cgit v1.2.3