View Issue Details

IDProjectCategoryView StatusLast Update
0016171ScribusStory Editor / Text Framespublic2020-08-11 20:56
Reporterale Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Fixed in Version1.5.6.svn 
Summary0016171: ScribusMainWindow::insertMark() should not delete the selection before executing the dialog
Descriptionthere is a crash when:

- selecting some text
- insert > marks > anchor
- cancel
- click somewhere outside of the frame
- crash

i guess that the first step to resolve this bug is not to delete the selection before the dialog is executed.
TagsNo tags attached.
PatchNo

Activities

ale

2020-07-19 12:46

manager   ~0047849

this code crashes in the conditions described above:

    if (!HaveDoc)
        return;
    if (doc->m_Selection->count() != 1)
        return;
    if (doc->masterPageMode())
        return;
    if (doc->appMode != modeEdit)
        return;

    PageItem* currItem = doc->m_Selection->itemAt(0);

    if (!currItem->isTextFrame())
        return;

    InsertBookmarkDialog dialog(this);
    if (!dialog.exec())
        return;

    UndoTransaction trans;

    if (currItem->HasSel)
    {
        if (UndoManager::instance()->undoEnabled())
            trans = m_undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete);
        //inserting mark replace some selected text
        currItem->asTextFrame()->deleteSelectedTextFromFrame();
    }

    if (trans)
        trans.commit();


p.s.: the dialog does absolutely nothing.

ale

2020-07-19 13:06

manager   ~0047850

the problem seems to be that

PageItem_TextFrame::deleteSelectedTextFromFrame()

has its own transaction...

ale

2020-07-19 13:16

manager   ~0047851

trying to disable the undo manager during deleteSelectedTextFromFrame() did not resolve the crash:


    UndoTransaction trans;

    bool undoEnabled = m_undoManager->undoEnabled();

    if (currItem->HasSel)
    {
        if (undoEnabled)
        {
            trans = m_undoManager->beginTransaction(Um::Selection,Um::IDelete,Um::Delete,"",Um::IDelete);
            m_undoManager->setUndoEnabled(false);
        }
        // TODO: instead of deleting the selection we should use it as the base for custom text
        //inserting mark replace some selected text
        currItem->asTextFrame()->deleteSelectedTextFromFrame();
        if (undoEnabled)
            m_undoManager->setUndoEnabled(true);
    }

    if (trans)
        trans.commit();

jghali

2020-07-20 04:08

administrator   ~0047852

Last edited: 2020-07-20 04:14

>> the problem seems to be that
>> PageItem_TextFrame::deleteSelectedTextFromFrame()
>> has its own transaction...

No, transactions are like groups for undo, they are made so that a transaction can embedded another one.

jghali

2020-07-20 04:38

administrator   ~0047853

The crash when cancelling was simply caused by the fact there was no text layout update after cancelling the dialog. Now that text selection is removed at its proper place, all is well.

Issue History

Date Modified Username Field Change
2020-07-19 08:23 ale New Issue
2020-07-19 12:46 ale Note Added: 0047849
2020-07-19 13:06 ale Note Added: 0047850
2020-07-19 13:16 ale Note Added: 0047851
2020-07-20 04:08 jghali Note Added: 0047852
2020-07-20 04:14 jghali Note Edited: 0047852
2020-07-20 04:38 jghali Assigned To => jghali
2020-07-20 04:38 jghali Status new => resolved
2020-07-20 04:38 jghali Resolution open => fixed
2020-07-20 04:38 jghali Fixed in Version => 1.5.6.svn
2020-07-20 04:38 jghali Note Added: 0047853
2020-08-11 20:56 cbradney Status resolved => closed