本文整理汇总了C++中QCoreApplication::applicationPid方法的典型用法代码示例。如果您正苦于以下问题:C++ QCoreApplication::applicationPid方法的具体用法?C++ QCoreApplication::applicationPid怎么用?C++ QCoreApplication::applicationPid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCoreApplication
的用法示例。
在下文中一共展示了QCoreApplication::applicationPid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPid
/*!
* @brief Gets crash-reporter-daemon pid and saves it to file.
*
* @param app Reference to application.
* @return True, if first startup; otherwise false.
*/
bool getPid(QCoreApplication &app)
{
QFile pidFile(CREPORTER_PID_FILE);
qint64 pid = 0;
bool firstStartup = true;
// Get new PID.
pid = app.applicationPid();
qDebug() << __PRETTY_FUNCTION__ << CReporter::DaemonBinaryName
<< "[" << pid << "] starting...";
if (pidFile.exists()) {
firstStartup = false;
qDebug() << __PRETTY_FUNCTION__ << "Removing stale PID file.";
pidFile.remove();
}
if (pidFile.open(QIODevice::WriteOnly)) {
QTextStream out(&pidFile);
out << pid;
pidFile.close();
}
qDebug() << __PRETTY_FUNCTION__ << "Startup delayed =" << firstStartup;
return firstStartup;
}
示例2: locker
void Soprano::Error::ErrorCache::setError( const Error& error ) const
{
if ( error ) {
QCoreApplication* app = QCoreApplication::instance();
qDebug() << ( app
? QString( "%1(%2)" ).arg( app->applicationFilePath() ).arg( app->applicationPid() )
: QString() )
<< "Soprano:" << error;
QMutexLocker locker( &d->errorMapMutex );
d->errorMap[QThread::currentThread()] = error;
}
else {
clearError();
}
}