本文整理汇总了C++中QThread::msleep方法的典型用法代码示例。如果您正苦于以下问题:C++ QThread::msleep方法的具体用法?C++ QThread::msleep怎么用?C++ QThread::msleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QThread
的用法示例。
在下文中一共展示了QThread::msleep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startServerManagerProcess
DatabaseServerError DatabaseServerStarter::startServerManagerProcess(const QString& dbType)
{
DatabaseServerError result;
/*
* TODO:
* 1. Acquire semaphore lock on "DigikamDBSrvAccess"
* 2. Check if there is an database server manager service already registered on DBus
* 3. If not, start the database server manager
* 4. Release semaphore lock
*/
QSystemSemaphore sem(QLatin1String("DigikamDBSrvAccess"), 1, QSystemSemaphore::Open);
sem.acquire();
if (!isServerRegistered())
{
const QString dbServerMgrPath = QString::fromUtf8(LIBEXEC_INSTALL_DIR) + QLatin1String("/digikamdatabaseserver");
if ( dbServerMgrPath.isEmpty() )
{
qCDebug(DIGIKAM_DBENGINE_LOG) << "No path to digikamdatabaseserver set in server manager configuration!";
}
const QStringList arguments;
bool result = QProcess::startDetached( dbServerMgrPath, arguments );
if ( !result )
{
qCDebug(DIGIKAM_DBENGINE_LOG) << "Could not start database server manager !";
qCDebug(DIGIKAM_DBENGINE_LOG) << "executable:" << dbServerMgrPath;
qCDebug(DIGIKAM_DBENGINE_LOG) << "arguments:" << arguments;
}
}
// wait until the server has successfully registered on DBUS
// TODO Use another way for that! Sleep isn't good :-/
for (int i = 0; i < 30; ++i)
{
if (!isServerRegistered())
{
QThread sleepThread;
sleepThread.msleep(250);
sleepThread.wait();
}
else
{
break;
}
}
QDBusInterface dbus_iface(QLatin1String("org.kde.digikam.DatabaseServer"), QLatin1String("/DatabaseServer"));
QDBusMessage stateMsg = dbus_iface.call(QLatin1String("isRunning"));
if (!stateMsg.arguments().at(0).toBool())
{
DatabaseServerError error;
QList<QVariant> arguments;
arguments.append(dbType);
QDBusMessage reply = dbus_iface.callWithArgumentList(QDBus::Block, QLatin1String("startDatabaseProcess"), arguments);
if (QDBusMessage::ErrorMessage == reply.type())
{
result.setErrorType(DatabaseServerError::StartError);
result.setErrorText(i18n("<p><b>Error while calling the database server starter.</b></p>"
"Details:\n %1", reply.errorMessage()));
}
else
{
arguments = reply.arguments();
QDBusVariant dbusVariant = qvariant_cast<QDBusVariant>(arguments.at(1));
// Retrieve the actual value stored in the D-Bus variant
QVariant dbusArgument = dbusVariant.variant();
DatabaseServerError item = qdbus_cast<DatabaseServerError>(dbusArgument);
result = item;
}
}
sem.release();
return result;
}