From 18c8cf59e86ef24f64c91cb1000d6088eb77f11c Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 20 Apr 2008 09:49:20 +0000 Subject: [PATCH] - when the loading of a textdocument-based document fails, cleanup all the stuff eventually gathered from the converter - cleanup also the annotation position when closing a textdocument svn path=/trunk/KDE/kdegraphics/okular/; revision=799076 --- core/textdocumentgenerator.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/textdocumentgenerator.cpp b/core/textdocumentgenerator.cpp index c362a7184..3ff580ba9 100644 --- a/core/textdocumentgenerator.cpp +++ b/core/textdocumentgenerator.cpp @@ -235,7 +235,22 @@ bool TextDocumentGenerator::loadDocument( const QString & fileName, QVectormDocument = d->mConverter->convert( fileName ); if ( !d->mDocument ) + { + // loading failed, cleanup all the stuff eventually gathered from the converter + d->mTitlePositions.clear(); + Q_FOREACH ( const TextDocumentGeneratorPrivate::LinkPosition &linkPos, d->mLinkPositions ) + { + delete linkPos.link; + } + d->mLinkPositions.clear(); + Q_FOREACH ( const TextDocumentGeneratorPrivate::AnnotationPosition &annPos, d->mAnnotationPositions ) + { + delete annPos.annotation; + } + d->mAnnotationPositions.clear(); + return false; + } d->generateTitleInfos(); d->generateLinkInfos(); @@ -288,6 +303,7 @@ bool TextDocumentGenerator::doCloseDocument() d->mTitlePositions.clear(); d->mLinkPositions.clear(); d->mLinkInfos.clear(); + d->mAnnotationPositions.clear(); d->mAnnotationInfos.clear(); // do not use clear() for the following two, otherwise they change type d->mDocumentInfo = Okular::DocumentInfo();