View Issue Details

IDProjectCategoryView StatusLast Update
0017153ScribusScripterpublic2024-02-12 21:10
ReporterZinal Assigned Tojghali  
PrioritylowSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.7.0.svn 
Fixed in Version1.6.2.svn 
Summary0017153: Scripter's combinePolygons() always returns error
DescriptionNo matter what type of objects are selected, the combinePolygons() function will always return an error.
Steps To Reproduce- create a simple text frame
- right-click the frame -> "Convert to" -> "Outlines"
- right-click the new group -> "Ungroup".
- in the script console run "scribus.combinePolygons()"
Tagspolygons, python, scripter
PatchNo

Activities

Zinal

2024-02-05 16:25

reporter   ~0050962

Found the reason:

File: cmdmani.cpp in scriptplugin -> cmdmani.cpp -> scribus_combinepolygons()

if ((!it->isPolygon()) || (!it->isPolyLine()))
    canUniteItems = false;

It should be an "and" operator, not an "or" operator. We want to check if the pageItem (it) is anything other than a polygon or polyline:

if((!it->isPolygon()) && (!it->isPolyLine()))
    canUniteItems = false;

ale

2024-02-05 17:56

manager   ~0050963

nice catch : - )

maybe it can be slightly simplified (using an early return instead of the temporary variable... and i'm pretty sure that the parentheses are not needed...):

PyObject *scribus_combinepolygons(PyObject * /* self */)
{
    if (!checkHaveDocument())
        return nullptr;

    ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
    Selection* curSelection = currentDoc->m_Selection;
    if (curSelection->count() <= 1)
        Py_RETURN_NONE;

    for (int i = 0; i < curSelection->count(); ++i)
    {
        PageItem* it = currentDoc->m_Selection->itemAt(i);
        if (!it->isPolygon() && !it->isPolyLine())
        {
            PyErr_SetString(WrongFrameTypeError, QObject::tr("Selection must contain only shapes or bezier curves.", "python error").toLocal8Bit().constData());
            return nullptr;
        }
    }

    currentDoc->itemSelection_UniteItems(nullptr);

    Py_RETURN_NONE;
}

jghali

2024-02-05 18:22

administrator   ~0050964

Nice catch, fixed! Thanks for the report.

Issue History

Date Modified Username Field Change
2024-02-05 16:16 Zinal New Issue
2024-02-05 16:16 Zinal Tag Attached: polygons
2024-02-05 16:16 Zinal Tag Attached: python
2024-02-05 16:16 Zinal Tag Attached: scripter
2024-02-05 16:25 Zinal Note Added: 0050962
2024-02-05 17:56 ale Note Added: 0050963
2024-02-05 18:05 jghali Summary combinePolygons() - Always returns error => Scripter's combinePolygons() always returns error
2024-02-05 18:22 jghali Assigned To => jghali
2024-02-05 18:22 jghali Status new => resolved
2024-02-05 18:22 jghali Resolution open => fixed
2024-02-05 18:22 jghali Fixed in Version => 1.6.2.svn
2024-02-05 18:22 jghali Note Added: 0050964
2024-02-12 21:10 cbradney Status resolved => closed