Commit 86179fa8 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Fix crash when trying to convert to a colorspace without valid profile

* disable the ok button
* don't try to convert to a 0 colorspace
* don't try to convert to a 0 colorspace in KisImage
parent 1c3d9d1d
......@@ -683,6 +683,7 @@ void KisImage::convertImageColorSpace(const KoColorSpace *dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags)
{
if (!dstColorSpace) return;
if (*m_d->colorSpace == *dstColorSpace) return;
const KoColorSpace *srcColorSpace = m_d->colorSpace;
......
......@@ -88,13 +88,14 @@ void ColorSpaceConversion::slotImageColorSpaceConversion()
if (dlgColorSpaceConversion->exec() == QDialog::Accepted) {
const KoColorSpace * cs = dlgColorSpaceConversion->m_page->colorSpaceSelector->currentColorSpace();
QApplication::setOverrideCursor(KisCursor::waitCursor());
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::HighQuality;
if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
if (!dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->isChecked()) conversionFlags |= KoColorConversionTransformation::NoOptimization;
image->convertImageColorSpace(cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags);
QApplication::restoreOverrideCursor();
if (cs) {
QApplication::setOverrideCursor(KisCursor::waitCursor());
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::HighQuality;
if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
if (!dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->isChecked()) conversionFlags |= KoColorConversionTransformation::NoOptimization;
image->convertImageColorSpace(cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags);
QApplication::restoreOverrideCursor();
}
}
delete dlgColorSpaceConversion;
}
......@@ -114,23 +115,24 @@ void ColorSpaceConversion::slotLayerColorSpaceConversion()
dlgColorSpaceConversion->setCaption(i18n("Convert Current Layer From") + layer->colorSpace()->name());
if (dlgColorSpaceConversion->exec() == QDialog::Accepted) {
QApplication::setOverrideCursor(KisCursor::waitCursor());
const KoColorSpace * cs = dlgColorSpaceConversion->m_page->colorSpaceSelector->currentColorSpace();
if (cs) {
QApplication::setOverrideCursor(KisCursor::waitCursor());
image->undoAdapter()->beginMacro(i18n("Convert Layer Type"));
image->undoAdapter()->beginMacro(i18n("Convert Layer Type"));
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::HighQuality;
if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
if (!dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->isChecked()) conversionFlags |= KoColorConversionTransformation::NoOptimization;
KisColorSpaceConvertVisitor visitor(image, layer->colorSpace(), cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags);
layer->accept(visitor);
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::HighQuality;
if (dlgColorSpaceConversion->m_page->chkBlackpointCompensation->isChecked()) conversionFlags |= KoColorConversionTransformation::BlackpointCompensation;
if (!dlgColorSpaceConversion->m_page->chkAllowLCMSOptimization->isChecked()) conversionFlags |= KoColorConversionTransformation::NoOptimization;
KisColorSpaceConvertVisitor visitor(image, layer->colorSpace(), cs, (KoColorConversionTransformation::Intent)dlgColorSpaceConversion->m_intentButtonGroup.checkedId(), conversionFlags);
layer->accept(visitor);
image->undoAdapter()->endMacro();
image->undoAdapter()->endMacro();
QApplication::restoreOverrideCursor();
m_view->nodeManager()->nodesUpdated();
QApplication::restoreOverrideCursor();
m_view->nodeManager()->nodesUpdated();
}
}
delete dlgColorSpaceConversion;
}
......
......@@ -61,6 +61,9 @@ DlgColorSpaceConversion::DlgColorSpaceConversion(QWidget * parent,
connect(this, SIGNAL(okClicked()),
this, SLOT(okClicked()));
connect(m_page->colorSpaceSelector, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
}
......@@ -70,6 +73,11 @@ DlgColorSpaceConversion::~DlgColorSpaceConversion()
delete m_page;
}
void DlgColorSpaceConversion::selectionChanged(bool valid)
{
enableButtonOk(m_page->colorSpaceSelector->currentColorSpace());
}
// SLOTS
void DlgColorSpaceConversion::okClicked()
......
......@@ -56,7 +56,7 @@ public:
QButtonGroup m_intentButtonGroup;
public slots:
void selectionChanged(bool);
void okClicked();
};
......
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