View Issue Details

IDProjectCategoryView StatusLast Update
0016809ScribusScripterpublic2023-05-29 18:56
Reporterwilliam Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5.8 
Fixed in Version1.6.0.svn 
Summary0016809: Scripter crashes with getAllObjects() on a master page
Descriptiona sequence like the one below crashes scribus in the scripter:
for MasterPageName in masterPageNames():
  editMasterPage(MasterPageName)
  ObjectNames = getAllObjects()
  for ObjectName in ObjectNames:
    x = getObjectType(ObjectName)
  closeMasterPage()

When scribus/plugins/scriptplugin/cmdgetprop.cpp scribus_getallobjects() makes the return list, it counts the items in currentDoc->DocItems but returns the items in currentDoc->Items. If you are on a master page, Items points to MasterItems. If the number of items differ, the python list object will have null items, which crashes python. It should count the items using Items instead of DocItems so it works on all types of pages.

The issue was introduced on Nov 4 18:41:26 2020 in 0016308: Readability and feature fixes for getAllObjects()
It is also present in 1.7.
TagsNo tags attached.
PatchYes

Activities

william

2022-06-13 23:24

updater  

scribus158-20220614-001746.patch (800 bytes)   
 scribus/plugins/scriptplugin/cmdgetprop.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scribus/plugins/scriptplugin/cmdgetprop.cpp b/scribus/plugins/scriptplugin/cmdgetprop.cpp
index b82e04942..0602cef5c 100644
--- a/scribus/plugins/scriptplugin/cmdgetprop.cpp
+++ b/scribus/plugins/scriptplugin/cmdgetprop.cpp
@@ -374,7 +374,7 @@ PyObject *scribus_getallobjects(PyObject* /* self */, PyObject* args, PyObject *
 		return true;
 	};
 
-	int returnedItemCount = std::count_if(currentDoc->DocItems.begin(), currentDoc->DocItems.end(), isReturnedItem);
+	int returnedItemCount = std::count_if(currentDoc->Items->begin(), currentDoc->Items->end(), isReturnedItem);
 
 	PyObject* pyItemList = PyList_New(returnedItemCount);
 	for (int i = 0; i < currentDoc->Items->count(); ++i)

jghali

2022-06-14 12:39

administrator   ~0049699

Applied, thanks!

Issue History

Date Modified Username Field Change
2022-06-13 23:24 william New Issue
2022-06-13 23:24 william File Added: scribus158-20220614-001746.patch
2022-06-13 23:39 william Description Updated
2022-06-14 12:39 jghali Assigned To => jghali
2022-06-14 12:39 jghali Status new => resolved
2022-06-14 12:39 jghali Resolution open => fixed
2022-06-14 12:39 jghali Fixed in Version => 1.6.0.svn
2022-06-14 12:39 jghali Note Added: 0049699
2022-06-14 12:39 jghali Summary [patch] scripter crashes with getAllObjects() on a master page => Scripter crashes with getAllObjects() on a master page
2023-05-29 18:56 cbradney Status resolved => closed