forked from qt-creator/qt-creator
Utils: Introduce sleep function
Use it in Android plugin Change-Id: Id3ae707d5425e99a2e5b993e1ed98dddd73809a9 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
47
src/libs/utils/sleep.cpp
Normal file
47
src/libs/utils/sleep.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Orgad Shaneh <orgads@gmail.com>.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "sleep.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
void Utils::sleep(int msec)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
::Sleep(msec);
|
||||
#else
|
||||
struct timespec ts = { msec / 1000, (msec % 1000) * 1000000 };
|
||||
::nanosleep(&ts, NULL);
|
||||
#endif
|
||||
}
|
41
src/libs/utils/sleep.h
Normal file
41
src/libs/utils/sleep.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Orgad Shaneh <orgads@gmail.com>.
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SLEEP_H
|
||||
#define SLEEP_H
|
||||
|
||||
#include "utils_global.h"
|
||||
|
||||
namespace Utils {
|
||||
|
||||
void QTCREATOR_UTILS_EXPORT sleep(int msec);
|
||||
|
||||
}
|
||||
|
||||
#endif // SLEEP_H
|
@@ -73,6 +73,7 @@ SOURCES += $$PWD/environment.cpp \
|
||||
$$PWD/portlist.cpp \
|
||||
$$PWD/tcpportsgatherer.cpp \
|
||||
$$PWD/appmainwindow.cpp \
|
||||
$$PWD/sleep.cpp \
|
||||
$$PWD/basetreeview.cpp \
|
||||
$$PWD/qtcassert.cpp \
|
||||
$$PWD/elfreader.cpp \
|
||||
@@ -163,6 +164,7 @@ HEADERS += \
|
||||
$$PWD/portlist.h \
|
||||
$$PWD/tcpportsgatherer.h \
|
||||
$$PWD/appmainwindow.h \
|
||||
$$PWD/sleep.h \
|
||||
$$PWD/basetreeview.h \
|
||||
$$PWD/elfreader.h \
|
||||
$$PWD/bracematcher.h \
|
||||
|
@@ -151,6 +151,8 @@ QtcLibrary {
|
||||
"settingsselector.cpp",
|
||||
"settingsselector.h",
|
||||
"settingsutils.h",
|
||||
"sleep.cpp",
|
||||
"sleep.h",
|
||||
"statuslabel.cpp",
|
||||
"statuslabel.h",
|
||||
"stringutils.cpp",
|
||||
|
@@ -17,6 +17,7 @@ QtcPlugin {
|
||||
Depends { name: "QtSupport" }
|
||||
Depends { name: "TextEditor" }
|
||||
Depends { name: "AnalyzerBase" }
|
||||
Depends { name: "Utils" }
|
||||
Depends { name: "Qt"; submodules: ["widgets", "xml", "network"] }
|
||||
|
||||
property bool enable: false
|
||||
|
@@ -8,6 +8,9 @@ QTC_PLUGIN_DEPENDS += \
|
||||
texteditor \
|
||||
analyzerbase
|
||||
|
||||
QTC_LIB_DEPENDS += \
|
||||
utils
|
||||
|
||||
exists(../../shared/qbs/qbs.pro): \
|
||||
QTC_PLUGIN_DEPENDS += \
|
||||
qbsprojectmanager
|
||||
|
@@ -47,6 +47,7 @@
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/sleep.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
@@ -59,14 +60,6 @@
|
||||
#include <QStringListModel>
|
||||
#include <QMessageBox>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#define sleep(_n) Sleep(1000 * (_n))
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -618,11 +611,11 @@ QString AndroidConfigurations::waitForAvd(int apiLevel, const QString &cpuAbi) c
|
||||
if (hasFinishedBooting(serialNumber))
|
||||
return serialNumber;
|
||||
else
|
||||
sleep(8);
|
||||
Utils::sleep(8000);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
sleep(8);
|
||||
Utils::sleep(8000);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
Reference in New Issue
Block a user