View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0009838 | Scribus | Story Editor / Text Frames | public | 2011-03-13 12:52 | 2011-03-21 07:04 |
Reporter | cbradney | Assigned To | jghali | ||
Priority | normal | Severity | crash | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Product Version | 1.4.0svn | ||||
Target Version | 1.4.0 | Fixed in Version | 1.4.0svn | ||
Summary | 0009838: Crash when changing any text setting after entering some new text in a new frame | ||||
Description | (gdb) bt #0 0x00007fff80052616 in __kill () 0000001 0x00007fff800f2cca in abort () 0000002 0x0000000102372515 in qt_message_output () 0000003 0x00000001023726f7 in qt_message () 0000004 0x00000001023728ba in qFatal () 0000005 0x000000010069127c in QList<ScText*>::at (this=0x104112400, i=268) at qlist.h:456 0000006 0x00000001009dc456 in StoryText::text (this=0x10417b8c8, pos=268) at /Users/craig/scribus/PostTrunk/Version135/Scribus/scribus/text/storytext.cpp:487 0000007 0x00000001009e0c8b in StoryText::insert (this=0x7fff5fbfdb60, pos=0, other=@0x10417b8c8, onlySelection=true) at /Users/craig/scribus/PostTrunk/Version135/Scribus/scribus/text/storytext.cpp:200 0000008 0x000000010039aa53 in PageItem::getItemTextSaxed (this=0x10417b600, undoItem=PageItem::SELECTION) at /Users/craig/scribus/PostTrunk/Version135/Scribus/scribus/pageitem.cpp:3944 0000009 0x00000001003f76ba in PageItem_TextFrame::updateUndo (this=0x10417b600, action=PageItem::PARAMSEL, str=@0x7fff5fbfe280) at /Users/craig/scribus/PostTrunk/Version135/Scribus/scribus/pageitem_textframe.cpp:3693 0000010 0x0000000100564cd3 in PropertiesPalette::NewLineSpacing (this=0x1039aac00) at /Users/craig/scribus/PostTrunk/Version135/Scribus/scribus/propertiespalette.cpp:3884 0000011 0x000000010003d37f in PropertiesPalette::qt_metacall (this=0x1039aac00, _c=QMetaObject::InvokeMetaMethod, _id=80, _a=0x7fff5fbfe430) at /Users/craig/scribus/PostTrunk/buildV135/scribus/moc_propertiespalette.cxx:441 0000012 0x00000001023c8996 in QMetaObject::activate () | ||||
Steps To Reproduce | Create text frame, enter text, go straight to change line spacing on PP without clicking on canvas, change line spacing value.. crash | ||||
Tags | No tags attached. | ||||
Patch | |||||
|
Fix for this bug in uploaded file. |
|
9838.patch (1,061 bytes)
Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16448) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -3941,7 +3942,7 @@ HasSel = true; } //is SELECTION - iT.insert(0, itemText, true); + iT.insert(0, itemText, HasSel); if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH { itemText.select(StartOldSel, LenOldSel); Index: Scribus/scribus/pageitem_textframe.cpp =================================================================== --- Scribus/scribus/pageitem_textframe.cpp (wersja 16448) +++ Scribus/scribus/pageitem_textframe.cpp (kopia robocza) @@ -3353,7 +3353,7 @@ LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(CPos)) - StartSel; } itemText.select(StartSel, LenSel); - qDebug() << "ExpandParSel" << StartSel << LenSel; + HasSel = true; } void PageItem_TextFrame::deselectAll() |
|
Not fixed, crash still occurs when cursor is placed after text frame last char and prolly any text setting changed |
|
9838v2.patch (2,856 bytes)
Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16448) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -3096,6 +3096,7 @@ && (ScCLocale::toDoubleC(ScCLocale::toQStringC(oldLocalScY)) == ScCLocale::toDoubleC(ScCLocale::toQStringC(LocalScY)))) return; + if (UndoManager::undoEnabled()) { SimpleState *ss = new SimpleState(Um::ImageScale, @@ -3937,11 +3938,16 @@ } else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel)) { - itemText.select(CPos,1); + if (CPos >= itemText.length()) + { + return ""; + } + else + itemText.select(CPos,1); HasSel = true; } //is SELECTION - iT.insert(0, itemText, true); + iT.insert(0, itemText, HasSel); if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH { itemText.select(StartOldSel, LenOldSel); Index: Scribus/scribus/pageitem_textframe.cpp =================================================================== --- Scribus/scribus/pageitem_textframe.cpp (wersja 16448) +++ Scribus/scribus/pageitem_textframe.cpp (kopia robocza) @@ -3344,16 +3344,16 @@ { //extend selection to whole paragraphs StartSel = itemText.startOfParagraph(itemText.nrOfParagraph(itemText.startOfSelection())); - LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection())) - StartSel; + LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection() -1)) - StartSel; } else { //extend selection to whole paragraph StartSel = itemText.startOfParagraph(itemText.nrOfParagraph(CPos)); - LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(CPos)) - StartSel; + LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(CPos - 1)) - StartSel; } itemText.select(StartSel, LenSel); - qDebug() << "ExpandParSel" << StartSel << LenSel; + HasSel = true; } void PageItem_TextFrame::deselectAll() @@ -3640,6 +3640,12 @@ { if (UndoManager::undoEnabled() && undoManager->undoEnabled()) { + if (CPos >= itemText.length() && itemTextSaxed.isEmpty() && action == PARAMFULL && m_Doc->appMode == modeEdit) + { //case when cursor is after last character without selection and nothing was and will be done + //changes will be ignored + lastUndoAction = PageItem::NOACTION; + return; + } SimpleState* ss; bool newState = true; // indicate when new undoState should be created if (lastUndoAction == action && action != REPSAX && action != DELSAX) |
|
OK, new version of patch for fix undo text crash issues when cursor is at end of text. Apply without first version. |
|
Fix the crash indeed, but it disable undo for paragraph related settings if cursor is set after frame last char. Modifying a paragraph setting will modify last paragraph in this case. |
|
9838v3.patch (9,488 bytes)
Index: Scribus/scribus/pageitem.cpp =================================================================== --- Scribus/scribus/pageitem.cpp (wersja 16448) +++ Scribus/scribus/pageitem.cpp (kopia robocza) @@ -3796,6 +3796,8 @@ { if (!isTextFrame()) return; + itemText.deselectAll(); + HasSel = false; EditAct action = (EditAct) state->getInt("STEXT"); if (action == PARAMFULL || action == PARAMSEL) { @@ -3821,10 +3823,12 @@ else if (action == PARAMSEL) { itemText.deselectAll(); - itemText.select(state->getInt("STEXT_SELSTART"),state->getInt("STEXT_SELLEN")); + int SelStart = state->getInt("STEXT_SELSTART"); + itemText.select(SelStart,state->getInt("STEXT_SELLEN")); asTextFrame()->deleteSelectedTextFromFrame(); - itemText.insert(state->getInt("STEXT_SELSTART"), *story); - itemText.select(state->getInt("STEXT_SELSTART"), story->length()); + assert(SelStart > itemText.length()); + itemText.insert(SelStart, *story); + itemText.select(SelStart, story->length()); HasSel = true; } CPos = itemText.endOfSelection(); @@ -3853,7 +3857,7 @@ dig.addRule("/SCRIBUSTEXT", desaxe::Result<StoryText>()); dig.parseMemory(buffout.toStdString().c_str(), buffout.length()); StoryText* story = dig.result<StoryText>(); - itemText.select(pos,story->length(), true); + itemText.select(pos,story->length()); asTextFrame()->deleteSelectedTextFromFrame(); Serializer dig2(*m_Doc); @@ -3889,6 +3893,7 @@ else { //undo for DELSAX, redo for INSSAX + assert(pos > itemText.length()); itemText.insert(pos, *story); CPos = pos + story->length(); } @@ -3905,6 +3910,7 @@ } else { + assert(pos > itemText.length()); itemText.insertChars(pos, str, true); CPos = pos + str.length(); } @@ -3937,11 +3943,14 @@ } else if (undoItem == CHAR || (undoItem == SELECTION && !HasSel)) { - itemText.select(CPos,1); + if (CPos >= itemText.length()) + return ""; + else + itemText.select(CPos,1); HasSel = true; } //is SELECTION - iT.insert(0, itemText, true); + iT.insert(0, itemText, HasSel); if (LenOldSel > 0) //restoring old selection if undoItem was PARAPGRAPH { itemText.select(StartOldSel, LenOldSel); Index: Scribus/scribus/pageitem_textframe.cpp =================================================================== --- Scribus/scribus/pageitem_textframe.cpp (wersja 16448) +++ Scribus/scribus/pageitem_textframe.cpp (kopia robocza) @@ -3344,16 +3344,16 @@ { //extend selection to whole paragraphs StartSel = itemText.startOfParagraph(itemText.nrOfParagraph(itemText.startOfSelection())); - LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection())) - StartSel; + LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(itemText.endOfSelection() -1)) - StartSel; } else { //extend selection to whole paragraph StartSel = itemText.startOfParagraph(itemText.nrOfParagraph(CPos)); - LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(CPos)) - StartSel; + LenSel = itemText.endOfParagraph(itemText.nrOfParagraph(CPos - 1)) - StartSel; } itemText.select(StartSel, LenSel); - qDebug() << "ExpandParSel" << StartSel << LenSel; + HasSel = true; } void PageItem_TextFrame::deselectAll() @@ -3640,6 +3640,18 @@ { if (UndoManager::undoEnabled() && undoManager->undoEnabled()) { + if (action == PARAMFULL && m_Doc->appMode == modeEdit) + { + //action is for paragraph where cursor is + ExpandParSel(); + action = PARAMSEL; + } + if (CPos >= itemText.length() && itemTextSaxed.isEmpty() && action == PARAMFULL && m_Doc->appMode == modeEdit) + { //case when cursor is after last character without selection and nothing was and will be done + //changes will be ignored + lastUndoAction = PageItem::NOACTION; + return; + } SimpleState* ss; bool newState = true; // indicate when new undoState should be created if (lastUndoAction == action && action != REPSAX && action != DELSAX) @@ -3677,12 +3689,6 @@ } else { - if (action == PARAMFULL && m_Doc->appMode == modeEdit) - { - //action is for paragraph where cursor is - ExpandParSel(); - action = PARAMSEL; - } if (action == PARAMSEL) { ss->set("STEXT_CPOS",CPos); Index: Scribus/scribus/scribus.cpp =================================================================== --- Scribus/scribus/scribus.cpp (wersja 16448) +++ Scribus/scribus/scribus.cpp (kopia robocza) @@ -7004,7 +7004,6 @@ PageItem *currItem = doc->m_Selection->itemAt(0); if (currItem->asTextFrame()) currItem->itemTextSaxed = currItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::SELECTION : PageItem::FRAME); - qDebug() << "setNewFont" << currItem->HasSel; doc->itemSelection_SetFont(nf2); if (currItem->asTextFrame()) currItem->asTextFrame()->updateUndo(currItem->HasSel? PageItem::PARAMSEL : PageItem::PARAMFULL); Index: Scribus/scribus/propertiespalette.cpp =================================================================== --- Scribus/scribus/propertiespalette.cpp (wersja 16448) +++ Scribus/scribus/propertiespalette.cpp (kopia robocza) @@ -2948,9 +2948,31 @@ { if (CurItem->asTextFrame()) { -// CurItem->asTextFrame()->ExpandParSel(); + // hack for save line spacing value + //so during Undo/Redo some old value will be applied + if (doc->appMode == modeEdit) + { + //selected parapgraph(s) only + CurItem->asTextFrame()->ExpandParSel(); + int StartSel = CurItem->itemText.startOfSelection(); + int EndSel = CurItem->itemText.endOfSelection(); + for (uint i = CurItem->itemText.nrOfParagraph(StartSel); i <= CurItem->itemText.nrOfParagraph(EndSel); i++) + { + CurItem->itemText.select(CurItem->itemText.startOfParagraph(i), CurItem->itemText.endOfParagraph(i) - CurItem->itemText.startOfParagraph(i)); + CurItem->HasSel = true; + doc->itemSelection_SetLineSpacingMode(CurItem->itemText.paragraphStyle(CurItem->itemText.startOfParagraph(i)).lineSpacingMode()); + } + } + else + { + //for whole frame + for (uint i = 0; i <= CurItem->itemText.nrOfParagraph(CurItem->itemText.lastInFrame()); i++) + { + CurItem->CPos = CurItem->itemText.startOfParagraph(i); + doc->itemSelection_SetLineSpacingMode(CurItem->itemText.paragraphStyle(CurItem->itemText.startOfParagraph(i)).lineSpacingMode()); + } + } CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); -// CurItem->asTextFrame()->lastAction4Paragraph = true; } doc->itemSelection_SetLineSpacingMode(id); updateStyle(doc->appMode == modeEdit? CurItem->currentStyle() : CurItem->itemText.defaultStyle()); @@ -3875,9 +3897,31 @@ return; if (CurItem->asTextFrame()) { -// CurItem->asTextFrame()->ExpandParSel(); + // hack for save line spacing value + //so during Undo/Redo some old value will be applied + if (doc->appMode == modeEdit) + { + //selected parapgraph(s) only + CurItem->asTextFrame()->ExpandParSel(); + int StartSel = CurItem->itemText.startOfSelection(); + int EndSel = CurItem->itemText.endOfSelection(); + for (uint i = CurItem->itemText.nrOfParagraph(StartSel); i <= CurItem->itemText.nrOfParagraph(EndSel); i++) + { + CurItem->itemText.select(CurItem->itemText.startOfParagraph(i), CurItem->itemText.endOfParagraph(i) - CurItem->itemText.startOfParagraph(i)); + CurItem->HasSel = true; + doc->itemSelection_SetLineSpacing(CurItem->itemText.paragraphStyle(CurItem->itemText.startOfParagraph(i)).lineSpacing()); + } + } + else + { + //for whole frame + for (uint i = 0; i <= CurItem->itemText.nrOfParagraph(CurItem->itemText.lastInFrame()); i++) + { + CurItem->CPos = CurItem->itemText.startOfParagraph(i); + doc->itemSelection_SetLineSpacing(CurItem->itemText.paragraphStyle(CurItem->itemText.startOfParagraph(i)).lineSpacing()); + } + } CurItem->itemTextSaxed = CurItem->getItemTextSaxed(doc->appMode == modeEdit? PageItem::PARAGRAPH : PageItem::FRAME); -// CurItem->asTextFrame()->lastAction4Paragraph = true; } doc->itemSelection_SetLineSpacing(LineSp->value()); if (CurItem->asTextFrame()) @@ -4276,7 +4320,7 @@ void PropertiesPalette::NewAlignement(int a) { - int StartSel = 0, EndSel = 0, LenSel = 0; + int StartSel = 0, EndSel = 0; if (!HaveDoc || !HaveItem || !m_ScMW || m_ScMW->scriptIsRunning()) return; if (CurItem->asTextFrame()) |
|
Another version of patch for fixing some text undo issues. Not only crashes, but also better undo/redo for line spacing. Also some code cleanup. Please test it. |
|
I commited the patch except the PP related changes which i still need to test. I discovered an issue related to undo in empty paragraph, but i consider this is another issue and will open another issue for that |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-03-13 12:52 | cbradney | New Issue | |
2011-03-13 13:01 | cbradney | Steps to Reproduce Updated | |
2011-03-17 08:12 | cezaryece | Note Added: 0025825 | |
2011-03-17 08:12 | cezaryece | File Added: 9838.patch | |
2011-03-17 08:50 | cbradney | Status | new => resolved |
2011-03-17 08:50 | cbradney | Fixed in Version | => 1.4.0svn |
2011-03-17 08:50 | cbradney | Resolution | open => fixed |
2011-03-17 08:50 | cbradney | Assigned To | => cbradney |
2011-03-17 12:59 | jghali | Note Added: 0025829 | |
2011-03-17 12:59 | jghali | Status | resolved => feedback |
2011-03-17 12:59 | jghali | Resolution | fixed => reopened |
2011-03-17 14:40 | cezaryece | File Added: 9838v2.patch | |
2011-03-17 14:42 | cezaryece | Note Added: 0025831 | |
2011-03-17 14:43 | cezaryece | Note Edited: 0025831 | |
2011-03-17 22:51 | jghali | Note Added: 0025844 | |
2011-03-18 14:18 | cezaryece | File Added: 9838v3.patch | |
2011-03-18 14:20 | cezaryece | Note Added: 0025848 | |
2011-03-19 11:51 | jghali | Summary | Crash when going to set line spacing after entering some new text in a new frame in a new doc => Crash when changing any text setting after entering some new text in a new frame |
2011-03-19 11:52 | jghali | Relationship added | has duplicate 0009854 |
2011-03-19 23:18 | jghali | Note Added: 0025853 | |
2011-03-19 23:18 | jghali | Status | feedback => resolved |
2011-03-19 23:18 | jghali | Resolution | reopened => fixed |
2011-03-19 23:18 | jghali | Assigned To | cbradney => jghali |
2011-03-21 07:04 | cbradney | Status | resolved => closed |
2015-09-17 20:08 | Kunda | Category | Story Editor / Text Frames => Story Ed/Txt Frames |
2015-09-17 20:12 | Kunda | Category | Story Ed/Txt Frames => Story Editor / Text Frames |