Commit 08930f0bc6b6bd3a83f5a5b1b56aae8d81f40391

Authored by Josh Klontz
1 parent 05f05e11

tweak to File set label

Showing 1 changed file with 10 additions and 3 deletions
sdk/openbr_plugin.cpp
@@ -130,10 +130,17 @@ void File::set(const QString &key, const QVariant &value) @@ -130,10 +130,17 @@ void File::set(const QString &key, const QVariant &value)
130 { 130 {
131 if (key == "Label") { 131 if (key == "Label") {
132 bool ok = false; 132 bool ok = false;
133 - if (value.canConvert(QVariant::Double)) 133 + const QString valueString = value.toString();
  134 +
  135 + /* We assume that if the value starts with '0'
  136 + then it was probably intended to to be a string UID
  137 + and that it's numerical value is not relevant. */
  138 + if (value.canConvert(QVariant::Double) &&
  139 + (!valueString.startsWith('0') || (valueString == "0")))
134 value.toFloat(&ok); 140 value.toFloat(&ok);
135 - if (!ok && !Globals->classes.contains(value.toString()))  
136 - Globals->classes.insert(value.toString(), Globals->classes.size()); 141 +
  142 + if (!ok && !Globals->classes.contains(valueString))
  143 + Globals->classes.insert(valueString, Globals->classes.size());
137 } 144 }
138 145
139 m_metadata.insert(key, value); 146 m_metadata.insert(key, value);