diff options
| author | Arno <arno@disconnect.de> | 2024-08-24 23:24:50 +0200 | 
|---|---|---|
| committer | Arno <arno@disconnect.de> | 2024-08-31 11:56:45 +0200 | 
| commit | 66606fd5cc6bd3d377cc35d9ce2e267b694410fc (patch) | |
| tree | c84c66431c49954251031e401f9ff852290e7345 /helper.cpp | |
| parent | 7f10707eb9c9ab9d4651022bfa89550b05d375c2 (diff) | |
| download | SheMov-66606fd5cc6bd3d377cc35d9ce2e267b694410fc.tar.gz SheMov-66606fd5cc6bd3d377cc35d9ce2e267b694410fc.tar.bz2 SheMov-66606fd5cc6bd3d377cc35d9ce2e267b694410fc.zip | |
Catch Magick::Exception
Prevent crash when trying to convert a file to png. This was a hard one.
After checking into detached QT-Containers I finally realized that
convertArchivefileToPng was the culprit, because ImageMagick::read
exited with an "Unsupported marker type 0x09" execption.
After some more investigation with convert, or magick convert these
days, I found out that they could be ignored. Yes, it's a big hammer,
but if it still fails after trying to convert, just return if still
don't have a valid image.
Diffstat (limited to 'helper.cpp')
| -rw-r--r-- | helper.cpp | 10 | 
1 files changed, 6 insertions, 4 deletions
| @@ -321,15 +321,17 @@ namespace Helper {          QString newFn = data.at(0).toString();          newFn.replace(QRegularExpression("(jpg|jpeg)$", QRegularExpression::CaseInsensitiveOption), "png");          Magick::Image img; -        img.read(data.at(3).toByteArray().data()); +        try { +            img.read(data.at(3).toByteArray().data()); +        } +        catch(Magick::Exception &) {} +          QTemporaryFile outFile("shemovconvertXXXXXX.png");          if(outFile.open()){              try {                  img.write(outFile.fileName().toStdString());              } -            catch(Magick::Exception &) { -                return retval; -            } +            catch(Magick::Exception &) {}              outFile.rename(newFn);              QString newMd5 = md5Sum(outFile.fileName());              QString dest = moveToArchive(outFile.fileName(), newMd5, true); | 
