fix: crash if unusual xmp tag used when open property dlg
This commit is contained in:
		@ -35,14 +35,20 @@ void Exiv2Wrapper::cacheSection(Collection collection)
 | 
				
			|||||||
    for (; it != end; ++it) {
 | 
					    for (; it != end; ++it) {
 | 
				
			||||||
        QString key = QString::fromUtf8(it->key().c_str());
 | 
					        QString key = QString::fromUtf8(it->key().c_str());
 | 
				
			||||||
        if (it->tagName().substr(0, 2) == "0x") continue;
 | 
					        if (it->tagName().substr(0, 2) == "0x") continue;
 | 
				
			||||||
        QString label = QString::fromLocal8Bit(it->tagLabel().c_str());
 | 
					        // We might get exceptions like "No namespace info available for XMP prefix `Item'"
 | 
				
			||||||
        std::ostringstream stream;
 | 
					        // when trying to get tagLabel() data from a Xmpdatum if the tag is not common-used.
 | 
				
			||||||
        stream << *it;
 | 
					        // We don't care for those rare tags so let's just use a try-cache...
 | 
				
			||||||
        QString value = QString::fromUtf8(stream.str().c_str());
 | 
					        try {
 | 
				
			||||||
        m_metadataValue.insert(key, value);
 | 
					            QString label = QString::fromLocal8Bit(it->tagLabel().c_str());
 | 
				
			||||||
        m_metadataLabel.insert(key, label);
 | 
					            std::ostringstream stream;
 | 
				
			||||||
 | 
					            stream << *it;
 | 
				
			||||||
        qDebug() << key << label << value;
 | 
					            QString value = QString::fromUtf8(stream.str().c_str());
 | 
				
			||||||
 | 
					            m_metadataValue.insert(key, value);
 | 
				
			||||||
 | 
					            m_metadataLabel.insert(key, label);
 | 
				
			||||||
 | 
					            qDebug() << key << label << value;
 | 
				
			||||||
 | 
					        } catch (Exiv2::BasicError<char> & err) {
 | 
				
			||||||
 | 
					            qWarning() << "Error loading key" << key << ":" << err.code() << err.what();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user