From d3091854805fc625e2f6109f6f4af579420cd2a5 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 2 Mar 2021 00:31:19 +0100 Subject: Fix crash with certain monitor setups #2 --- src/QuickMedia.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index dd5b025..6b480d2 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -109,13 +109,15 @@ static int get_largest_monitor_height(Display *display) { 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) { - // Need to get the min of width or height because we want to get the smallest size for monitors in portrait mode, for mobile devices such as pinephone - int width_or_height = std::min((int)mode_info->width, (int)mode_info->height); - max_height = std::max(max_height, width_or_height); + if(crt_info) { + const XRRModeInfo *mode_info = get_mode_info(screen_res, crt_info->mode); + if(mode_info) { + // Need to get the min of width or height because we want to get the smallest size for monitors in portrait mode, for mobile devices such as pinephone + int width_or_height = std::min((int)mode_info->width, (int)mode_info->height); + max_height = std::max(max_height, width_or_height); + } + XRRFreeCrtcInfo(crt_info); } - XRRFreeCrtcInfo(crt_info); } if(out_info) XRRFreeOutputInfo(out_info); -- cgit v1.2.3