Re: Keywords with id=0?
Johannes Zarl-Zierl <[email protected]> Mon, 16 Dec 2019 00:30:54 +0100
| Newsgroups | gmane.comp.kde.kimdaba |
|---|---|
| Message-ID | <1694583.yjPjIMzLF4@mani> |
Am Sonntag, 15. Dezember 2019, 22:59:40 CET schrieb Robert Krawitz: > On Sun, 15 Dec 2019 19:05:27 +0100, Johannes Zarl-Zierl wrote: > >> > A final thought (not having tried the fix yet): shouldn't we also use > >> > m_idMap.at(name, 0) instead of m_idMap[name] in idForName()? > >> > >> Why? > > > > Because in initIdMap() we check whether the m_idMap already contains > > the tag and only set an id otherwise. We don't want to insert an > > invalid value into m_idMap by using operator[]. > > We're not inserting anything in idForName(); we're just retrieving it. Sorry, I somehow overlooked that idForName() is of course const. I'm somewhat paranoid when it comes to QMap::operator[] ever since I've accidentally inserted values into a map by calling its non-const version.