Sfoglia il codice sorgente

amending helper function to return generic task code if key not found

logicp 4 anni fa
parent
commit
2697795ba9
1 ha cambiato i file con 4 aggiunte e 1 eliminazioni
  1. 4 1
      include/task/task.hpp

+ 4 - 1
include/task/task.hpp

@@ -33,7 +33,10 @@ inline static std::map<std::string, uint32_t> TaskCodes{
 };
 
 inline static uint32_t findTaskCode(QString key) {
-  return TaskCodes.at(key.toUtf8().constData());
+  auto it = TaskCodes.find(key.toUtf8().constData());
+  return it == TaskCodes.end() ?
+    TaskCodes.at("Generic") :
+    (*it).second;
 }
 
 /**