[KPhotoAlbum] Keywords with id=0?

Robert Krawitz rlk at alum.mit.edu
Sun Dec 15 23:42:01 GMT 2019


So this is where we are now:

diff --git a/XMLDB/XMLCategory.cpp b/XMLDB/XMLCategory.cpp
index 712cc689..1ddc00f3 100644
--- a/XMLDB/XMLCategory.cpp
+++ b/XMLDB/XMLCategory.cpp
@@ -20,6 +20,7 @@
 #include <DB/ImageDB.h>
 #include <DB/MemberMap.h>
 #include <Utilities/List.h>
+#include "Logging.h"
 
 XMLDB::XMLCategory::XMLCategory(const QString &name, const QString &icon, ViewType type, int thumbnailSize, bool show, bool positionable)
     : m_name(name)
@@ -130,7 +131,8 @@ void XMLDB::XMLCategory::renameItem(const QString &oldValue, const QString &newV
     m_idMap.remove(oldValue);
 
     addItem(newValue);
-    setIdMapping(newValue, id);
+    if ( id > 0)
+        setIdMapping(newValue, id);
     emit itemRenamed(oldValue, newValue);
 }
 
@@ -179,8 +181,12 @@ void XMLDB::XMLCategory::initIdMap()
 
 void XMLDB::XMLCategory::setIdMapping(const QString &name, int id)
 {
-    m_nameMap.insert(id, name);
-    m_idMap.insert(name, id);
+    if (id <= 0) {
+        qCWarning(XMLDBLog, "XMLDB::XMLCategory::setIdMapping attempting to set id for %s to invalid value %d", qPrintable(name), id);
+    } else {
+        m_nameMap.insert(id, name);
+        m_idMap.insert(name, id);
+    }
 }
 
 QString XMLDB::XMLCategory::nameForId(int id) const


-- 
Robert Krawitz                                     <rlk at alum.mit.edu>

***  MIT Engineers   A Proud Tradition   http://mitathletics.com  ***
Member of the League for Programming Freedom  --  http://ProgFree.org
Project lead for Gutenprint   --    http://gimp-print.sourceforge.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton



More information about the Kphotoalbum mailing list