Browse Source

Only log error when setting FullScreenSelectedMonitors

We don't want the log to spam every time this parameter is used so only
complain from the parses when the value is changed.
tags/v1.11.90
Pierre Ossman 2 years ago
parent
commit
b24cfff4be
2 changed files with 18 additions and 12 deletions
  1. 16
    11
      vncviewer/MonitorIndicesParameter.cxx
  2. 2
    1
      vncviewer/MonitorIndicesParameter.h

+ 16
- 11
vncviewer/MonitorIndicesParameter.cxx View File

if (strlen(value) < 0) if (strlen(value) < 0)
return false; return false;


if (!parseIndices(value, &indices)) {
if (!parseIndices(value, &indices, true)) {
vlog.error(_("Invalid configuration specified for %s"), name); vlog.error(_("Invalid configuration specified for %s"), name);
return false; return false;
} }


int v = strtol(number.c_str(), NULL, 0); int v = strtol(number.c_str(), NULL, 0);


if (v <= 0) {
vlog.error(_("The given monitor index(%s) is too small to be valid"), number.c_str());
if (v <= 0)
return false; return false;
}


if (v > INT_MAX) {
vlog.error(_("The given monitor index (%s) is too large to be valid"), number.c_str());
if (v > INT_MAX)
return false; return false;
}


indices->insert(v-1); indices->insert(v-1);
return true; return true;
} }


bool MonitorIndicesParameter::parseIndices(const char* value, std::set<int> *indices)
bool MonitorIndicesParameter::parseIndices(const char* value,
std::set<int> *indices,
bool complain)
{ {
char d; char d;
std::string current; std::string current;
current.push_back(d); current.push_back(d);
else if (d == ',') { else if (d == ',') {
if (!parseNumber(current, indices)) { if (!parseNumber(current, indices)) {
vlog.error(_("Invalid monitor index '%s'"), current.c_str());
if (complain)
vlog.error(_("Invalid monitor index '%s'"),
current.c_str());
return false; return false;
} }


current.clear(); current.clear();
} else { } else {
vlog.error(_("Unexpected character '%c'"), d);
if (complain)
vlog.error(_("Unexpected character '%c'"), d);
return false; return false;
} }
} }
return true; return true;


// Parsing anything we have left. // Parsing anything we have left.
if (!parseNumber(current, indices))
if (!parseNumber(current, indices)) {
if (complain)
vlog.error(_("Invalid monitor index '%s'"),
current.c_str());
return false; return false;
}


return true; return true;
} }

+ 2
- 1
vncviewer/MonitorIndicesParameter.h View File

int fltkIndex; int fltkIndex;
} Monitor; } Monitor;


bool parseIndices(const char* value, std::set<int> *indices);
bool parseIndices(const char* value, std::set<int> *indices,
bool complain=false);
std::vector<MonitorIndicesParameter::Monitor> fetchMonitors(); std::vector<MonitorIndicesParameter::Monitor> fetchMonitors();
static int compare(const void*, const void*); static int compare(const void*, const void*);
}; };

Loading…
Cancel
Save