[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [digikam] core/utilities/imageeditor/core: undo is now very fast on big images
From: Maik Qualmann <null () kde ! org>
Date: 2018-04-30 19:24:18
Message-ID: E1fDEPK-00088o-Br () code ! kde ! org
[Download RAW message or body]
Git commit cbfbb398be95d1bf66838375e481f261f5cb99b2 by Maik Qualmann.
Committed on 30/04/2018 at 19:23.
Pushed by mqualmann into branch 'master'.
undo is now very fast on big images
M +11 -13 core/utilities/imageeditor/core/undocache.cpp
https://commits.kde.org/digikam/cbfbb398be95d1bf66838375e481f261f5cb99b2
diff --git a/core/utilities/imageeditor/core/undocache.cpp \
b/core/utilities/imageeditor/core/undocache.cpp index b45748edc7..b27ecb7200 100644
--- a/core/utilities/imageeditor/core/undocache.cpp
+++ b/core/utilities/imageeditor/core/undocache.cpp
@@ -44,7 +44,6 @@
// Local includes
#include "digikam_debug.h"
-#include "dimgloader.h"
namespace Digikam
{
@@ -166,12 +165,14 @@ bool UndoCache::putData(int level, const DImg& img) const
{
file.close();
file.remove();
+
return false;
}
d->cachedLevels << level;
file.close();
+
return true;
}
@@ -197,38 +198,35 @@ DImg UndoCache::getData(int level) const
ds >> hasAlpha;
ds >> sixteenBit;
- qint64 size = w * h * (sixteenBit ? 8 : 4);
-
- if (ds.status() != QDataStream::Ok ||
- ds.atEnd() || numBytes != size || size == 0)
+ if (ds.status() != QDataStream::Ok || ds.atEnd())
{
qCDebug(DIGIKAM_GENERAL_LOG) << "The undo cache file is corrupt";
file.close();
+
return DImg();
}
- char* data = (char*)DImgLoader::new_failureTolerant(size);
+ DImg img(w, h, sixteenBit, hasAlpha);
- if (!data)
+ if (img.isNull() || numBytes != img.numBytes())
{
file.close();
+
return DImg();
}
- qint64 readSize = file.read(data, size);
+ qint64 readBytes = file.read((char*)img.bits(), numBytes);
- if (file.error() != QFileDevice::NoError || readSize != size)
+ if (file.error() != QFileDevice::NoError || readBytes != numBytes)
{
- 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