diff --git a/changelog/unreleased/12045 b/changelog/unreleased/12045 new file mode 100644 index 00000000000..3569b1436ec --- /dev/null +++ b/changelog/unreleased/12045 @@ -0,0 +1,7 @@ +Bugfix: Fix crash after resource job fails + +When a network error occurs while fetching a resource (e.g. a space +image), no icon is available, and a crash would occur. This is fixed by +returning an empty icon. + +https://github.com/owncloud/client/pull/12045 diff --git a/src/libsync/networkjobs/resources.cpp b/src/libsync/networkjobs/resources.cpp index 82420ee4813..4ff189d2f89 100644 --- a/src/libsync/networkjobs/resources.cpp +++ b/src/libsync/networkjobs/resources.cpp @@ -72,8 +72,12 @@ void ResourceJob::finished() QIcon ResourceJob::asIcon() const { + if (_cacheKey.isEmpty()) { + // This can happen when a network error occurred when retrieving the icon. + return {}; + } + // storing the file on disk enables Qt to apply some optimizations (e.g., caching of rendered pixmaps) - Q_ASSERT(!_cacheKey.isEmpty()); return QIcon(_cache->path(_cacheKey)); }