r22943 by jghali - Check there is a current document when calling scripter's createCustomLineStyle()

scribus-commit scribus-commit at lists.scribus.net
Sat Apr 13 12:39:10 UTC 2019


Author: jghali
Date: Sat Apr 13 12:39:10 2019
New Revision: 22943

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22943
Log:
Check there is a current document when calling scripter's createCustomLineStyle()

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=22943&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp	(original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdstyle.cpp	Sat Apr 13 12:39:10 2019
@@ -213,8 +213,12 @@
 		return nullptr;
 	}
 
+	if (!checkHaveDocument())
+		return nullptr;
+	ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
+
 	multiLine ml;
-	const ColorList& docColors = ScCore->primaryMainWindow()->doc->PageColors;
+	const ColorList& docColors = currentDoc->PageColors;
 
 	for (int i = 0; i < PyList_Size(obj); i++)
 	{
@@ -231,7 +235,7 @@
 		if (val)
 			sl.Color = PyString_AsString(val);
 		else 
-			sl.Color = ScCore->primaryMainWindow()->doc->itemToolPrefs().lineColor;
+			sl.Color = currentDoc->itemToolPrefs().lineColor;
 
 		val = PyDict_GetItemString(line, "Dash");
 		if (val)
@@ -255,13 +259,13 @@
 		if (val)
 			sl.Shade = PyInt_AsLong(val);
 		else 
-			sl.Shade = ScCore->primaryMainWindow()->doc->itemToolPrefs().lineColorShade;
+			sl.Shade = currentDoc->itemToolPrefs().lineColorShade;
 
 		val = PyDict_GetItemString(line, "Width");
 		if (val)
 			sl.Width = PyFloat_AsDouble(val);
 		else 
-			sl.Width = ScCore->primaryMainWindow()->doc->itemToolPrefs().lineWidth;
+			sl.Width = currentDoc->itemToolPrefs().lineWidth;
 
 		val = PyDict_GetItemString(line, "Shortcut");
 		if (val)
@@ -277,7 +281,7 @@
 		ml.push_back(sl);
 	}
 	if (!ml.empty())
-		ScCore->primaryMainWindow()->doc->MLineStyles[Name] = ml;
+		currentDoc->MLineStyles[Name] = ml;
 	Py_RETURN_NONE;
 }
 




More information about the scribus-commit mailing list