Parcourir la source

Be more paranoid about monitor info

These function are not guaranteed to succeed, and we've had reports that
they fail on ARM. So make sure we more properly check return values.
tags/v1.12.90
Pierre Ossman il y a 2 ans
Parent
révision
fabea0a092
1 fichiers modifiés avec 18 ajouts et 6 suppressions
  1. 18
    6
      vncviewer/MonitorArrangement.cxx

+ 18
- 6
vncviewer/MonitorArrangement.cxx Voir le fichier

@@ -406,6 +406,12 @@ std::string MonitorArrangement::get_monitor_name(int m)
#elif defined(__APPLE__)
CGDisplayCount count;
CGDirectDisplayID displays[16];

CGDirectDisplayID displayID;
CFDictionaryRef info;
CFDictionaryRef dict;
CFIndex dict_len;

std::string name;

if (CGGetActiveDisplayList(16, displays, &count) != kCGErrorSuccess)
@@ -418,14 +424,20 @@ std::string MonitorArrangement::get_monitor_name(int m)
return "";

// Notice: Here we assume indices to be ordered the same as in FLTK (we rely on that in cocoa.mm as well).
CGDirectDisplayID displayID = displays[m];
displayID = displays[m];

info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),
kIODisplayOnlyPreferredName);
if (info == NULL)
return "";

CFDictionaryRef info = IODisplayCreateInfoDictionary(
/* display = */ CGDisplayIOServicePort(displayID),
/* options = */ kIODisplayOnlyPreferredName);
dict = (CFDictionaryRef) CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
if (dict == NULL) {
CFRelease(info);
return "";
}

CFDictionaryRef dict = (CFDictionaryRef) CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
CFIndex dict_len = CFDictionaryGetCount(dict);
dict_len = CFDictionaryGetCount(dict);

if (dict_len > 0) {
CFTypeRef * names = new CFTypeRef[dict_len];

Chargement…
Annuler
Enregistrer