Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bug (cherry-pick from master) #2346

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/apps/dde-file-manager/singleapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,13 @@
localServer = nullptr;
}
}

void SingleApplication::handleQuitAction()

Check warning on line 191 in src/apps/dde-file-manager/singleapplication.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'handleQuitAction' is never used.

Check warning on line 191 in src/apps/dde-file-manager/singleapplication.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'handleQuitAction' is never used.
{
// fix bug-272373
// When exiting the process, if a copy task exists (@abstractjob.cpp),
// this task will block the main thread, causing the UI to be unresponsive.
// So here is a rewrite of the exit implementation that closes all the windows
// of the filemanager
WindowUtils::closeAllFileManagerWindows();
}
3 changes: 3 additions & 0 deletions src/apps/dde-file-manager/singleapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public slots:
void readData();
void closeServer();

protected:
virtual void handleQuitAction() override;

private:
static QLocalSocket *getNewClientConnect(const QString &key, const QByteArray &message);
static QString userServerName(const QString &key);
Expand Down
17 changes: 17 additions & 0 deletions src/dfm-base/utils/windowutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "windowutils.h"

#include <dfm-base/widgets/filemanagerwindowsmanager.h>

#include <QApplication>
#include <QScreen>

Expand Down Expand Up @@ -48,3 +50,18 @@ QScreen *DFMBASE_NAMESPACE::WindowUtils::cursorScreen()

return cursorScreen;
}

void DFMBASE_NAMESPACE::WindowUtils::closeAllFileManagerWindows()
{
auto winIds { FileManagerWindowsManager::instance().windowIdList() };

for (auto id : winIds) {
FileManagerWindow *window { FileManagerWindowsManager::instance().findWindowById(id) };
if (window)
window->close();
}

winIds = FileManagerWindowsManager::instance().windowIdList();
if (winIds.count() > 0)
qApp->quit();
}
4 changes: 3 additions & 1 deletion src/dfm-base/utils/windowutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class WindowUtils
static bool keyAltIsPressed();

static QScreen *cursorScreen();

static void closeAllFileManagerWindows();
};

}
} // namespace dfmbase
#endif // WINDOWUTILS_H
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ AbstractJob::AbstractJob(AbstractWorker *doWorker, QObject *parent)
connect(doWorker, &AbstractWorker::fileRenamed, this, &AbstractJob::handleFileRenamed, Qt::QueuedConnection);
connect(qApp, &QCoreApplication::aboutToQuit, this, [=]() {
thread.quit();
thread.wait();
// When manipulating a file,
// if the TaskDialog has not been popped up yet,
// immediately close dde-file-manage at this time,
// here will cause the dde-file-manager process
// to be blocked in the main thread,
// and then can not open the new dde-file-manage process,
// so here to add a timeout time.
// see: bug-272373
thread.wait(3000);
});
start();
}
Expand Down
Loading