From c7b0d2967acf2430aabfda4910e77f4cf4827f55 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 17 Jun 2024 23:47:28 +0200 Subject: Fix crash when trying to read an invalid image Helper::picSize assumed that all data passed to it is a valid image and thus crashed with an exception. Wrap it into try - catch and return QVariant() when the pic is invalid. --- newpicsdialog.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'newpicsdialog.cpp') diff --git a/newpicsdialog.cpp b/newpicsdialog.cpp index baaed8f..e7e963b 100644 --- a/newpicsdialog.cpp +++ b/newpicsdialog.cpp @@ -354,6 +354,9 @@ void NewPicFilesModel::addFile(const QString &path){ return; } QVariant picSize = Helper::picSize(fi.absoluteFilePath()); + if(picSize == QVariant()){ + return; + } insertRows(0, 1, QModelIndex()); QModelIndex inserted = index(0, 1, QModelIndex()); setData(inserted, fi.fileName(), FileNameRole); -- cgit v1.2.3-70-g09d2