on demand creation of the auxiliary threads

svn path=/trunk/KDE/kdegraphics/okular/; revision=656230
remotes/origin/KDE/4.0
Pino Toscano 19 years ago
parent 9134ad4669
commit fc97f3b23b
  1. 21
      core/generator.cpp
  2. 4
      core/generator_p.h

@ -46,26 +46,30 @@ GeneratorPrivate::~GeneratorPrivate()
delete m_about; delete m_about;
} }
void GeneratorPrivate::createPixmapGenerationThread() PixmapGenerationThread* GeneratorPrivate::pixmapGenerationThread()
{ {
if ( mPixmapGenerationThread ) if ( mPixmapGenerationThread )
return; return mPixmapGenerationThread;
mPixmapGenerationThread = new PixmapGenerationThread( m_generator ); mPixmapGenerationThread = new PixmapGenerationThread( m_generator );
QObject::connect( mPixmapGenerationThread, SIGNAL( finished() ), QObject::connect( mPixmapGenerationThread, SIGNAL( finished() ),
m_generator, SLOT( pixmapGenerationFinished() ), m_generator, SLOT( pixmapGenerationFinished() ),
Qt::QueuedConnection ); Qt::QueuedConnection );
return mPixmapGenerationThread;
} }
void GeneratorPrivate::createTextPageGenerationThread() TextPageGenerationThread* GeneratorPrivate::textPageGenerationThread()
{ {
if ( mTextPageGenerationThread ) if ( mTextPageGenerationThread )
return; return mTextPageGenerationThread;
mTextPageGenerationThread = new TextPageGenerationThread( m_generator ); mTextPageGenerationThread = new TextPageGenerationThread( m_generator );
QObject::connect( mTextPageGenerationThread, SIGNAL( finished() ), QObject::connect( mTextPageGenerationThread, SIGNAL( finished() ),
m_generator, SLOT( textpageGenerationFinished() ), m_generator, SLOT( textpageGenerationFinished() ),
Qt::QueuedConnection ); Qt::QueuedConnection );
return mTextPageGenerationThread;
} }
void GeneratorPrivate::pixmapGenerationFinished() void GeneratorPrivate::pixmapGenerationFinished()
@ -118,8 +122,7 @@ void Generator::generatePixmap( PixmapRequest *request )
if ( hasFeature( Threaded ) ) if ( hasFeature( Threaded ) )
{ {
d->createPixmapGenerationThread(); d->pixmapGenerationThread()->startGeneration( request );
d->mPixmapGenerationThread->startGeneration( request );
/** /**
* We create the text page for every page that is visible to the * 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() ) { if ( hasFeature( TextExtraction ) && !request->page()->hasTextPage() && canGenerateTextPage() ) {
d->mTextPageReady = false; d->mTextPageReady = false;
d->createTextPageGenerationThread(); d->textPageGenerationThread()->startGeneration( request->page() );
d->mTextPageGenerationThread->startGeneration( request->page() );
} }
return; return;
@ -153,8 +155,7 @@ void Generator::generateTextPage( Page *page, enum GenerationType type )
if ( type == Asynchronous ) { if ( type == Asynchronous ) {
if ( hasFeature( Threaded ) ) if ( hasFeature( Threaded ) )
{ {
d->createTextPageGenerationThread(); d->textPageGenerationThread()->startGeneration( page );
d->mTextPageGenerationThread->startGeneration( page );
return; return;
} }
} }

@ -34,8 +34,8 @@ class GeneratorPrivate
~GeneratorPrivate(); ~GeneratorPrivate();
void createPixmapGenerationThread(); PixmapGenerationThread* pixmapGenerationThread();
void createTextPageGenerationThread(); TextPageGenerationThread* textPageGenerationThread();
void pixmapGenerationFinished(); void pixmapGenerationFinished();
void textpageGenerationFinished(); void textpageGenerationFinished();

Loading…
Cancel
Save