r22925 by jghali - Add more error checks in createCharStyle() vs specified fill and stroke colors
scribus-commit
scribus-commit at lists.scribus.net
Wed Apr 3 21:23:41 UTC 2019
Author: jghali
Date: Wed Apr 3 21:23:41 2019
New Revision: 22925
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22925
Log:
Add more error checks in createCharStyle() vs specified fill and stroke colors
Modified:
trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22925&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp Wed Apr 3 21:23:41 2019
@@ -145,7 +145,21 @@
if (!ScCore->primaryMainWindow()->doc->AllFonts->contains(RealFont))
{
- PyErr_SetString(PyExc_ValueError, QObject::tr("Specified font is not available in font list.", "python error").toLocal8Bit().constData());
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Specified font is not available.", "python error").toLocal8Bit().constData());
+ return nullptr;
+ }
+
+ const ColorList& docColors = ScCore->primaryMainWindow()->doc->PageColors;
+ QString qFillColor = QString(FillColor);
+ QString qStrokeColor = QString(StrokeColor);
+ if ((qFillColor != CommonStrings::None) && (!docColors.contains(qFillColor)))
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Specified fill color is not available in document.", "python error").toLocal8Bit().constData());
+ return nullptr;
+ }
+ if ((qStrokeColor != CommonStrings::None) && (!docColors.contains(qStrokeColor)))
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Specified stroke color is not available in document.", "python error").toLocal8Bit().constData());
return nullptr;
}
@@ -157,9 +171,9 @@
TmpCharStyle.setFontSize(FontSize * 10);
TmpCharStyle.setFontFeatures(FontFeatures);
TmpCharStyle.setFeatures(FeaturesList);
- TmpCharStyle.setFillColor(QString(FillColor));
+ TmpCharStyle.setFillColor(qFillColor);
TmpCharStyle.setFillShade(FillShade * 100);
- TmpCharStyle.setStrokeColor(QString(StrokeColor));
+ TmpCharStyle.setStrokeColor(qStrokeColor);
TmpCharStyle.setStrokeShade(StrokeShade * 100);
TmpCharStyle.setBaselineOffset(BaselineOffset);
TmpCharStyle.setShadowXOffset(ShadowXOffset);
More information about the scribus-commit
mailing list