Do not start numberOfPagesWithPixmaps threads because that brings the system down, just start what threadweaver thinks its best

Probably still have to tell the weaver how to optimize for memory consumption but it's an improvement anyways

svn path=/trunk/KDE/kdegraphics/okular/; revision=683383
This commit is contained in:
Albert Astals Cid 2007-07-04 16:55:33 +00:00
parent 80d7b04b0f
commit 2437917e47
5 changed files with 25 additions and 10 deletions

View file

@ -85,7 +85,7 @@ IF(APPLE)
SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework") SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
ENDIF(APPLE) ENDIF(APPLE)
target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_KDEPRINT_LIBRARY} ${KDE4_PHONON_LIBRARY} ${MATH_LIB}) target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_KDEPRINT_LIBRARY} ${KDE4_PHONON_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
set_target_properties(okularcore PROPERTIES VERSION 1.0.0 SOVERSION 1 ) set_target_properties(okularcore PROPERTIES VERSION 1.0.0 SOVERSION 1 )

View file

@ -290,8 +290,7 @@ void PagePrivate::rotateAt( Rotation orientation )
RotationJob *job = new RotationJob( object.m_pixmap->toImage(), object.m_rotation, m_rotation, it.key() ); RotationJob *job = new RotationJob( object.m_pixmap->toImage(), object.m_rotation, m_rotation, it.key() );
job->setPage( this ); job->setPage( this );
QObject::connect( job, SIGNAL( finished() ), PageController::self(), SLOT( imageRotationDone() ) ); PageController::self()->addRotationJob(job);
job->start();
} }
/** /**
@ -374,8 +373,7 @@ void Page::setPixmap( int id, QPixmap *pixmap )
} else { } else {
RotationJob *job = new RotationJob( pixmap->toImage(), Rotation0, d->m_rotation, id ); RotationJob *job = new RotationJob( pixmap->toImage(), Rotation0, d->m_rotation, id );
job->setPage( d ); job->setPage( d );
QObject::connect( job, SIGNAL( finished() ), PageController::self(), SLOT( imageRotationDone() ) ); PageController::self()->addRotationJob(job);
job->start();
delete pixmap; delete pixmap;
} }

View file

@ -11,6 +11,7 @@
// qt/kde includes // qt/kde includes
#include <kglobal.h> #include <kglobal.h>
#include <threadweaver/ThreadWeaver.h>
// local includes // local includes
#include "page_p.h" #include "page_p.h"
@ -23,6 +24,9 @@ using namespace Okular;
PageController::PageController() PageController::PageController()
: QObject() : QObject()
{ {
connect( ThreadWeaver::Weaver::instance(),
SIGNAL( jobDone(ThreadWeaver::Job*) ),
SLOT( imageRotationDone(ThreadWeaver::Job*) ) );
} }
PageController::~PageController() PageController::~PageController()
@ -34,9 +38,14 @@ PageController * PageController::self()
return page_controller_self; return page_controller_self;
} }
void PageController::imageRotationDone() void PageController::addRotationJob(RotationJob *job)
{ {
RotationJob *job = sender() ? qobject_cast< RotationJob * >( sender() ) : 0; ThreadWeaver::Weaver::instance()->enqueue(job);
}
void PageController::imageRotationDone(ThreadWeaver::Job *j)
{
RotationJob *job = qobject_cast< RotationJob * >(j);
if ( !job ) if ( !job )
return; return;

View file

@ -12,9 +12,14 @@
#include <QtCore/QObject> #include <QtCore/QObject>
namespace ThreadWeaver {
class Job;
}
namespace Okular { namespace Okular {
class Page; class Page;
class RotationJob;
class PageController : public QObject class PageController : public QObject
{ {
@ -30,11 +35,13 @@ class PageController : public QObject
static PageController * self(); static PageController * self();
void addRotationJob( RotationJob *job );
signals: signals:
void rotationFinished( int page ); void rotationFinished( int page );
private slots: private slots:
void imageRotationDone(); void imageRotationDone(ThreadWeaver::Job*);
}; };
} }

View file

@ -10,16 +10,17 @@
#ifndef _OKULAR_ROTATIONJOB_H #ifndef _OKULAR_ROTATIONJOB_H
#define _OKULAR_ROTATIONJOB_H #define _OKULAR_ROTATIONJOB_H
#include <QtCore/QThread>
#include <QtGui/QImage> #include <QtGui/QImage>
#include <threadweaver/Job.h>
#include "core/global.h" #include "core/global.h"
namespace Okular { namespace Okular {
class PagePrivate; class PagePrivate;
class RotationJob : public QThread class RotationJob : public ThreadWeaver::Job
{ {
Q_OBJECT Q_OBJECT