Add a close() method for the comicbook document so:

- resources can be freed when closing the Okular document for real (and not just when opening a new comicbook document or quitting)
- we do not crash when doing an opening sequence like: cbz -> cbr -> cbz

svn path=/trunk/KDE/kdegraphics/okular/; revision=798868
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent 2634a4b8d4
commit f697cdf007
  1. 18
      generators/comicbook/document.cpp
  2. 1
      generators/comicbook/document.h
  3. 2
      generators/comicbook/generator_comicbook.cpp

@ -25,15 +25,11 @@ Document::Document()
Document::~Document()
{
delete mUnrar;
delete mZip;
}
bool Document::open( const QString &fileName )
{
delete mZip;
delete mUnrar;
mPageMap.clear();
close();
/**
* We have a zip archive
@ -93,6 +89,18 @@ bool Document::open( const QString &fileName )
return true;
}
void Document::close()
{
if ( !( mZip || mUnrar ) )
return;
delete mZip;
mZip = 0;
delete mUnrar;
mUnrar = 0;
mPageMap.clear();
}
void Document::extractImageFiles( const QStringList &list )
{
QStringList files( list );

@ -26,6 +26,7 @@ class Document
~Document();
bool open( const QString &fileName );
void close();
int pages() const;
QStringList pageTitles() const;

@ -76,6 +76,8 @@ bool ComicBookGenerator::loadDocument( const QString & fileName, QVector<Okular:
bool ComicBookGenerator::doCloseDocument()
{
mDocument.close();
return true;
}

Loading…
Cancel
Save