From fc97f3b23bed5fa559cc64e20f5b30c044a92137 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 20 Apr 2007 17:59:12 +0000 Subject: [PATCH] on demand creation of the auxiliary threads svn path=/trunk/KDE/kdegraphics/okular/; revision=656230 --- core/generator.cpp | 21 +++++++++++---------- core/generator_p.h | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/generator.cpp b/core/generator.cpp index b0c20784b..3cb98dd34 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -46,26 +46,30 @@ GeneratorPrivate::~GeneratorPrivate() delete m_about; } -void GeneratorPrivate::createPixmapGenerationThread() +PixmapGenerationThread* GeneratorPrivate::pixmapGenerationThread() { if ( mPixmapGenerationThread ) - return; + return mPixmapGenerationThread; mPixmapGenerationThread = new PixmapGenerationThread( m_generator ); QObject::connect( mPixmapGenerationThread, SIGNAL( finished() ), m_generator, SLOT( pixmapGenerationFinished() ), Qt::QueuedConnection ); + + return mPixmapGenerationThread; } -void GeneratorPrivate::createTextPageGenerationThread() +TextPageGenerationThread* GeneratorPrivate::textPageGenerationThread() { if ( mTextPageGenerationThread ) - return; + return mTextPageGenerationThread; mTextPageGenerationThread = new TextPageGenerationThread( m_generator ); QObject::connect( mTextPageGenerationThread, SIGNAL( finished() ), m_generator, SLOT( textpageGenerationFinished() ), Qt::QueuedConnection ); + + return mTextPageGenerationThread; } void GeneratorPrivate::pixmapGenerationFinished() @@ -118,8 +122,7 @@ void Generator::generatePixmap( PixmapRequest *request ) if ( hasFeature( Threaded ) ) { - d->createPixmapGenerationThread(); - d->mPixmapGenerationThread->startGeneration( request ); + d->pixmapGenerationThread()->startGeneration( request ); /** * We create the text page for every page that is visible to the @@ -127,8 +130,7 @@ void Generator::generatePixmap( PixmapRequest *request ) */ if ( hasFeature( TextExtraction ) && !request->page()->hasTextPage() && canGenerateTextPage() ) { d->mTextPageReady = false; - d->createTextPageGenerationThread(); - d->mTextPageGenerationThread->startGeneration( request->page() ); + d->textPageGenerationThread()->startGeneration( request->page() ); } return; @@ -153,8 +155,7 @@ void Generator::generateTextPage( Page *page, enum GenerationType type ) if ( type == Asynchronous ) { if ( hasFeature( Threaded ) ) { - d->createTextPageGenerationThread(); - d->mTextPageGenerationThread->startGeneration( page ); + d->textPageGenerationThread()->startGeneration( page ); return; } } diff --git a/core/generator_p.h b/core/generator_p.h index e2282feb9..321c18e71 100644 --- a/core/generator_p.h +++ b/core/generator_p.h @@ -34,8 +34,8 @@ class GeneratorPrivate ~GeneratorPrivate(); - void createPixmapGenerationThread(); - void createTextPageGenerationThread(); + PixmapGenerationThread* pixmapGenerationThread(); + TextPageGenerationThread* textPageGenerationThread(); void pixmapGenerationFinished(); void textpageGenerationFinished();