r17759 by jghali - #11039: crash when deleting text

scribus-commit scribus-commit at lists.scribus.net
Mon Aug 20 18:10:16 UTC 2012


Author: jghali
Date: Mon Aug 20 18:10:16 2012
New Revision: 17759

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17759
Log:
#11039: crash when deleting text

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17759&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Mon Aug 20 18:10:16 2012
@@ -4015,46 +4015,46 @@
 			for (int i=start; i <= stop; ++i)
 			{
 				const CharStyle& curParent(itemText.charStyle(i));
-				if (!curParent.equiv(lastParent) || i==stop)
-					{
-						added = false;
-						lastIsDelete = false;
-						if(is && dynamic_cast<ScItemState<CharStyle>*>(ts->at(0))->get("ETEA") == "delete_frametext" && lastPos<is->getInt("START"))
-						{
-							if(is->getItem().equiv(lastParent))
-							{
-								is->set("START",start);
-								is->set("TEXT_STR",itemText.text(lastPos,i - lastPos) + is->get("TEXT_STR"));
-								added = true;
-							}
-							lastIsDelete = true;
-						}
-						else if(is && dynamic_cast<ScItemState<CharStyle>*>(ts->at(0))->get("ETEA") == "delete_frametext"  && lastPos>=is->getInt("START"))
-						{
-							if(is && is->getItem().equiv(lastParent)){
-								is->set("TEXT_STR",is->get("TEXT_STR") + itemText.text(lastPos,i - lastPos));
-								added = true;
-							}
-							lastIsDelete = true;
-						}
-						if(!added)
-						{
-							is = new ScItemState<CharStyle>(Um::DeleteText,"",Um::IDelete);
-							is->set("DELETE_FRAMETEXT", "delete_frametext");
-							is->set("ETEA", QString("delete_frametext"));
-							is->set("TEXT_STR",itemText.text(lastPos,i - lastPos));
-							is->set("START", start);
-							is->setItem(lastParent);
-							if(!ts || !lastIsDelete){
-								undoManager->action(this, is);
-								ts = NULL;
-							}
-							else
-								ts->pushBack(this,is);
-						}
-						lastPos = i;
-						lastParent = curParent;
-					}
+				if (curParent.equiv(lastParent) && i != stop)
+					continue;
+
+				added = false;
+				lastIsDelete = false;
+				if (is && ts && dynamic_cast<ScItemState<CharStyle>*>(ts->at(0))->get("ETEA") == "delete_frametext" && lastPos<is->getInt("START"))
+				{
+					if (is->getItem().equiv(lastParent))
+					{
+						is->set("START",start);
+						is->set("TEXT_STR",itemText.text(lastPos,i - lastPos) + is->get("TEXT_STR"));
+						added = true;
+					}
+					lastIsDelete = true;
+				}
+				else if (is && ts && dynamic_cast<ScItemState<CharStyle>*>(ts->at(0))->get("ETEA") == "delete_frametext"  && lastPos>=is->getInt("START"))
+				{
+					if (is->getItem().equiv(lastParent)){
+						is->set("TEXT_STR",is->get("TEXT_STR") + itemText.text(lastPos,i - lastPos));
+						added = true;
+					}
+					lastIsDelete = true;
+				}
+				if (!added)
+				{
+					is = new ScItemState<CharStyle>(Um::DeleteText,"",Um::IDelete);
+					is->set("DELETE_FRAMETEXT", "delete_frametext");
+					is->set("ETEA", QString("delete_frametext"));
+					is->set("TEXT_STR",itemText.text(lastPos,i - lastPos));
+					is->set("START", start);
+					is->setItem(lastParent);
+					if(!ts || !lastIsDelete){
+						undoManager->action(this, is);
+						ts = NULL;
+					}
+					else
+						ts->pushBack(this,is);
+				}
+				lastPos = i;
+				lastParent = curParent;
 			}
 			trans.commit();
 		}




More information about the scribus-commit mailing list