Commit 73ecac02 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix crash when opening Krita with ABR brushes with upper case extensions


On Windows we QDirIterator returns us all the matching storages in
case-insensitive manner, so we should make sure we can handle these
storages later.

The patch also adds a fallback storage plugin to make sure Krita
will not crash when handling such storage later.

BUG:447454
parent 0aced718
......@@ -989,6 +989,10 @@ void KisResourceLocator::findStorages()
while (iter.hasNext()) {
iter.next();
KisResourceStorageSP storage = QSharedPointer<KisResourceStorage>::create(iter.filePath());
if (!storage->valid()) {
// we still add the storage to the list and try to read whatever possible
qWarning() << "KisResourceLocator::findStorages: the storage is invalid" << storage->location();
}
d->storages[storage->location()] = storage;
}
}
......
......@@ -88,16 +88,16 @@ KisResourceStorage::KisResourceStorage(const QString &location)
d->storageType = StorageType::Folder;
d->valid = fi.isWritable();
}
else if (d->location.endsWith(".bundle")) {
else if (d->location.endsWith(".bundle", Qt::CaseInsensitive)) {
d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::Bundle]->create(location));
d->storageType = StorageType::Bundle;
// XXX: should we also check whether there's a valid metadata entry? Or is this enough?
d->valid = (fi.isReadable() && QuaZip(d->location).open(QuaZip::mdUnzip));
} else if (d->location.endsWith(".abr")) {
} else if (d->location.endsWith(".abr", Qt::CaseInsensitive)) {
d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::AdobeBrushLibrary]->create(location));
d->storageType = StorageType::AdobeBrushLibrary;
d->valid = fi.isReadable();
} else if (d->location.endsWith(".asl")) {
} else if (d->location.endsWith(".asl", Qt::CaseInsensitive)) {
d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::AdobeStyleLibrary]->create(location));
d->storageType = StorageType::AdobeStyleLibrary;
d->valid = d->storagePlugin->isValid();
......@@ -107,6 +107,8 @@ KisResourceStorage::KisResourceStorage(const QString &location)
d->storageType = StorageType::Memory;
d->valid = true;
} else {
// we create a fake memeory storage to make sure methods like `timestamp()` still work
d->storagePlugin.reset(KisStoragePluginRegistry::instance()->m_storageFactoryMap[StorageType::Memory]->create(location));
d->valid = false;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment