From c64b74d328da715696cac59349c877c2c33bae5f Mon Sep 17 00:00:00 2001 From: blacksun Date: Thu, 13 Dec 2018 21:39:44 +0000 Subject: [PATCH] Fix : On windows when user drag and drop an element from the common elements collection to the custom elements collection, the element file stay in read only mode, and so user can't save the element git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5648 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- .../elementcollectionhandler.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sources/ElementsCollection/elementcollectionhandler.cpp b/sources/ElementsCollection/elementcollectionhandler.cpp index 3aca3f869..c9013ad95 100644 --- a/sources/ElementsCollection/elementcollectionhandler.cpp +++ b/sources/ElementsCollection/elementcollectionhandler.cpp @@ -135,7 +135,24 @@ ElementsLocation ECHSFileToFile::copyElement(ElementsLocation &source, ElementsL QString new_elmt_name = rename.isEmpty() ? source.fileName() : rename; bool rb = QFile::copy(source.fileSystemPath(), destination.fileSystemPath() + "/" + new_elmt_name); if (rb) + { +#ifdef Q_OS_WIN + //On windows when user drag and drop an element from the common elements collection + //to the custom elements collection, the element file stay in read only mode, and so + //user can't save the element + extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; + qt_ntfs_permission_lookup++; + QFile file(destination.fileSystemPath() + "/" + new_elmt_name); + if (!file.isWritable()) { + if (!file.setPermissions(file.permissions() | QFileDevice::WriteUser)) { + qDebug() << "Failed to change file permission of : " << QFileInfo(file).canonicalFilePath() \ + << " in ECHSFileToFile::copyElement"; + } + } + qt_ntfs_permission_lookup--; +#endif return ElementsLocation (destination.fileSystemPath() + "/" + new_elmt_name); + } else return ElementsLocation(); }