mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-27 19:50:27 +00:00
Remove the EventLoop hack which causes crashes when you close the
application during loading svn path=/trunk/KDE/kdegraphics/okular/; revision=706608
This commit is contained in:
parent
ae2247f207
commit
f764604bb6
|
@ -15,7 +15,7 @@
|
|||
#include <ktempdir.h>
|
||||
|
||||
Unrar::Unrar()
|
||||
: QObject( 0 ), mTempDir( 0 ), mErrorOccured( false )
|
||||
: QObject( 0 ), mTempDir( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -41,22 +41,14 @@ bool Unrar::open( const QString &fileName )
|
|||
|
||||
connect( mProcess, SIGNAL( readyReadStandardOutput() ), SLOT( readFromStdout() ) );
|
||||
connect( mProcess, SIGNAL( readyReadStandardError() ), SLOT( readFromStderr() ) );
|
||||
connect( mProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( processExited() ) );
|
||||
connect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), SLOT( processExited() ) );
|
||||
|
||||
mProcess->start( "unrar", QStringList() << "e" << mFileName << mTempDir->name(), QIODevice::ReadOnly );
|
||||
|
||||
mEventLoop.exec();
|
||||
bool ok = mProcess->waitForFinished( -1 );
|
||||
|
||||
delete mProcess;
|
||||
mProcess = 0;
|
||||
|
||||
if ( mErrorOccured ) {
|
||||
mErrorOccured = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
QStringList Unrar::list()
|
||||
|
@ -68,12 +60,9 @@ QStringList Unrar::list()
|
|||
|
||||
connect( mProcess, SIGNAL( readyReadStandardOutput() ), SLOT( readFromStdout() ) );
|
||||
connect( mProcess, SIGNAL( readyReadStandardError() ), SLOT( readFromStderr() ) );
|
||||
connect( mProcess, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( processExited() ) );
|
||||
connect( mProcess, SIGNAL( error( QProcess::ProcessError ) ), SLOT( processError() ) );
|
||||
|
||||
mProcess->start( "unrar", QStringList() << "lb" << mFileName, QIODevice::ReadOnly );
|
||||
|
||||
mEventLoop.exec();
|
||||
mProcess->waitForFinished( -1 );
|
||||
|
||||
delete mProcess;
|
||||
mProcess = 0;
|
||||
|
@ -100,14 +89,4 @@ void Unrar::readFromStderr()
|
|||
mStdErrData += mProcess->readAllStandardError();
|
||||
}
|
||||
|
||||
void Unrar::processExited()
|
||||
{
|
||||
mEventLoop.exit();
|
||||
}
|
||||
|
||||
void Unrar::processError()
|
||||
{
|
||||
mErrorOccured = true;
|
||||
}
|
||||
|
||||
#include "unrar.moc"
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#ifndef UNRAR_H
|
||||
#define UNRAR_H
|
||||
|
||||
#include <QtCore/QEventLoop>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
|
@ -48,19 +47,15 @@ class Unrar : public QObject
|
|||
QByteArray contentOf( const QString &fileName ) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void processExited();
|
||||
void processError();
|
||||
void readFromStdout();
|
||||
void readFromStderr();
|
||||
|
||||
private:
|
||||
QProcess *mProcess;
|
||||
QEventLoop mEventLoop;
|
||||
QString mFileName;
|
||||
QByteArray mStdOutData;
|
||||
QByteArray mStdErrData;
|
||||
KTempDir *mTempDir;
|
||||
bool mErrorOccured;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue