[Pkg-owncloud-commits] [owncloud-client] 50/89: usleep is not working on windows, use QThread::usleep
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Dec 14 01:02:35 UTC 2013
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 0360babe02db6408aba24863a82aaa173a352920
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Dec 10 13:47:44 2013 +0100
usleep is not working on windows, use QThread::usleep
Shoud fix #1082
---
src/mirall/owncloudpropagator.cpp | 9 +++++----
src/mirall/utility.cpp | 21 ++++++++++++++++-----
src/mirall/utility.h | 1 +
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/src/mirall/owncloudpropagator.cpp b/src/mirall/owncloudpropagator.cpp
index 974329f..1d3aa3a 100644
--- a/src/mirall/owncloudpropagator.cpp
+++ b/src/mirall/owncloudpropagator.cpp
@@ -16,6 +16,7 @@
#include "owncloudpropagator.h"
#include "syncjournaldb.h"
#include "syncjournalfilerecord.h"
+#include "utility.h"
#include <httpbf.h>
#include <qfile.h>
#include <qdir.h>
@@ -39,8 +40,6 @@
#include <neon/ne_compress.h>
#include <neon/ne_redirect.h>
-#include <time.h>
-
#ifdef Q_OS_WIN
#include <windef.h>
#include <winbase.h>
@@ -517,7 +516,8 @@ void PropagateItemJob::limitBandwidth(qint64 progress, qint64 bandwidth_limit)
if (len > 0 && diff > 0 && (1000000 * len / diff) > bandwidth_limit) {
int64_t wait_time = (1000000 * len / bandwidth_limit) - diff;
if (wait_time > 0) {
- usleep(wait_time);
+ //qDebug() << "Limiting bandwidth to " << bandwidth_limit << "KB/s by waiting " << wait_time << " µs; ";
+ Mirall::Utility::usleep(wait_time);
}
}
_lastProgress = progress;
@@ -528,7 +528,8 @@ void PropagateItemJob::limitBandwidth(qint64 progress, qint64 bandwidth_limit)
// -bandwidth_limit is the % of bandwidth
int64_t wait_time = -diff * (1 + 100.0 / bandwidth_limit);
if (wait_time > 0) {
- usleep(wait_time);
+ Mirall::Utility::usleep(wait_time);
+
}
}
_lastTime.start();
diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp
index d22ab13..9365dc4 100644
--- a/src/mirall/utility.cpp
+++ b/src/mirall/utility.cpp
@@ -26,6 +26,7 @@
#include <QDebug>
#include <QDesktopServices>
#include <QProcess>
+#include <QThread>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <QDesktopServices>
@@ -234,13 +235,23 @@ QString Utility::dataLocation()
#endif
}
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+// In Qt 4, QThread::sleep functions are protected.
+// This is a hack to make them visible in this namespace.
+struct QThread : ::QThread {
+ using ::QThread::sleep;
+ using ::QThread::usleep;
+};
+#endif
+
void Utility::sleep(int sec)
{
-#ifdef Q_OS_WIN
- ::Sleep(sec*1000);
-#else
- ::sleep(sec);
-#endif
+ QThread::sleep(sec);
+}
+
+void Utility::usleep(int usec)
+{
+ QThread::usleep(usec);
}
// ### helper functions for showInFileManager() ###
diff --git a/src/mirall/utility.h b/src/mirall/utility.h
index a6779a5..b52cd6a 100644
--- a/src/mirall/utility.h
+++ b/src/mirall/utility.h
@@ -25,6 +25,7 @@ namespace Mirall {
namespace Utility
{
void sleep(int sec);
+ void usleep(int usec);
QString formatFingerprint( const QByteArray& );
void setupFavLink( const QString &folder );
QString octetsToString( qint64 octets );
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list