diff -Nru gwenview-4.8.4/app/preloader.cpp gwenview-4.8.5/app/preloader.cpp --- gwenview-4.8.4/app/preloader.cpp 2011-12-20 19:14:04.000000000 +0000 +++ gwenview-4.8.5/app/preloader.cpp 2012-07-30 15:07:59.016061690 +0000 @@ -43,14 +43,24 @@ struct PreloaderPrivate { + Preloader* q; Document::Ptr mDocument; QSize mSize; + + void forgetDocument() + { + // Forget about the document. Keeping a reference to it would prevent it + // from being garbage collected. + QObject::disconnect(mDocument.data(), 0, q, 0); + mDocument = 0; + } }; Preloader::Preloader(QObject* parent) : QObject(parent) , d(new PreloaderPrivate) { + d->q = this; } Preloader::~Preloader() @@ -78,6 +88,12 @@ void Preloader::doPreload() { + if (d->mDocument->loadingState() == Document::LoadingFailed) { + LOG("loading failed"); + d->forgetDocument(); + return; + } + if (!d->mDocument->size().isValid()) { LOG("size not available yet"); return; @@ -95,11 +111,7 @@ LOG("preloading full image"); d->mDocument->startLoadingFullImage(); } - - // Forget about the document. Keeping a reference to it would prevent it - // from being garbage collected. - disconnect(d->mDocument.data(), 0, this, 0); - d->mDocument = 0; + d->forgetDocument(); } } // namespace diff -Nru gwenview-4.8.4/app/viewmainpage.cpp gwenview-4.8.5/app/viewmainpage.cpp --- gwenview-4.8.4/app/viewmainpage.cpp 2012-01-02 19:53:00.135329698 +0000 +++ gwenview-4.8.5/app/viewmainpage.cpp 2012-07-30 15:07:59.016061690 +0000 @@ -560,10 +560,7 @@ bool ViewMainPage::isEmpty() const { - if (!d->currentView()) { - return true; - } - return d->currentView()->isEmpty(); + return !currentDocument(); } RasterImageView* ViewMainPage::imageView() const diff -Nru gwenview-4.8.4/debian/changelog gwenview-4.8.5/debian/changelog --- gwenview-4.8.4/debian/changelog 2012-06-23 20:32:06.000000000 +0000 +++ gwenview-4.8.5/debian/changelog 2012-09-07 14:38:29.000000000 +0000 @@ -1,3 +1,9 @@ +gwenview (4:4.8.5-0ubuntu0.1) precise-proposed; urgency=low + + * New upstream bugfix release (LP: #1047417) + + -- Scott Kitterman Fri, 07 Sep 2012 16:38:29 +0200 + gwenview (4:4.8.4-0ubuntu0.1) precise-proposed; urgency=low * New upstream release. (LP: #1007798) diff -Nru gwenview-4.8.4/debian/control gwenview-4.8.5/debian/control --- gwenview-4.8.4/debian/control 2012-06-04 12:19:41.000000000 +0000 +++ gwenview-4.8.5/debian/control 2012-07-30 20:07:27.000000000 +0000 @@ -4,7 +4,7 @@ Maintainer: Kubuntu Developers XSBC-Original-Maintainer: Debian Qt/KDE Maintainers Uploaders: Eshat Cakar -Build-Depends: kde-sc-dev-latest (>= 4:4.8.4), +Build-Depends: kde-sc-dev-latest (>= 4:4.8.5), cmake, debhelper (>= 7.3.16), pkg-kde-tools (>= 0.12), libexiv2-dev, libjpeg-dev, Binary files /tmp/oROVfohagK/gwenview-4.8.4/doc/index.cache.bz2 and /tmp/q6FgY9qBpW/gwenview-4.8.5/doc/index.cache.bz2 differ diff -Nru gwenview-4.8.4/lib/CMakeLists.txt gwenview-4.8.5/lib/CMakeLists.txt --- gwenview-4.8.4/lib/CMakeLists.txt 2012-02-29 22:57:15.969328306 +0000 +++ gwenview-4.8.5/lib/CMakeLists.txt 2012-07-30 15:07:59.017061681 +0000 @@ -163,6 +163,7 @@ set_source_files_properties( exiv2imageloader.cpp + imagemetainfomodel.cpp PROPERTIES COMPILE_FLAGS "${KDE4_ENABLE_EXCEPTIONS}" ) diff -Nru gwenview-4.8.4/lib/document/document.cpp gwenview-4.8.5/lib/document/document.cpp --- gwenview-4.8.4/lib/document/document.cpp 2011-12-20 19:14:04.000000000 +0000 +++ gwenview-4.8.5/lib/document/document.cpp 2012-07-30 15:07:59.017061681 +0000 @@ -376,7 +376,10 @@ return true; } - if (loadingState() == Loaded) { + if (loadingState() == LoadingFailed) { + kWarning() << "Image has failed to load, not doing anything"; + return false; + } else if (loadingState() == Loaded) { // Resample image from the full one d->mDownSampledImageMap[invertedZoom] = d->mImage.scaled(d->mImage.size() / invertedZoom, Qt::KeepAspectRatio, Qt::FastTransformation); if (d->mDownSampledImageMap[invertedZoom].size().isEmpty()) { diff -Nru gwenview-4.8.4/lib/document/documentfactory.cpp gwenview-4.8.5/lib/document/documentfactory.cpp --- gwenview-4.8.4/lib/document/documentfactory.cpp 2012-06-01 12:32:33.257467830 +0000 +++ gwenview-4.8.5/lib/document/documentfactory.cpp 2012-07-30 15:07:59.017061681 +0000 @@ -34,7 +34,7 @@ #undef ENABLE_LOG #undef LOG -#define ENABLE_LOG +//#define ENABLE_LOG #ifdef ENABLE_LOG #define LOG(x) kDebug() << x #else diff -Nru gwenview-4.8.4/lib/documentview/documentview.cpp gwenview-4.8.5/lib/documentview/documentview.cpp --- gwenview-4.8.4/lib/documentview/documentview.cpp 2012-02-29 22:57:15.969328306 +0000 +++ gwenview-4.8.5/lib/documentview/documentview.cpp 2012-07-30 15:07:59.017061681 +0000 @@ -409,11 +409,6 @@ d->updateCaption(); } -bool DocumentView::isEmpty() const -{ - return qobject_cast(d->mAdapter.data()); -} - void DocumentView::loadAdapterConfig() { d->mAdapter->loadConfig(); diff -Nru gwenview-4.8.4/lib/documentview/documentview.h gwenview-4.8.5/lib/documentview/documentview.h --- gwenview-4.8.4/lib/documentview/documentview.h 2012-01-02 19:53:00.136329689 +0000 +++ gwenview-4.8.5/lib/documentview/documentview.h 2012-07-30 15:07:59.017061681 +0000 @@ -84,12 +84,6 @@ */ void loadAdapterConfig(); - /** - * Returns true if an adapter is loaded (note: adapters are also used to - * display error messages!) - */ - bool isEmpty() const; - bool canZoom() const; qreal minimumZoom() const; diff -Nru gwenview-4.8.4/lib/exiv2imageloader.h gwenview-4.8.5/lib/exiv2imageloader.h --- gwenview-4.8.4/lib/exiv2imageloader.h 2011-12-02 21:32:06.000000000 +0000 +++ gwenview-4.8.5/lib/exiv2imageloader.h 2012-07-30 15:07:59.017061681 +0000 @@ -21,6 +21,8 @@ #ifndef EXIV2IMAGELOADER_H #define EXIV2IMAGELOADER_H +#include + // Qt // KDE @@ -43,7 +45,7 @@ * This helper class loads image using libexiv2, and takes care of exception * handling for the different versions of libexiv2. */ -class Exiv2ImageLoader +class GWENVIEWLIB_EXPORT Exiv2ImageLoader { public: Exiv2ImageLoader(); diff -Nru gwenview-4.8.4/lib/imagemetainfomodel.cpp gwenview-4.8.5/lib/imagemetainfomodel.cpp --- gwenview-4.8.4/lib/imagemetainfomodel.cpp 2011-12-20 19:14:04.000000000 +0000 +++ gwenview-4.8.5/lib/imagemetainfomodel.cpp 2012-07-30 15:07:59.017061681 +0000 @@ -262,25 +262,28 @@ it = container.begin(), end = container.end(); - if (it == end) { - return; - } - for (; it != end; ++it) { - QString key = QString::fromUtf8(it->key().c_str()); - QString label = QString::fromLocal8Bit(it->tagLabel().c_str()); - std::ostringstream stream; - stream << *it; - QString value = QString::fromLocal8Bit(stream.str().c_str()); - - EntryHash::iterator hashIt = hash.find(key); - if (hashIt != hash.end()) { - hashIt.value()->appendValue(value); - } else { - hash.insert(key, new MetaInfoGroup::Entry(key, label, value)); + try { + QString key = QString::fromUtf8(it->key().c_str()); + QString label = QString::fromLocal8Bit(it->tagLabel().c_str()); + std::ostringstream stream; + stream << *it; + QString value = QString::fromLocal8Bit(stream.str().c_str()); + + EntryHash::iterator hashIt = hash.find(key); + if (hashIt != hash.end()) { + hashIt.value()->appendValue(value); + } else { + hash.insert(key, new MetaInfoGroup::Entry(key, label, value)); + } + } catch (const Exiv2::Error& error) { + kWarning() << "Failed to read some meta info:" << error.what(); } } + if (hash.isEmpty()) { + return; + } q->beginInsertRows(parent, 0, hash.size() - 1); Q_FOREACH(MetaInfoGroup::Entry * entry, hash) { group->addEntry(entry); diff -Nru gwenview-4.8.4/lib/version.h gwenview-4.8.5/lib/version.h --- gwenview-4.8.4/lib/version.h 2012-06-01 12:32:33.296467498 +0000 +++ gwenview-4.8.5/lib/version.h 2012-07-30 15:08:04.759006901 +0000 @@ -21,6 +21,6 @@ #ifndef VERSION_H #define VERSION_H -#define GWENVIEW_VERSION "2.8.4" +#define GWENVIEW_VERSION "2.8.5" #endif /* VERSION_H */ diff -Nru gwenview-4.8.4/tests/auto/CMakeLists.txt gwenview-4.8.5/tests/auto/CMakeLists.txt --- gwenview-4.8.4/tests/auto/CMakeLists.txt 2011-12-20 19:14:04.000000000 +0000 +++ gwenview-4.8.5/tests/auto/CMakeLists.txt 2012-07-30 15:07:59.018061671 +0000 @@ -45,3 +45,4 @@ ) gv_add_unit_test(sorteddirmodeltest testutils.cpp) gv_add_unit_test(slidecontainerautotest slidecontainerautotest.cpp) +gv_add_unit_test(imagemetainfomodeltest testutils.cpp) diff -Nru gwenview-4.8.4/tests/auto/documenttest.cpp gwenview-4.8.5/tests/auto/documenttest.cpp --- gwenview-4.8.4/tests/auto/documenttest.cpp 2012-03-29 20:29:13.077167654 +0000 +++ gwenview-4.8.5/tests/auto/documenttest.cpp 2012-07-30 15:07:59.031061546 +0000 @@ -274,6 +274,19 @@ QVERIFY2(spy.count() > count, "No imageRectUpdated() signal received after restarting"); } +void DocumentTest::testPrepareDownSampledAfterFailure() +{ + KUrl url = urlForTestFile("empty.png"); + Document::Ptr doc = DocumentFactory::instance()->load(url); + + doc->startLoadingFullImage(); + doc->waitUntilLoaded(); + QCOMPARE(doc->loadingState(), Document::LoadingFailed); + + bool ready = doc->prepareDownSampledImageForZoom(0.25); + QVERIFY2(!ready, "Down sampled image should not be ready"); +} + void DocumentTest::testSaveRemote() { KUrl dstUrl = setUpRemoteTestDir(); diff -Nru gwenview-4.8.4/tests/auto/documenttest.h gwenview-4.8.5/tests/auto/documenttest.h --- gwenview-4.8.4/tests/auto/documenttest.h 2011-12-20 19:14:04.000000000 +0000 +++ gwenview-4.8.5/tests/auto/documenttest.h 2012-07-30 15:07:59.031061546 +0000 @@ -111,6 +111,7 @@ void testLoadDownSampledPng(); void testLoadRemote(); void testLoadAnimated(); + void testPrepareDownSampledAfterFailure(); void testDeleteWhileLoading(); void testLoadRotated(); void testMultipleLoads(); diff -Nru gwenview-4.8.4/tests/auto/imagemetainfomodeltest.cpp gwenview-4.8.5/tests/auto/imagemetainfomodeltest.cpp --- gwenview-4.8.4/tests/auto/imagemetainfomodeltest.cpp 1970-01-01 00:00:00.000000000 +0000 +++ gwenview-4.8.5/tests/auto/imagemetainfomodeltest.cpp 2012-07-30 15:07:59.031061546 +0000 @@ -0,0 +1,58 @@ +/* +Gwenview: an image viewer +Copyright 2012 Aurélien Gâteau + +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 the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ +// Qt + +// KDE +#include +#include + +// Local +#include "../lib/exiv2imageloader.h" +#include "../lib/imagemetainfomodel.h" +#include "testutils.h" + +#include + +#include "imagemetainfomodeltest.moc" + +QTEST_KDEMAIN(ImageMetaInfoModelTest, GUI) + +using namespace Gwenview; + +void ImageMetaInfoModelTest::testCatchExiv2Errors() +{ + QByteArray data; + { + QString path = pathForTestFile("302350_exiv_0.23_exception.jpg"); + QFile file(path); + QVERIFY(file.open(QIODevice::ReadOnly)); + data = file.readAll(); + } + + Exiv2::Image::AutoPtr image; + { + Exiv2ImageLoader loader; + QVERIFY(loader.load(data)); + image = loader.popImage(); + } + + ImageMetaInfoModel model; + model.setExiv2Image(image.get()); +} diff -Nru gwenview-4.8.4/tests/auto/imagemetainfomodeltest.h gwenview-4.8.5/tests/auto/imagemetainfomodeltest.h --- gwenview-4.8.4/tests/auto/imagemetainfomodeltest.h 1970-01-01 00:00:00.000000000 +0000 +++ gwenview-4.8.5/tests/auto/imagemetainfomodeltest.h 2012-07-30 15:07:59.031061546 +0000 @@ -0,0 +1,38 @@ +/* +Gwenview: an image viewer +Copyright 2012 Aurélien Gâteau + +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 the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +*/ +#ifndef IMAGEMETAINFOMODELTEST_H +#define IMAGEMETAINFOMODELTEST_H + +// Qt +#include + +// KDE + +// Local + +class ImageMetaInfoModelTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testCatchExiv2Errors(); +}; + +#endif // IMAGEMETAINFOMODELTEST_H Binary files /tmp/oROVfohagK/gwenview-4.8.4/tests/data/302350_exiv_0.23_exception.jpg and /tmp/q6FgY9qBpW/gwenview-4.8.5/tests/data/302350_exiv_0.23_exception.jpg differ