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 @@
#include <QProcess> #include <QProcess>
#include <QSettings> #include <QSettings>
#include <QLocale> #include <QLocale>
#include <QThread>
#ifdef DISABLE_GUI #ifdef DISABLE_GUI
#include <QCoreApplication> #include <QCoreApplication>
@ -631,3 +632,18 @@ QString misc::accurateDoubleToString(const double &n, const int &precision, bool
else else
return QString::number(std::floor(n*prec)/prec, 'f', precision); 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 @@
#include <sstream> #include <sstream>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QThread>
#include <ctime> #include <ctime>
#include <QPoint> #include <QPoint>
#include <QFile> #include <QFile>
@ -106,15 +105,8 @@ namespace misc
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
bool naturalSort(QString left, QString right, bool& result); bool naturalSort(QString left, QString right, bool& result);
#endif #endif
}
// Trick to get a portable sleep() function void msleep(unsigned long msecs);
class SleeperThread : public QThread { }
public:
static void msleep(unsigned long msecs)
{
QThread::msleep(msecs);
}
};
#endif #endif

2
src/properties/propertieswidget.cpp

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

Loading…
Cancel
Save