优化线程退出时资源的释放问题

This commit is contained in:
2024-09-12 15:18:09 +08:00
parent 843b2058c3
commit 9d506e1cfc
314 changed files with 2448 additions and 529454 deletions

View File

@@ -288,7 +288,7 @@ void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray a
{
isStartVideo = false;
emit statusUpdated(client, true, jsonArray, itemJsonIndex);
qDebug() << "--- STOP_VIDEO Current path: " << QDir::currentPath();
/*qDebug() << "--- STOP_VIDEO Current path: " << QDir::currentPath();
QString filePath = QDir::currentPath() + "/add1.h264";
if (QFile::exists(filePath)) {
QFile file(filePath);
@@ -301,7 +301,7 @@ void DataHandler::handleFrontCmd(int msg_id, const QString& client, QByteArray a
}
else {
qDebug() << "File add1.h264 does not exist.";
}
}*/
}
break;
case TOUCH_TEST:
@@ -494,26 +494,28 @@ void DataHandler::handleBackCmd(int msg_id, const QString& client, QByteArray ac
isStartVideo = false;
emit statusUpdated(client, true, jsonArray, itemJsonIndex);
qDebug() << "--- STOP_VIDEO";
qDebug() << "Current path: " << QDir::currentPath();
QString filePath = QDir::currentPath() + "/add1.h264";
if (QFile::exists(filePath)) {
QFile file(filePath);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
qDebug() << "File add1.h264 cleared successfully.";
}
else {
qDebug() << "Failed to clear file add1.h264:" << file.errorString();
}
}
else {
qDebug() << "File add1.h264 does not exist.";
}
if (ffmpegDecoder) {
start_run = 0;
ffmpegDecoder->stopFFmpegDecoder();
ffmpegDecoder->requestInterruption();
ffmpegDecoder->wait(); // 等待解码器线程完成
delete ffmpegDecoder;
ffmpegDecoder = nullptr;
qDebug() << "Current path: " << QDir::currentPath();
QString filePath = QDir::currentPath() + "/add1.h264";
if (QFile::exists(filePath)) {
QFile file(filePath);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
qDebug() << "File add1.h264 cleared successfully.";
}
else {
qDebug() << "Failed to clear file add1.h264:" << file.errorString();
}
}
else {
qDebug() << "File add1.h264 does not exist.";
}
}
}
}