mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Desktop: Fix Crash when Adding JPG Image on MacOS.
Fix a crash on MacOS when trying to open a JPG image with libraw by filtering files by valid extensions for RAW files. Fixes #4377. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
71ebee8ab6
commit
5b5d2868e2
3 changed files with 6 additions and 5 deletions
|
@ -74,9 +74,9 @@ void ImageDownloader::saveImage(QNetworkReply *reply)
|
|||
reply->deleteLater();
|
||||
}
|
||||
|
||||
static bool hasVideoFileExtension(const QString &filename)
|
||||
static bool hasFileExtension(const QString &filename, const QStringList extensionsList)
|
||||
{
|
||||
for (const QString &ext: videoExtensionsList)
|
||||
for (const QString &ext: extensionsList)
|
||||
if (filename.endsWith(ext, Qt::CaseInsensitive))
|
||||
return true;
|
||||
return false;
|
||||
|
@ -136,7 +136,7 @@ Thumbnailer::Thumbnail Thumbnailer::fetchImage(const QString &urlfilename, const
|
|||
|
||||
#ifdef LIBRAW_SUPPORT
|
||||
// If note, perhaps a raw image?
|
||||
if (thumb.isNull())
|
||||
if (thumb.isNull() && hasFileExtension(filename, rawExtensionsList))
|
||||
thumb = fetchRawThumbnail(filename);
|
||||
#endif
|
||||
if (!thumb.isNull()) {
|
||||
|
@ -148,7 +148,7 @@ Thumbnailer::Thumbnail Thumbnailer::fetchImage(const QString &urlfilename, const
|
|||
// Neither our code, nor Qt could determine the type of this object from looking at the data.
|
||||
// Try to check for a video-file extension. Since we couldn't parse the video file,
|
||||
// we pass 0 as the duration.
|
||||
if (hasVideoFileExtension(filename))
|
||||
if (hasFileExtension(filename, videoExtensionsList))
|
||||
return fetchVideoThumbnail(filename, originalFilename, duration_t());
|
||||
|
||||
// Give up: we simply couldn't determine what this thing is.
|
||||
|
|
|
@ -1092,7 +1092,7 @@ const QStringList videoExtensionsList = {
|
|||
};
|
||||
|
||||
// Raw extensions according to https://en.wikipedia.org/wiki/Raw_image_format
|
||||
static const QStringList rawExtensionsList = {
|
||||
const QStringList rawExtensionsList = {
|
||||
#ifdef LIBRAW_SUPPORT
|
||||
"*.3fr", "*.ari", "*.arw", "*.bay", "*.braw", "*.crw", "*.cr2", "*.cr3", "*.cap",
|
||||
"*.data", "*.dcs", "*.dcr", "*.dng", "*.drf", "*.eip", "*.erf", "*.fff", "*.gpr",
|
||||
|
|
|
@ -41,6 +41,7 @@ bool parseGpsText(const QString &gps_text, double *latitude, double *longitude);
|
|||
void init_proxy();
|
||||
QStringList getWaterTypesAsString();
|
||||
extern const QStringList videoExtensionsList;
|
||||
extern const QStringList rawExtensionsList;
|
||||
QStringList mediaExtensionFilters();
|
||||
QStringList imageExtensionFilters();
|
||||
QStringList videoExtensionFilters();
|
||||
|
|
Loading…
Add table
Reference in a new issue