Skip to content

Commit

Permalink
fix: Resolve the issue of not being able to repeatedly open ddf files
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
starhcq committed Sep 18, 2024
1 parent 52e0d39 commit bc461fb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/frame/cviewmanagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char *>(dest);
while (remain) {
while (remain && !appQuit) {
size_t n = fread(offset, 1, remain, file);
if (n == 0) {
return -1;
Expand All @@ -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 !!!!!---------- ";
Expand Down

0 comments on commit bc461fb

Please sign in to comment.