Warning, /graphics/krita/3rdparty/ext_qt/0026-Android-Use-processOpenModeFlags-to-get-right-OpenMo.patch is written in an unsupported language. File is not indexed.
0001 From 668bd4d9b9b8fd40cc9017082f72dbe931e1ee7b Mon Sep 17 00:00:00 2001 0002 From: Sharaf Zaman <sharafzaz121@gmail.com> 0003 Date: Thu, 5 Nov 2020 11:13:49 +0000 0004 Subject: [PATCH 26/46] Android: Use processOpenModeFlags to get right OpenMode 0005 0006 processOpenModeFlags handles flags individually so, we get the right 0007 behavior which is consistent with rest of the Qt. Previously using 0008 WriteOnly would only pass the flag "w" to Android. Now it correctly 0009 handles the additional Truncate flag. 0010 --- 0011 .../src/org/qtproject/qt5/android/QtNative.java | 3 ++- 0012 .../android/androidcontentfileengine.cpp | 17 +++++++++++++---- 0013 2 files changed, 15 insertions(+), 5 deletions(-) 0014 0015 diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java 0016 index 367b063a0e..4e5ff3bde6 100644 0017 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java 0018 +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java 0019 @@ -243,9 +243,10 @@ public class QtNative 0020 m_parcelFileDescriptors.put(fdDesc.getFd(), fdDesc); 0021 return fdDesc.getFd(); 0022 } catch (FileNotFoundException e) { 0023 + e.printStackTrace(); 0024 return error; 0025 } catch (IllegalArgumentException e) { 0026 - Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri"); 0027 + Log.e(QtTAG, "openFdForContentUrl(): Invalid Uri: " + e); 0028 return error; 0029 } 0030 } 0031 diff --git a/src/plugins/platforms/android/androidcontentfileengine.cpp b/src/plugins/platforms/android/androidcontentfileengine.cpp 0032 index c367a7e362..ffda6592f4 100644 0033 --- a/src/plugins/platforms/android/androidcontentfileengine.cpp 0034 +++ b/src/plugins/platforms/android/androidcontentfileengine.cpp 0035 @@ -54,15 +54,23 @@ AndroidContentFileEngine::AndroidContentFileEngine(const QString &f) 0036 bool AndroidContentFileEngine::open(QIODevice::OpenMode openMode) 0037 { 0038 QString openModeStr; 0039 - if (openMode & QFileDevice::ReadOnly) { 0040 + ProcessOpenModeResult res = processOpenModeFlags(openMode); 0041 + if (!res.ok) { 0042 + setError(QFileDevice::OpenError, res.error); 0043 + return false; 0044 + } 0045 + 0046 + // if Truncate flag is set we have to set 'r' as well, else we get inconsistent results. 0047 + if ((res.openMode & QFileDevice::ReadOnly) || (res.openMode & QFileDevice::Truncate)) { 0048 openModeStr += QLatin1Char('r'); 0049 } 0050 - if (openMode & QFileDevice::WriteOnly) { 0051 + if (res.openMode & QFileDevice::WriteOnly) { 0052 openModeStr += QLatin1Char('w'); 0053 } 0054 - if (openMode & QFileDevice::Truncate) { 0055 + if (res.openMode & QFileDevice::Truncate) { 0056 openModeStr += QLatin1Char('t'); 0057 - } else if (openMode & QFileDevice::Append) { 0058 + } else if (res.openMode & QFileDevice::Append) { 0059 + qWarning("Android doesn't support 'a' mode when accessing a ContentProvider"); 0060 openModeStr += QLatin1Char('a'); 0061 } 0062 0063 @@ -74,6 +82,7 @@ bool AndroidContentFileEngine::open(QIODevice::OpenMode openMode) 0064 QJNIObjectPrivate::fromString(openModeStr).object()); 0065 0066 if (fd < 0) { 0067 + setError(QFileDevice::OpenError, QLatin1String("The file could not be opened.")); 0068 return false; 0069 } 0070 0071 -- 0072 2.33.0 0073