[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [digikam] core/utilities/imageeditor/core: use QFile read / write to bypass the 2GiB boundary of the
From:       Maik Qualmann <null () kde ! org>
Date:       2018-04-30 10:40:47
Message-ID: E1fD6Eh-0002xf-O2 () code ! kde ! org
[Download RAW message or body]

Git commit b68123472b98dd5c08c2f60ae211e980f82d16a6 by Maik Qualmann.
Committed on 30/04/2018 at 10:40.
Pushed by mqualmann into branch 'master'.

use QFile read / write to bypass the 2GiB boundary of the QDataStream

M  +10   -9    core/utilities/imageeditor/core/undocache.cpp

https://commits.kde.org/digikam/b68123472b98dd5c08c2f60ae211e980f82d16a6

diff --git a/core/utilities/imageeditor/core/undocache.cpp \
b/core/utilities/imageeditor/core/undocache.cpp index 078452e4ca..b45748edc7 100644
--- a/core/utilities/imageeditor/core/undocache.cpp
+++ b/core/utilities/imageeditor/core/undocache.cpp
@@ -160,18 +160,18 @@ bool UndoCache::putData(int level, const DImg& img) const
     ds << img.hasAlpha();
     ds << img.sixteenBit();
 
-    ds.writeRawData((const char*)img.bits(), img.numBytes());
+    file.write((const char*)img.bits(), img.numBytes());
 
-    file.close();
-
-    if (ds.status() != QDataStream::Ok)
+    if (file.error() != QFileDevice::NoError)
     {
+        file.close();
         file.remove();
         return false;
     }
 
     d->cachedLevels << level;
 
+    file.close();
     return true;
 }
 
@@ -197,7 +197,7 @@ DImg UndoCache::getData(int level) const
     ds >> hasAlpha;
     ds >> sixteenBit;
 
-    uint size  = w * h * (sixteenBit ? 8 : 4);
+    qint64 size  = w * h * (sixteenBit ? 8 : 4);
 
     if (ds.status() != QDataStream::Ok ||
         ds.atEnd() || numBytes != size || size == 0)
@@ -216,18 +216,19 @@ DImg UndoCache::getData(int level) const
         return DImg();
     }
 
-    ds.readRawData(data, size);
+    qint64 readSize = file.read(data, size);
 
-    file.close();
-
-    if (ds.status() != QDataStream::Ok)
+    if (file.error() != QFileDevice::NoError || readSize != size)
     {
         delete [] data;
+
+        file.close();
         return DImg();
     }
 
     DImg img(w, h, sixteenBit, hasAlpha, (uchar*)data, false);
 
+    file.close();
     return img;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic