diff options
author | saturneric <[email protected]> | 2024-01-22 14:01:34 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-22 14:01:34 +0000 |
commit | 0ff4345f4ce20be2f0d20a597da324d4f4855999 (patch) | |
tree | 0ef6472ac1f0fb87b5c42cce7344652affc2a3f1 /src/ui/widgets/FileTreeView.cpp | |
parent | fix: QStringList is not equal to QList<QVector> (diff) | |
download | GpgFrontend-0ff4345f4ce20be2f0d20a597da324d4f4855999.tar.gz GpgFrontend-0ff4345f4ce20be2f0d20a597da324d4f4855999.zip |
fix: stop reading all data into memory at file hash calculation
Diffstat (limited to 'src/ui/widgets/FileTreeView.cpp')
-rw-r--r-- | src/ui/widgets/FileTreeView.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp index 41cd9aff..0c299a97 100644 --- a/src/ui/widgets/FileTreeView.cpp +++ b/src/ui/widgets/FileTreeView.cpp @@ -28,8 +28,10 @@ #include "FileTreeView.h" +#include "core/utils/AsyncUtils.h" #include "core/utils/IOUtils.h" #include "ui/UISignalStation.h" +#include "ui/UserInterfaceUtils.h" namespace GpgFrontend::UI { @@ -372,8 +374,24 @@ void FileTreeView::slot_show_custom_context_menu(const QPoint& point) { } void FileTreeView::slot_calculate_hash() { - emit UISignalStation::GetInstance()->SignalRefreshInfoBoard( - CalculateHash(this->GetSelectedPath()), InfoBoardStatus::INFO_ERROR_OK); + CommonUtils::WaitForOpera( + this->parentWidget(), tr("Calculating"), [=](const OperaWaitingHd& hd) { + RunOperaAsync( + [=](DataObjectPtr data_object) { + data_object->Swap({CalculateHash(this->GetSelectedPath())}); + return 0; + }, + [hd](int rtn, DataObjectPtr data_object) { + hd(); + if (rtn < 0 || !data_object->Check<QString>()) { + return; + } + auto result = ExtractParams<QString>(data_object, 0); + emit UISignalStation::GetInstance()->SignalRefreshInfoBoard( + result, InfoBoardStatus::INFO_ERROR_OK); + }, + "calculate_file_hash"); + }); } void FileTreeView::slot_compress_files() {} |