From 2437917e47625228e86a2d32ba41d35c874c455d Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 4 Jul 2007 16:55:33 +0000 Subject: [PATCH] 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 --- CMakeLists.txt | 2 +- core/page.cpp | 6 ++---- core/pagecontroller.cpp | 13 +++++++++++-- core/pagecontroller_p.h | 9 ++++++++- core/rotationjob_p.h | 5 +++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1bfb77a8..7ebeb8ef6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ IF(APPLE) SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework") 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 ) diff --git a/core/page.cpp b/core/page.cpp index 0bce0d0a4..8369bf1c1 100644 --- a/core/page.cpp +++ b/core/page.cpp @@ -290,8 +290,7 @@ void PagePrivate::rotateAt( Rotation orientation ) RotationJob *job = new RotationJob( object.m_pixmap->toImage(), object.m_rotation, m_rotation, it.key() ); job->setPage( this ); - QObject::connect( job, SIGNAL( finished() ), PageController::self(), SLOT( imageRotationDone() ) ); - job->start(); + PageController::self()->addRotationJob(job); } /** @@ -374,8 +373,7 @@ void Page::setPixmap( int id, QPixmap *pixmap ) } else { RotationJob *job = new RotationJob( pixmap->toImage(), Rotation0, d->m_rotation, id ); job->setPage( d ); - QObject::connect( job, SIGNAL( finished() ), PageController::self(), SLOT( imageRotationDone() ) ); - job->start(); + PageController::self()->addRotationJob(job); delete pixmap; } diff --git a/core/pagecontroller.cpp b/core/pagecontroller.cpp index f14b4b026..c9af42b30 100644 --- a/core/pagecontroller.cpp +++ b/core/pagecontroller.cpp @@ -11,6 +11,7 @@ // qt/kde includes #include +#include // local includes #include "page_p.h" @@ -23,6 +24,9 @@ using namespace Okular; PageController::PageController() : QObject() { + connect( ThreadWeaver::Weaver::instance(), + SIGNAL( jobDone(ThreadWeaver::Job*) ), + SLOT( imageRotationDone(ThreadWeaver::Job*) ) ); } PageController::~PageController() @@ -34,9 +38,14 @@ PageController * PageController::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 ) return; diff --git a/core/pagecontroller_p.h b/core/pagecontroller_p.h index a379e263d..e5683568a 100644 --- a/core/pagecontroller_p.h +++ b/core/pagecontroller_p.h @@ -12,9 +12,14 @@ #include +namespace ThreadWeaver { + class Job; +} + namespace Okular { class Page; +class RotationJob; class PageController : public QObject { @@ -30,11 +35,13 @@ class PageController : public QObject static PageController * self(); + void addRotationJob( RotationJob *job ); + signals: void rotationFinished( int page ); private slots: - void imageRotationDone(); + void imageRotationDone(ThreadWeaver::Job*); }; } diff --git a/core/rotationjob_p.h b/core/rotationjob_p.h index 7051447de..6505427a9 100644 --- a/core/rotationjob_p.h +++ b/core/rotationjob_p.h @@ -10,16 +10,17 @@ #ifndef _OKULAR_ROTATIONJOB_H #define _OKULAR_ROTATIONJOB_H -#include #include +#include + #include "core/global.h" namespace Okular { class PagePrivate; -class RotationJob : public QThread +class RotationJob : public ThreadWeaver::Job { Q_OBJECT