Browse Source

Remove inclusion of <QThread> from misc.h

adaptive-webui-19844
Ivan Sorokin 10 years ago
parent
commit
5ea1a4c3cc
  1. 16
      src/misc.cpp
  2. 12
      src/misc.h
  3. 2
      src/properties/propertieswidget.cpp

16
src/misc.cpp

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
#include <QProcess>
#include <QSettings>
#include <QLocale>
#include <QThread>
#ifdef DISABLE_GUI
#include <QCoreApplication>
@ -631,3 +632,18 @@ QString misc::accurateDoubleToString(const double &n, const int &precision, bool @@ -631,3 +632,18 @@ QString misc::accurateDoubleToString(const double &n, const int &precision, bool
else
return QString::number(std::floor(n*prec)/prec, 'f', precision);
}
namespace {
// Trick to get a portable sleep() function
class SleeperThread : public QThread {
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};
}
void misc::msleep(unsigned long msecs) {
SleeperThread::msleep(msecs);
}

12
src/misc.h

@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
#include <sstream>
#include <QString>
#include <QStringList>
#include <QThread>
#include <ctime>
#include <QPoint>
#include <QFile>
@ -106,15 +105,8 @@ namespace misc @@ -106,15 +105,8 @@ namespace misc
#ifndef DISABLE_GUI
bool naturalSort(QString left, QString right, bool& result);
#endif
}
// Trick to get a portable sleep() function
class SleeperThread : public QThread {
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};
void msleep(unsigned long msecs);
}
#endif

2
src/properties/propertieswidget.cpp

@ -666,7 +666,7 @@ void PropertiesWidget::renameSelectedFile() { @@ -666,7 +666,7 @@ void PropertiesWidget::renameSelectedFile() {
int timeout = 10;
while(!QDir().rmpath(old_folder.absolutePath()) && timeout > 0) {
// XXX: We should not sleep here (freezes the UI for 1 second)
SleeperThread::msleep(100);
misc::msleep(100);
--timeout;
}
}

Loading…
Cancel
Save