Don't leak memory

svn path=/trunk/playground/graphics/okular/; revision=622789
This commit is contained in:
Leandro Emanuel López 2007-01-13 00:18:44 +00:00
parent 26f4618ae3
commit 21c42d89c7
2 changed files with 10 additions and 3 deletions

View file

@ -82,7 +82,7 @@ K_EXPORT_COMPONENT_FACTORY(libokularpart, okularPartFactory)
Part::Part(QWidget *parentWidget,
QObject *parent,
const QStringList & /*args*/ )
: KParts::ReadOnlyPart(parent),
: KParts::ReadOnlyPart(parent),
m_showMenuBarAction(0), m_showFullScreenAction(0), m_actionsSearched(false),
m_searchStarted(false), m_cliPresentation(false)
{
@ -92,7 +92,9 @@ Part::Part(QWidget *parentWidget,
connect(this, SIGNAL(started(KIO::Job *)), this, SLOT(setMimeTypes(KIO::Job *)));
// load catalog for translation
KGlobal::locale()->insertCatalog("okular");
m_tempfile= 0L;
// create browser extension (for printing when embedded into browser)
m_bExtension = new BrowserExtension(this);
@ -419,6 +421,9 @@ Part::~Part()
QHash<QString, Okular::Generator*>::iterator it = m_loadedGenerators.begin(), itEnd = m_loadedGenerators.end();
for ( ; it != itEnd; ++it )
delete *it;
if (m_tempfile)
delete m_tempfile;
}
bool Part::openDocument(const KUrl& url, uint page)
@ -1397,7 +1402,7 @@ bool Part::handleCompressed(KUrl & url, const QString &path, const KMimeType::Pt
// we are working with a compressed file, decompressing
// temporary file for decompressing
KTemporaryFile *m_tempfile = new KTemporaryFile;
m_tempfile = new KTemporaryFile;
if ( !m_tempfile )
{
KMessageBox::error( 0,

2
part.h
View file

@ -40,6 +40,7 @@ class KToggleFullScreenAction;
class KSelectAction;
class KAboutData;
class KPrinter;
class KTemporaryFile;
class ThumbnailList;
class ThumbnailController;
@ -155,6 +156,7 @@ private:
void doPrint( KPrinter& printer );
void fillGenerators();
bool handleCompressed(KUrl & url, const QString &path, const KMimeType::Ptr mimetype);
KTemporaryFile *m_tempfile;
// the document
Okular::Document * m_document;