使用此代码:
bool initQdbgLog()
{
deleteOldLogs(); //delete old log files
initLogFileName(); //create the logfile name
QFile outFile (logFileName);
if (outFile.open (QIODevice::WriteOnly | QIODevice::Append)) { <<<<<<<<<<<<<(1)
qInstallMsgHandler (QDBGLOG::myMessageHandler);
return true; <<<<<<<<<<<<<(2)
} else {
return false;
}
}
Klocwork 表示资源泄漏:
Resource acquired to '@temp_3' at line <<<(1) may be lost here <<<(2)
有人知道为什么吗?
@Sivanesh Waran您好,感谢您的帮助,但我尝试了不同的代码并且总是得到相同的错误,即使使用该代码:
void initQdbgLog()
{
deleteOldLogs(); //delete old log files
initLogFileName(); //create the logfile name
QFile outFile (logFileName);
bool result = outFile.open (QIODevice::WriteOnly | QIODevice::Append);
if (result) {
qInstallMsgHandler (QDBGLOG::myMessageHandler);
outFile.close();
}
}