aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/EditorPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widgets/EditorPage.cpp')
-rw-r--r--src/ui/widgets/EditorPage.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ui/widgets/EditorPage.cpp b/src/ui/widgets/EditorPage.cpp
index eeedfaf5..94c98036 100644
--- a/src/ui/widgets/EditorPage.cpp
+++ b/src/ui/widgets/EditorPage.cpp
@@ -107,9 +107,11 @@ void EditorPage::slotFormatGpgHeader() {
cursor.setCharFormat(signFormat);
}
-void EditorPage::readFile() {
+void EditorPage::ReadFile() {
LOG(INFO) << "Called";
+ readDone = false;
+
auto text_page = this->getTextPage();
text_page->setReadOnly(true);
auto thread = new FileReadThread(this->fullFilePath.toStdString());
@@ -126,19 +128,27 @@ void EditorPage::readFile() {
connect(thread, &FileReadThread::finished, this, [=]() {
LOG(INFO) << "Thread finished";
thread->deleteLater();
+ readDone = true;
+ readThread = nullptr;
});
- connect(this, &FileReadThread::destroyed, [=]() {
+ connect(this, &EditorPage::destroyed, [=]() {
LOG(INFO) << "RequestInterruption for readThread";
thread->requestInterruption();
- thread->deleteLater();
+ readThread = nullptr;
});
-
+ this->readThread = thread;
thread->start();
}
void EditorPage::slotInsertText(const QString& text) {
this->getTextPage()->insertPlainText(text);
}
+void EditorPage::PrepareToDestroy() {
+ if (readThread) {
+ readThread->requestInterruption();
+ readThread = nullptr;
+ }
+}
} // namespace GpgFrontend::UI