From d4a881e6ee9b6b0ba6fc4bc06beb5a57c9e0e8f2 Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgads@gmail.com>
Date: Thu, 1 Dec 2011 23:34:23 +0200
Subject: [PATCH] Test for read-only when session is loaded

Task-number: QTCREATORBUG-5131
Change-Id: I6642ec2b80ff156b76bba86172e8a2362cb02bc8
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
---
 .../coreplugin/editormanager/openeditorsmodel.cpp      | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
index 27bff24e6ef..b7b4250ba85 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
@@ -310,8 +310,14 @@ QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
                 ? e.displayName() + QLatin1Char('*')
                 : e.displayName();
     case Qt::DecorationRole:
-        return (e.editor && e.editor->file()->isReadOnly())
-                ? d->m_lockedIcon : QIcon();
+    {
+        bool readOnly = false;
+        if (e.editor)
+            readOnly = e.editor->file()->isReadOnly();
+        else
+            readOnly = !QFileInfo(e.m_fileName).isWritable();
+        return readOnly ? d->m_lockedIcon : QIcon();
+    }
     case Qt::ToolTipRole:
         return e.fileName().isEmpty()
                 ? e.displayName()
-- 
GitLab