From deed9799f5a8edc49d9747cfef3394999b59b54f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 27 Feb 2021 12:45:11 +0100 Subject: Fix crash with certain monitor setups --- src/QuickMedia.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 7eb36ca..dd5b025 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -79,14 +79,16 @@ static int get_monitor_max_hz(Display *display) { for(int i = 0; i < screen_res->noutput; ++i) { XRROutputInfo *out_info = XRRGetOutputInfo(display, screen_res, screen_res->outputs[i]); if(out_info && out_info->connection == RR_Connected) { - XRRCrtcInfo* crt_info = XRRGetCrtcInfo(display, screen_res, out_info->crtc); - const XRRModeInfo *mode_info = get_mode_info(screen_res, crt_info->mode); - if(mode_info) { - unsigned long total = mode_info->hTotal * mode_info->vTotal; - if(total > 0) - max_hz = std::max(max_hz, mode_info->dotClock / total); + XRRCrtcInfo *crt_info = XRRGetCrtcInfo(display, screen_res, out_info->crtc); + if(crt_info) { + const XRRModeInfo *mode_info = get_mode_info(screen_res, crt_info->mode); + if(mode_info) { + unsigned long total = mode_info->hTotal * mode_info->vTotal; + if(total > 0) + max_hz = std::max(max_hz, mode_info->dotClock / total); + } + XRRFreeCrtcInfo(crt_info); } - XRRFreeCrtcInfo(crt_info); } if(out_info) XRRFreeOutputInfo(out_info); @@ -1769,7 +1771,7 @@ namespace QuickMedia { related_videos = video_page->get_related_media(video_url, channel_url); // TODO: Make this also work for other video plugins - if(strcmp(plugin_name, "youtube") != 0) + if(strcmp(plugin_name, "youtube") != 0 || resume_video) return; std::string video_id; -- cgit v1.2.3