Use QtConcurrent::run() in ShellIntegration class instead of manually managing the thread. ShellIntegration is now completely static and must not be instantiated.

This commit is contained in:
LoRd_MuldeR 2011-07-15 13:44:32 +02:00
parent 54c6cae91b
commit c5606cf45a
3 changed files with 10 additions and 28 deletions

View File

@ -29,8 +29,8 @@
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 3
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 3
#define VER_LAMEXP_BUILD 602
#define VER_LAMEXP_PATCH 4
#define VER_LAMEXP_BUILD 603
///////////////////////////////////////////////////////////////////////////////
// Tools versions

View File

@ -28,6 +28,7 @@
#include <QFileInfo>
#include <QDir>
#include <QMutexLocker>
#include <QtConcurrentRun>
#include <Shlobj.h>
#include <Shlwapi.h>
@ -49,15 +50,9 @@ QMutex ShellIntegration::m_mutex;
// Constructor
////////////////////////////////////////////////////////////
ShellIntegration::ShellIntegration(bool install)
:
QThread(),
m_install(install)
{
}
ShellIntegration::~ShellIntegration(void)
ShellIntegration::ShellIntegration(void)
{
throw "Cannot create instance of this class, sorry!";
}
////////////////////////////////////////////////////////////
@ -69,9 +64,7 @@ void ShellIntegration::install(bool async)
//Install asynchronously
if(async)
{
ShellIntegration *shellIntegration = new ShellIntegration(true);
connect(shellIntegration, SIGNAL(finished()), shellIntegration, SLOT(deleteLater()));
shellIntegration->start();
QFuture<void>(QtConcurrent::run(install, false));
return;
}
@ -143,9 +136,7 @@ void ShellIntegration::remove(bool async)
//Remove asynchronously
if(async)
{
ShellIntegration *shellIntegration = new ShellIntegration(false);
connect(shellIntegration, SIGNAL(finished()), shellIntegration, SLOT(deleteLater()));
shellIntegration->start();
QFuture<void>(QtConcurrent::run(remove, false));
return;
}

View File

@ -21,13 +21,13 @@
#pragma once
#include <QThread>
#include <QObject>
#include <QMutex>
class QString;
class QStringList;
class ShellIntegration : public QThread
class ShellIntegration : public QObject
{
Q_OBJECT
@ -35,18 +35,9 @@ public:
static void install(bool async = true);
static void remove(bool async = true);
protected:
void run()
{
if(m_install) install(false); else remove(false);
}
private:
ShellIntegration(bool install = true);
~ShellIntegration(void);
ShellIntegration(void);
static QStringList *detectTypes(const QString &lamexpFileType, const QString &lamexpShellAction);
static QMutex m_mutex;
bool m_install;
};