Commit 71a44a9b authored by Boudewijn Rempt's avatar Boudewijn Rempt

minor fixes, future-proofing and an attempt at making the destructor of...

minor fixes, future-proofing and an attempt at making the destructor of KoColorSpaceRegistry actually work

svn path=/trunk/koffice/; revision=898457
parent cbc5b2f5
......@@ -21,14 +21,13 @@
#include <QtGui/QColor>
#include <QtCore/QString>
#include "ksharedptr.h"
/**
* This class gives some basic information about a channel,
* that is, one of the components that makes up a particular
* pixel.
*/
class KoChannelInfo : public KShared {
class KoChannelInfo {
public:
/// enum to define the type of the channel
enum enumChannelType {
......
......@@ -26,7 +26,7 @@ class KoColorSpace;
#include "KoColorConversionTransformation.h"
/**
* This class holds a cache of KoColorConversionTransformation.
* This class holds a cache of KoColorConversionTransformations.
*
* This class is not part of public API, and can be changed without notice.
*/
......@@ -36,13 +36,15 @@ class KoColorConversionCache {
public:
KoColorConversionCache();
~KoColorConversionCache();
/**
* This function return a cached color transformation if available
* This function returns a cached color transformation if available
* or create one.
* @param src source color space
* @param dst destination color space
*/
KoCachedColorConversionTransformation cachedConverter(const KoColorSpace* src, const KoColorSpace* dst, KoColorConversionTransformation::Intent _renderingIntent = KoColorConversionTransformation::IntentPerceptual);
/**
* This function is called by the destructor of the color space to
* warn the cache that any pointers to this color space is going to
......
......@@ -516,7 +516,7 @@ inline KoColorConversionSystem::Path* KoColorConversionSystem::findBestPathImpl2
else if ( pQC.lessWorseThan( newP, lessWorsePath) ) {
Q_ASSERT(newP->startNode()->id() == lessWorsePath->startNode()->id() );
Q_ASSERT(newP->endNode()->id() == lessWorsePath->endNode()->id());
kDebug() << pQC.lessWorseThan( newP, lessWorsePath) << " " << newP << " "<< lessWorsePath;
warnPigment << pQC.lessWorseThan( newP, lessWorsePath) << " " << newP << " "<< lessWorsePath;
delete lessWorsePath;
lessWorsePath = newP;
} else {
......@@ -547,10 +547,10 @@ inline KoColorConversionSystem::Path* KoColorConversionSystem::findBestPathImpl2
}
if(lessWorsePath)
{
kWarning(DBG_PIGMENT) << "No good path from " << srcNode->id() << " to " << dstNode->id() << " found : length = " << lessWorsePath->length() << " cost = " << lessWorsePath->cost << " referenceDepth = " << lessWorsePath->referenceDepth << " respectColorCorrectness = " << lessWorsePath->respectColorCorrectness << " isGood = " << lessWorsePath->isGood ;
warnPigment << "No good path from " << srcNode->id() << " to " << dstNode->id() << " found : length = " << lessWorsePath->length() << " cost = " << lessWorsePath->cost << " referenceDepth = " << lessWorsePath->referenceDepth << " respectColorCorrectness = " << lessWorsePath->respectColorCorrectness << " isGood = " << lessWorsePath->isGood ;
return lessWorsePath;
}
kError(DBG_PIGMENT) << "No path from " << srcNode->id() << " to " << dstNode->id() << " found not ";
errorPigment << "No path from " << srcNode->id() << " to " << dstNode->id() << " found not ";
return 0;
}
......
......@@ -80,7 +80,10 @@ KoColorSpace::~KoColorSpace()
{
delete channel;
}
KoColorSpaceRegistry::instance()->colorConversionCache()->colorSpaceIsDestroyed(this);
KoColorConversionCache* cache = KoColorSpaceRegistry::instance()->colorConversionCache();
if (cache) {
cache->colorSpaceIsDestroyed(this);
}
delete d->mixColorsOp;
delete d->convolutionOp;
delete d;
......
......@@ -31,10 +31,10 @@
#include <klocale.h>
#include <kservice.h>
#include <kservicetypetrader.h>
#include <k3staticdeleter.h>
#include <lcms.h>
#include "KoPluginLoader.h"
#include "DebugPigment.h"
......@@ -70,11 +70,14 @@ struct KoColorSpaceRegistry::Private {
};
KoColorSpaceRegistry *KoColorSpaceRegistry::Private::singleton = 0;
// deleting the registry still gives errors
//static K3StaticDeleter<KoColorSpaceRegistry> staticDeleter;
KoColorSpaceRegistry* KoColorSpaceRegistry::instance()
{
if(KoColorSpaceRegistry::Private::singleton == 0)
{
//staticDeleter.setObject(KoColorSpaceRegistry::Private::singleton, new KoColorSpaceRegistry());
KoColorSpaceRegistry::Private::singleton = new KoColorSpaceRegistry();
KoColorSpaceRegistry::Private::singleton->init();
}
......@@ -201,7 +204,6 @@ KoColorSpaceRegistry::KoColorSpaceRegistry() : d(new Private())
KoColorSpaceRegistry::~KoColorSpaceRegistry()
{
delete d->colorConversionSystem;
delete d->colorConversionCache;
foreach( KoColorProfile* profile, d->profileMap) {
delete profile;
}
......@@ -210,6 +212,9 @@ KoColorSpaceRegistry::~KoColorSpaceRegistry()
delete cs;
}
d->csMap.clear();
// deleting colorspaces calls a function in the cache
delete d->colorConversionCache;
d->colorConversionCache = 0;
delete d->alphaCs;
delete d->rgbU8sRGB;
delete d->lab16sLAB;
......
......@@ -367,13 +367,13 @@ void KoAlphaColorSpace::fromQColor(const QColor& c, quint8 *dst, const KoColorPr
void KoAlphaColorSpace::toQColor(const quint8 * src, QColor *c, const KoColorProfile * /*profile*/) const
{
c->setRgba(255, 255, 255, src[PIXEL_MASK]);
c->setRgba(qRgba(255, 255, 255, src[PIXEL_MASK]));
}
quint8 KoAlphaColorSpace::difference(const quint8 *src1, const quint8 *src2) const
{
// Arithmetic operands smaller than int are converted to int automatically
return QABS(src2[PIXEL_MASK] - src1[PIXEL_MASK]);
return qAbs(src2[PIXEL_MASK] - src1[PIXEL_MASK]);
}
void KoAlphaColorSpace::mixColors(const quint8 **colors, const quint8 *weights, quint32 nColors, quint8 *dst) const
......
......@@ -63,7 +63,7 @@ public:
const channels_type *s = reinterpret_cast<const channels_type *>(srcRowStart);
channels_type *d = reinterpret_cast<channels_type *>(dstRowStart);
const Q_UINT8 *mask = maskRowStart;
const quint8 *mask = maskRowStart;
for (qint32 i = cols; i > 0; i--, s+=srcInc, d+=_CSTraits::channels_nb)
{
......
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