Commit 6555ba9b authored by Halla Rempt's avatar Halla Rempt
Browse files

Fix KisPatternTest

parent d8ee0554
......@@ -21,6 +21,9 @@
#include <qtest_kde.h>
#include "KoPattern.h"
#include <QCryptographicHash>
#include <QByteArray>
void KoPatternTest::testCreation()
{
KoPattern test(QString(FILES_DATA_DIR) + QDir::separator() + "pattern.pat");
......@@ -50,6 +53,17 @@ void KoPatternTest::testRoundTripMd5()
qDebug() << patPattern.pattern().format();
QCOMPARE(pngPattern.pattern().convertToFormat(QImage::Format_ARGB32), patPattern.pattern().convertToFormat(QImage::Format_ARGB32));
QImage im1 = pngPattern.pattern().convertToFormat(QImage::Format_ARGB32);
QImage im2 = patPattern.pattern().convertToFormat(QImage::Format_ARGB32);
QCryptographicHash h1(QCryptographicHash::Md5);
h1.addData(QByteArray::fromRawData((const char*)im1.constBits(), im1.byteCount()));
QCryptographicHash h2(QCryptographicHash::Md5);
h2.addData(QByteArray::fromRawData((const char*)im2.constBits(), im2.byteCount()));
QCOMPARE(h1.result(), h2.result());
QCOMPARE(im1, im2);
QCOMPARE(pngPattern.md5(), patPattern.md5());
}
......
......@@ -72,7 +72,6 @@ KisFilterConfiguration* KisFilterOpSettings::filterConfig() const
{
if (hasProperty(FILTER_ID)) {
KisFilterSP filter = KisFilterRegistry::instance()->get(getString(FILTER_ID));
Q_ASSERT(filter);
if (filter) {
KisFilterConfiguration* configuration = filter->factoryConfiguration(0);
configuration->fromXML(getString(FILTER_CONFIGURATION));
......@@ -100,7 +99,6 @@ void KisFilterOpSettings::fromXML(const QDomElement& e)
QDomElement element = e.firstChildElement("filterconfig");
if (hasProperty(FILTER_ID)) {
KisFilterSP filter = KisFilterRegistry::instance()->get(getString(FILTER_ID));
Q_ASSERT(filter);
if (filter) {
KisFilterConfiguration* configuration = filter->factoryConfiguration(0);
configuration->fromXML(element);
......
......@@ -354,10 +354,11 @@ QImage KoPattern::pattern() const
QByteArray KoPattern::generateMD5() const
{
if (!pattern().isNull()) {
QImage im = m_pattern.convertToFormat(QImage::Format_ARGB32);
#if QT_VERSION >= 0x040700
QByteArray ba = QByteArray::fromRawData((const char*)m_pattern.constBits(), m_pattern.byteCount());
QByteArray ba = QByteArray::fromRawData((const char*)im.constBits(), im.byteCount());
#else
QByteArray ba = QByteArray::fromRawData((const char*)m_pattern.bits(), m_pattern.byteCount());
QByteArray ba = QByteArray::fromRawData((const char*)im.bits(), im.byteCount());
#endif
QCryptographicHash md5(QCryptographicHash::Md5);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment