Skip to content

Commit

Permalink
fix: no permissions to read file without create new tab.
Browse files Browse the repository at this point in the history
Change-Id: Ie8faeef2313bb8ee6939b033565faf6015e2305a
  • Loading branch information
rekols committed Sep 19, 2018
1 parent 5e9a884 commit bc4039e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 0 additions & 11 deletions editor/src/editorbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "editorbuffer.h"
#include "utils.h"
#include "window.h"
#include "fileloadthread.h"

#include <QCoreApplication>
Expand Down Expand Up @@ -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;

Expand Down
8 changes: 8 additions & 0 deletions editor/src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit bc4039e

Please sign in to comment.