diff --git a/editor/src/editorbuffer.cpp b/editor/src/editorbuffer.cpp index 52e6855d..a21ec53a 100644 --- a/editor/src/editorbuffer.cpp +++ b/editor/src/editorbuffer.cpp @@ -19,7 +19,6 @@ #include "editorbuffer.h" #include "utils.h" -#include "window.h" #include "fileloadthread.h" #include @@ -55,16 +54,6 @@ void EditorBuffer::openFile(const QString &filepath) // update file path. updatePath(filepath); - QFile file(filepath); - if (!file.open(QIODevice::ReadOnly)) { - QTimer::singleShot(100, this, [=] { - Utils::toast(QString(tr("You do not have permission to open %1")).arg(filepath), - this->topLevelWidget()); - }); - - return; - } - m_isWritable = QFileInfo(filepath).isWritable(); m_isLoadFinished = false; diff --git a/editor/src/window.cpp b/editor/src/window.cpp index 0a779644..20e81dd4 100644 --- a/editor/src/window.cpp +++ b/editor/src/window.cpp @@ -230,6 +230,14 @@ void Window::addTab(const QString &filepath, bool activeTab) { // check whether it is an editable file thround mimeType. if (Utils::isEditableFile(filepath)) { + + // check if have permission to read the file. + QFile file(filepath); + if (!file.open(QIODevice::ReadOnly)) { + showNotify(QString(tr("You do not have permission to open %1")).arg(filepath)); + return; + } + if (m_tabbar->getTabIndex(filepath) == -1) { m_tabbar->addTab(filepath, QFileInfo(filepath).fileName());