From c5606cf45aadeb6f244638d8f13d86a49120f687 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Fri, 15 Jul 2011 13:44:32 +0200 Subject: [PATCH] Use QtConcurrent::run() in ShellIntegration class instead of manually managing the thread. ShellIntegration is now completely static and must not be instantiated. --- src/Config.h | 4 ++-- src/ShellIntegration.cpp | 19 +++++-------------- src/ShellIntegration.h | 15 +++------------ 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/Config.h b/src/Config.h index 758d38af..2d594808 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 diff --git a/src/ShellIntegration.cpp b/src/ShellIntegration.cpp index 56dfdc22..dfdfca71 100644 --- a/src/ShellIntegration.cpp +++ b/src/ShellIntegration.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -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(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(QtConcurrent::run(remove, false)); return; } diff --git a/src/ShellIntegration.h b/src/ShellIntegration.h index 79464063..a828bd94 100644 --- a/src/ShellIntegration.h +++ b/src/ShellIntegration.h @@ -21,13 +21,13 @@ #pragma once -#include +#include #include 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; };