mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
okular: use QThread instead of ThreadWeaver for image rotation jobs
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
572f9eaa88
commit
22fd0cca5f
7 changed files with 16 additions and 23 deletions
|
@ -111,7 +111,6 @@ target_link_libraries(okularcore
|
|||
${KDE4_KIO_LIBS}
|
||||
${KDE4_PHONON_LIBRARY}
|
||||
${MATH_LIB}
|
||||
${KDE4_THREADWEAVER_LIBRARY}
|
||||
KDE4::kmediaplayer
|
||||
kscreen
|
||||
)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
// qt/kde includes
|
||||
#include <kglobal.h>
|
||||
#include <threadweaver/ThreadWeaver.h>
|
||||
|
||||
// local includes
|
||||
#include "page_p.h"
|
||||
|
@ -30,12 +29,12 @@ PageController::~PageController()
|
|||
|
||||
void PageController::addRotationJob(RotationJob *job)
|
||||
{
|
||||
connect( job, SIGNAL(done(ThreadWeaver::Job*)),
|
||||
this, SLOT(imageRotationDone(ThreadWeaver::Job*)) );
|
||||
ThreadWeaver::Weaver::instance()->enqueue(job);
|
||||
connect( job, SIGNAL(done(QThread*)),
|
||||
this, SLOT(imageRotationDone(QThread*)) );
|
||||
job->start();
|
||||
}
|
||||
|
||||
void PageController::imageRotationDone(ThreadWeaver::Job *j)
|
||||
void PageController::imageRotationDone(QThread *j)
|
||||
{
|
||||
RotationJob *job = static_cast< RotationJob * >( j );
|
||||
|
||||
|
|
|
@ -10,11 +10,7 @@
|
|||
#ifndef _OKULAR_PAGECONTROLLER_P_H_
|
||||
#define _OKULAR_PAGECONTROLLER_P_H_
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
namespace ThreadWeaver {
|
||||
class Job;
|
||||
}
|
||||
#include <QtCore/QThread>
|
||||
|
||||
namespace Okular {
|
||||
|
||||
|
@ -37,7 +33,7 @@ class PageController : public QObject
|
|||
void rotationFinished( int page, Okular::Page *okularPage );
|
||||
|
||||
private slots:
|
||||
void imageRotationDone(ThreadWeaver::Job*);
|
||||
void imageRotationDone(QThread*);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,8 @@ void RotationJob::run()
|
|||
QTransform matrix = rotationMatrix( mOldRotation, mNewRotation );
|
||||
|
||||
mRotatedImage = mImage.transformed( matrix );
|
||||
|
||||
emit done(this);
|
||||
}
|
||||
|
||||
QTransform RotationJob::rotationMatrix( Rotation from, Rotation to )
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
#ifndef _OKULAR_ROTATIONJOB_P_H_
|
||||
#define _OKULAR_ROTATIONJOB_P_H_
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QTransform>
|
||||
|
||||
#include <threadweaver/Job.h>
|
||||
|
||||
#include "core/global.h"
|
||||
#include "core/area.h"
|
||||
|
||||
|
@ -23,7 +22,7 @@ namespace Okular {
|
|||
class DocumentObserver;
|
||||
class PagePrivate;
|
||||
|
||||
class RotationJob : public ThreadWeaver::Job
|
||||
class RotationJob : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -41,6 +40,9 @@ class RotationJob : public ThreadWeaver::Job
|
|||
|
||||
static QTransform rotationMatrix( Rotation from, Rotation to );
|
||||
|
||||
Q_SIGNALS:
|
||||
void done(QThread*);
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ kde4_add_test(okular-parttest parttest.cpp )
|
|||
target_link_libraries(okular-parttest ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularpart okularcore )
|
||||
|
||||
kde4_add_test(okular-documenttest documenttest.cpp )
|
||||
target_link_libraries(okular-documenttest ${KDE4_KDECORE_LIBS} ${KDE4_THREADWEAVER_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
|
||||
target_link_libraries(okular-documenttest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
|
||||
|
||||
kde4_add_test(okular-searchtest searchtest.cpp )
|
||||
target_link_libraries(okular-searchtest ${KDE4_KDECORE_LIBS} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY} okularcore )
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <qtest_kde.h>
|
||||
|
||||
#include <threadweaver/ThreadWeaver.h>
|
||||
#include <QLinkedList>
|
||||
|
||||
#include "../core/document.h"
|
||||
#include "../core/generator.h"
|
||||
|
@ -41,9 +41,6 @@ void DocumentTest::testCloseDuringRotationJob()
|
|||
m_document->openDocument( testFile, KUrl(), mime );
|
||||
m_document->setRotation( 1 );
|
||||
|
||||
// Tell ThreadWeaver not to start any new job
|
||||
ThreadWeaver::Weaver::instance()->suspend();
|
||||
|
||||
// Request a pixmap. A RotationJob will be enqueued but not started
|
||||
Okular::PixmapRequest *pixmapReq = new Okular::PixmapRequest(
|
||||
dummyDocumentObserver, 0, 100, 100, 1, Okular::PixmapRequest::NoFeature );
|
||||
|
@ -52,9 +49,7 @@ void DocumentTest::testCloseDuringRotationJob()
|
|||
// Delete the document
|
||||
delete m_document;
|
||||
|
||||
// Resume job processing and wait for the RotationJob to finish
|
||||
ThreadWeaver::Weaver::instance()->resume();
|
||||
ThreadWeaver::Weaver::instance()->finish();
|
||||
// Wait for the RotationJob to finish
|
||||
qApp->processEvents();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue