From bc461fbe5424708befee17cd9e37bfd13979bf1c Mon Sep 17 00:00:00 2001 From: houchengqiu Date: Wed, 18 Sep 2024 17:25:44 +0800 Subject: [PATCH] fix: Resolve the issue of not being able to repeatedly open ddf files Resolve the issue of not being able to repeatedly open ddf files Log: Resolve the issue of not being able to repeatedly open ddf files Bug: https://pms.uniontech.com/bug-view-270887.html --- src/frame/cviewmanagement.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/frame/cviewmanagement.cpp b/src/frame/cviewmanagement.cpp index 72972ce08..eec84a64c 100644 --- a/src/frame/cviewmanagement.cpp +++ b/src/frame/cviewmanagement.cpp @@ -299,10 +299,16 @@ void CFileWatcher::doRun() if (!isVaild()) return; + bool appQuit = false; + QObject::connect(qApp, &QApplication::aboutToQuit, [&,this](){ + appQuit = true; + clear(); + }); + char name[1024]; auto freadsome = [ = ](void *dest, size_t remain, FILE * file) { char *offset = reinterpret_cast(dest); - while (remain) { + while (remain && !appQuit) { size_t n = fread(offset, 1, remain, file); if (n == 0) { return -1; @@ -316,7 +322,7 @@ void CFileWatcher::doRun() FILE *watcher_file = fdopen(_handleId, "r"); - while (true) { + while (!qApp->closingDown() && !appQuit) { inotify_event event; if (-1 == freadsome(&event, sizeof(event), watcher_file)) { qWarning() << "------------- freadsome error !!!!!---------- ";