Permalink
Browse files

Fix an error that caused runtime warnings from Qt.

git-svn-id: https://scantailor.svn.sourceforge.net/svnroot/scantailor/trunk@414 80b70061-164d-0410-b7b7-e274ec932871
  • Loading branch information...
1 parent ed69779 commit ea0b739e7f9e295a7866bab5e000d05a4e4f5a21 jart committed Sep 13, 2009
Showing with 14 additions and 6 deletions.
  1. +1 −1 AtomicFileOverwriter.cpp
  2. +6 −2 JpegMetadataLoader.cpp
  3. +5 −1 PngMetadataLoader.cpp
  4. +2 −2 ThumbnailPixmapCache.cpp
@@ -39,7 +39,7 @@ AtomicFileOverwriter::startWriting(QString const& file_path)
m_ptrTempFile.reset(new QTemporaryFile(file_path));
m_ptrTempFile->setAutoRemove(false);
if (!m_ptrTempFile->open()) {
- m_ptrTempFile->reset();
+ m_ptrTempFile.reset();
}
return m_ptrTempFile.get();
@@ -1,6 +1,6 @@
/*
Scan Tailor - Interactive post-processing tool for scanned pages.
- Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+ Copyright (C) 2007-2009 Joseph Artsimovich <joseph_a@mail.ru>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -223,9 +223,13 @@ JpegMetadataLoader::loadMetadata(
QIODevice& io_device,
VirtualFunction1<void, ImageMetadata const&>& out)
{
+ if (!io_device.isReadable()) {
+ return GENERIC_ERROR;
+ }
+
static unsigned char const jpeg_signature[] = { 0xff, 0xd8, 0xff };
static int const sig_size = sizeof(jpeg_signature);
-
+
unsigned char signature[sig_size];
if (io_device.peek((char*)signature, sig_size) != sig_size) {
return FORMAT_NOT_RECOGNIZED;
@@ -1,6 +1,6 @@
/*
Scan Tailor - Interactive post-processing tool for scanned pages.
- Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+ Copyright (C) 2007-2009 Joseph Artsimovich <joseph_a@mail.ru>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -95,6 +95,10 @@ PngMetadataLoader::loadMetadata(
QIODevice& io_device,
VirtualFunction1<void, ImageMetadata const&>& out)
{
+ if (!io_device.isReadable()) {
+ return GENERIC_ERROR;
+ }
+
png_byte signature[8];
if (io_device.peek((char*)signature, 8) != 8) {
return FORMAT_NOT_RECOGNIZED;
@@ -476,7 +476,7 @@ ThumbnailPixmapCache::Impl::ensureThumbnailExists(
AtomicFileOverwriter overwriter;
QIODevice* iodev = overwriter.startWriting(thumb_file_path);
- if (thumbnail.save(iodev, "PNG")) {
+ if (iodev && thumbnail.save(iodev, "PNG")) {
overwriter.commit();
}
}
@@ -505,7 +505,7 @@ ThumbnailPixmapCache::Impl::recreateThumbnail(
// Note that we may be called from multiple threads at the same time.
AtomicFileOverwriter overwriter;
QIODevice* iodev = overwriter.startWriting(thumb_file_path);
- if (thumbnail.save(iodev, "PNG")) {
+ if (iodev && thumbnail.save(iodev, "PNG")) {
thumb_written = overwriter.commit();
} else {
overwriter.abort();

0 comments on commit ea0b739

Please sign in to comment.