r18045 by fschmid - Fixed Bug #11331: crash on deleting inline frame in special edit mode

scribus-commit scribus-commit at lists.scribus.net
Sat Jan 5 08:38:47 UTC 2013


Author: fschmid
Date: Sat Jan  5 08:38:47 2013
New Revision: 18045

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18045
Log:
Fixed Bug #11331: crash on deleting inline frame in special edit mode

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18045&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Jan  5 08:38:47 2013
@@ -6569,87 +6569,91 @@
 	}
 	else
 	{
-		PageItem* currItem = Items->at(0);
 		ScPage* addedPage = TempPages.at(0);
-		if (Items->count() > 1)
-		{
-			if ((!currItem->isGroup()) && (Items->count() > 1))
-			{
-				itemAdd(PageItem::Group, PageItem::Rectangle, addedPage->xOffset(), addedPage->yOffset(), 10, 10, 0, CommonStrings::None, CommonStrings::None, true);
-				PageItem *groupItem = Items->takeLast();
-				groupItem->setLayer(0);
-				Items->insert(0, groupItem);
-				double minx =  std::numeric_limits<double>::max();
-				double miny =  std::numeric_limits<double>::max();
-				double maxx = -std::numeric_limits<double>::max();
-				double maxy = -std::numeric_limits<double>::max();
-				for (int as = 1; as < Items->count(); ++as)
+		if (Items->count() == 0)
+		{
+			docPatterns.remove(currentEditedSymbol);
+		}
+		else
+		{
+			PageItem* currItem = Items->at(0);
+			if (Items->count() > 1)
+			{
+				if ((!currItem->isGroup()) && (Items->count() > 1))
 				{
-					PageItem* currItem = Items->at(as);
-					groupItem->groupItemList.append(currItem);
-					double x1, x2, y1, y2;
-					currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
-					minx = qMin(minx, x1);
-					miny = qMin(miny, y1);
-					maxx = qMax(maxx, x2);
-					maxy = qMax(maxy, y2);
+					itemAdd(PageItem::Group, PageItem::Rectangle, addedPage->xOffset(), addedPage->yOffset(), 10, 10, 0, CommonStrings::None, CommonStrings::None, true);
+					PageItem *groupItem = Items->takeLast();
+					groupItem->setLayer(0);
+					Items->insert(0, groupItem);
+					double minx =  std::numeric_limits<double>::max();
+					double miny =  std::numeric_limits<double>::max();
+					double maxx = -std::numeric_limits<double>::max();
+					double maxy = -std::numeric_limits<double>::max();
+					for (int as = 1; as < Items->count(); ++as)
+					{
+						PageItem* currItem = Items->at(as);
+						groupItem->groupItemList.append(currItem);
+						double x1, x2, y1, y2;
+						currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
+						minx = qMin(minx, x1);
+						miny = qMin(miny, y1);
+						maxx = qMax(maxx, x2);
+						maxy = qMax(maxy, y2);
+					}
+					Items->clear();
+					Items->append(groupItem);
+					for (int em = 0; em < groupItem->groupItemList.count(); ++em)
+					{
+						PageItem* currItem = groupItem->groupItemList.at(em);
+						currItem->gXpos = currItem->xPos() - minx;
+						currItem->gYpos = currItem->yPos() - miny;
+						currItem->gWidth = maxx - minx;
+						currItem->gHeight = maxy - miny;
+					}
+					groupItem->setXYPos(minx, miny, true);
+					groupItem->setWidthHeight(maxx - minx, maxy - miny, true);
+					groupItem->groupWidth = maxx - minx;
+					groupItem->groupHeight = maxy - miny;
+					groupItem->gWidth = maxx - minx;
+					groupItem->gHeight = maxy - miny;
+					groupItem->SetRectFrame();
+					groupItem->ClipEdited = true;
+					groupItem->FrameType = 3;
+					groupItem->setTextFlowMode(PageItem::TextFlowDisabled);
+					groupItem->AutoName = false;
+					groupItem->setFillTransparency(0);
+					groupItem->setLineTransparency(0);
+					groupItem->asGroupFrame()->adjustXYPosition();
+					GroupCounter++;
 				}
-				Items->clear();
-				Items->append(groupItem);
-				for (int em = 0; em < groupItem->groupItemList.count(); ++em)
-				{
-					PageItem* currItem = groupItem->groupItemList.at(em);
-					currItem->gXpos = currItem->xPos() - minx;
-					currItem->gYpos = currItem->yPos() - miny;
-					currItem->gWidth = maxx - minx;
-					currItem->gHeight = maxy - miny;
-				}
-				groupItem->setXYPos(minx, miny, true);
-				groupItem->setWidthHeight(maxx - minx, maxy - miny, true);
-				groupItem->groupWidth = maxx - minx;
-				groupItem->groupHeight = maxy - miny;
-				groupItem->gWidth = maxx - minx;
-				groupItem->gHeight = maxy - miny;
-				groupItem->SetRectFrame();
-				groupItem->ClipEdited = true;
-				groupItem->FrameType = 3;
-				groupItem->setTextFlowMode(PageItem::TextFlowDisabled);
-				groupItem->AutoName = false;
-				groupItem->setFillTransparency(0);
-				groupItem->setLineTransparency(0);
-				groupItem->asGroupFrame()->adjustXYPosition();
-				GroupCounter++;
-			}
-		}
-		currItem = Items->at(0);
-		double minx =  std::numeric_limits<double>::max();
-		double miny =  std::numeric_limits<double>::max();
-		double maxx = -std::numeric_limits<double>::max();
-		double maxy = -std::numeric_limits<double>::max();
-		double x1, x2, y1, y2;
-		currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
-		minx = qMin(minx, x1);
-		miny = qMin(miny, y1);
-		maxx = qMax(maxx, x2);
-		maxy = qMax(maxy, y2);
-		currItem->gXpos = currItem->xPos() - minx;
-		currItem->gYpos = currItem->yPos() - miny;
-		currItem->setXYPos(currItem->gXpos, currItem->gYpos, true);
-		docPatterns[currentEditedSymbol].pattern = currItem->DrawObj_toImage(qMax(maxx - minx, maxy - miny));
-		docPatterns[currentEditedSymbol].width = maxx - minx;
-		docPatterns[currentEditedSymbol].height = maxy - miny;
+			}
+			currItem = Items->at(0);
+			double minx =  std::numeric_limits<double>::max();
+			double miny =  std::numeric_limits<double>::max();
+			double maxx = -std::numeric_limits<double>::max();
+			double maxy = -std::numeric_limits<double>::max();
+			double x1, x2, y1, y2;
+			currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
+			minx = qMin(minx, x1);
+			miny = qMin(miny, y1);
+			maxx = qMax(maxx, x2);
+			maxy = qMax(maxy, y2);
+			currItem->gXpos = currItem->xPos() - minx;
+			currItem->gYpos = currItem->yPos() - miny;
+			currItem->setXYPos(currItem->gXpos, currItem->gYpos, true);
+			docPatterns[currentEditedSymbol].pattern = currItem->DrawObj_toImage(qMax(maxx - minx, maxy - miny));
+			docPatterns[currentEditedSymbol].width = maxx - minx;
+			docPatterns[currentEditedSymbol].height = maxy - miny;
+		}
 		if (m_ScMW->patternsDependingOnThis.count() > 1)
 		{
 			for (int a = 1; a < m_ScMW->patternsDependingOnThis.count(); a++)
 			{
 				Items = &docPatterns[m_ScMW->patternsDependingOnThis[a]].items;
-				currItem = Items->at(0);
+				PageItem *currItem = Items->at(0);
+				double x1, x2, y1, y2;
 				currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
-				minx = qMin(minx, x1);
-				miny = qMin(miny, y1);
-				maxx = qMax(maxx, x2);
-				maxy = qMax(maxy, y2);
-				docPatterns[m_ScMW->patternsDependingOnThis[a]].pattern = currItem->DrawObj_toImage(qMax(maxx - minx, maxy - miny));
+				docPatterns[m_ScMW->patternsDependingOnThis[a]].pattern = currItem->DrawObj_toImage(qMax(x2 - x1, y2 - y1));
 			}
 		}
 		if (masterPageMode())
@@ -6720,77 +6724,84 @@
 	}
 	else
 	{
-		PageItem* currItem = Items->at(0);
 		ScPage* addedPage = TempPages.at(0);
-		if (Items->count() > 1)
-		{
-			if ((!currItem->isGroup()) && (Items->count() > 1))
-			{
-				itemAdd(PageItem::Group, PageItem::Rectangle, addedPage->xOffset(), addedPage->yOffset(), 10, 10, 0, CommonStrings::None, CommonStrings::None, true);
-				PageItem *groupItem = Items->takeLast();
-				groupItem->setLayer(0);
-				Items->insert(0, groupItem);
-				double minx =  std::numeric_limits<double>::max();
-				double miny =  std::numeric_limits<double>::max();
-				double maxx = -std::numeric_limits<double>::max();
-				double maxy = -std::numeric_limits<double>::max();
-				for (int as = 1; as < Items->count(); ++as)
+		if (Items->count() == 0)
+		{
+			removeInlineFrame(currentEditedIFrame);
+		}
+		else
+		{
+			PageItem* currItem = Items->at(0);
+			if (Items->count() > 1)
+			{
+				if ((!currItem->isGroup()) && (Items->count() > 1))
 				{
-					PageItem* currItem = Items->at(as);
-					groupItem->groupItemList.append(currItem);
-					double x1, x2, y1, y2;
-					currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
-					minx = qMin(minx, x1);
-					miny = qMin(miny, y1);
-					maxx = qMax(maxx, x2);
-					maxy = qMax(maxy, y2);
+					itemAdd(PageItem::Group, PageItem::Rectangle, addedPage->xOffset(), addedPage->yOffset(), 10, 10, 0, CommonStrings::None, CommonStrings::None, true);
+					PageItem *groupItem = Items->takeLast();
+					groupItem->setLayer(0);
+					Items->insert(0, groupItem);
+					double minx =  std::numeric_limits<double>::max();
+					double miny =  std::numeric_limits<double>::max();
+					double maxx = -std::numeric_limits<double>::max();
+					double maxy = -std::numeric_limits<double>::max();
+					for (int as = 1; as < Items->count(); ++as)
+					{
+						PageItem* currItem = Items->at(as);
+						groupItem->groupItemList.append(currItem);
+						double x1, x2, y1, y2;
+						currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
+						minx = qMin(minx, x1);
+						miny = qMin(miny, y1);
+						maxx = qMax(maxx, x2);
+						maxy = qMax(maxy, y2);
+					}
+					Items->clear();
+					Items->append(groupItem);
+					for (int em = 0; em < groupItem->groupItemList.count(); ++em)
+					{
+						PageItem* currItem = groupItem->groupItemList.at(em);
+						currItem->gXpos = currItem->xPos() - minx;
+						currItem->gYpos = currItem->yPos() - miny;
+						currItem->gWidth = maxx - minx;
+						currItem->gHeight = maxy - miny;
+					}
+					groupItem->setXYPos(minx, miny, true);
+					groupItem->setWidthHeight(maxx - minx, maxy - miny, true);
+					groupItem->groupWidth = maxx - minx;
+					groupItem->groupHeight = maxy - miny;
+					groupItem->gWidth = maxx - minx;
+					groupItem->gHeight = maxy - miny;
+					groupItem->SetRectFrame();
+					groupItem->ClipEdited = true;
+					groupItem->FrameType = 3;
+					groupItem->setTextFlowMode(PageItem::TextFlowDisabled);
+					groupItem->AutoName = false;
+					groupItem->setFillTransparency(0);
+					groupItem->setLineTransparency(0);
+					groupItem->asGroupFrame()->adjustXYPosition();
+					GroupCounter++;
 				}
-				Items->clear();
-				Items->append(groupItem);
-				for (int em = 0; em < groupItem->groupItemList.count(); ++em)
-				{
-					PageItem* currItem = groupItem->groupItemList.at(em);
-					currItem->gXpos = currItem->xPos() - minx;
-					currItem->gYpos = currItem->yPos() - miny;
-					currItem->gWidth = maxx - minx;
-					currItem->gHeight = maxy - miny;
-				}
-				groupItem->setXYPos(minx, miny, true);
-				groupItem->setWidthHeight(maxx - minx, maxy - miny, true);
-				groupItem->groupWidth = maxx - minx;
-				groupItem->groupHeight = maxy - miny;
-				groupItem->gWidth = maxx - minx;
-				groupItem->gHeight = maxy - miny;
-				groupItem->SetRectFrame();
-				groupItem->ClipEdited = true;
-				groupItem->FrameType = 3;
-				groupItem->setTextFlowMode(PageItem::TextFlowDisabled);
-				groupItem->AutoName = false;
-				groupItem->setFillTransparency(0);
-				groupItem->setLineTransparency(0);
-				groupItem->asGroupFrame()->adjustXYPosition();
-				GroupCounter++;
-			}
-		}
-		currItem = Items->at(0);
-		double minx =  std::numeric_limits<double>::max();
-		double miny =  std::numeric_limits<double>::max();
-		double maxx = -std::numeric_limits<double>::max();
-		double maxy = -std::numeric_limits<double>::max();
-		double x1, x2, y1, y2;
-		currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
-		minx = qMin(minx, x1);
-		miny = qMin(miny, y1);
-		maxx = qMax(maxx, x2);
-		maxy = qMax(maxy, y2);
-		currItem->gXpos = currItem->xPos() - minx;
-		currItem->gYpos = currItem->yPos() - miny;
-		currItem->gWidth = maxx - minx;
-		currItem->gHeight = maxy - miny;
-		currItem->setXYPos(currItem->gXpos, currItem->gYpos, true);
-		currItem->isEmbedded = true;
-		currItem->inlineCharID = currentEditedIFrame;
-		FrameItems[currentEditedIFrame] = currItem;
+			}
+			currItem = Items->at(0);
+			double minx =  std::numeric_limits<double>::max();
+			double miny =  std::numeric_limits<double>::max();
+			double maxx = -std::numeric_limits<double>::max();
+			double maxy = -std::numeric_limits<double>::max();
+			double x1, x2, y1, y2;
+			currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
+			minx = qMin(minx, x1);
+			miny = qMin(miny, y1);
+			maxx = qMax(maxx, x2);
+			maxy = qMax(maxy, y2);
+			currItem->gXpos = currItem->xPos() - minx;
+			currItem->gYpos = currItem->yPos() - miny;
+			currItem->gWidth = maxx - minx;
+			currItem->gHeight = maxy - miny;
+			currItem->setXYPos(currItem->gXpos, currItem->gYpos, true);
+			currItem->isEmbedded = true;
+			currItem->inlineCharID = currentEditedIFrame;
+			FrameItems[currentEditedIFrame] = currItem;
+		}
 		if (masterPageMode())
 		{
 			Pages = &MasterPages;




More information about the scribus-commit mailing list