r16177 by fschmid - Fixed crash when selecting shapes to import with preview option switched on.

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 28 13:51:51 CET 2010


Author: fschmid
Date: Tue Dec 28 12:51:51 2010
New Revision: 16177

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16177
Log:
Fixed crash when selecting shapes to import with preview option switched on.

Modified:
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/scribusview.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Tue Dec 28 12:51:51 2010
@@ -1687,7 +1687,6 @@
 
 void PageItem::DrawObj_Decoration(ScPainter *p)
 {
-	ScribusView* view = m_Doc->view();
 	p->save();
 	if (!isEmbedded)
 		p->translate(Xpos, Ypos);
@@ -1695,7 +1694,7 @@
 	if ((!isEmbedded) && (!m_Doc->RePos))
 	{
 		double aestheticFactor(5.0);
-		double scpInv = 1.0 / (qMax(view->scale(), 1.0) * aestheticFactor);
+		double scpInv = 1.0 / (qMax(p->zoomFactor(), 1.0) * aestheticFactor);
 		if (!isGroup())
 		{
 			if ((Frame) && (m_Doc->guidesPrefs().framesShown) && ((itemType() == ImageFrame) || (itemType() == LatexFrame) || (itemType() == OSGFrame) || (itemType() == PathText)))
@@ -1743,7 +1742,7 @@
 		}
 		if ((m_Doc->guidesPrefs().framesShown) && textFlowUsesContourLine() && (ContourLine.size() != 0))
 		{
-			p->setPen(Qt::darkGray, 1.0 / qMax(view->scale(), 1.0), Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
+			p->setPen(Qt::darkGray, 1.0 / qMax(p->zoomFactor(), 1.0), Qt::DotLine, Qt::FlatCap, Qt::MiterJoin);
 // Ugly Hack to fix rendering problems with cairo >=1.5.10 && <1.8.0 follows
 #ifdef HAVE_CAIRO
 	#if ((CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 10)) && (CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 8, 0)))
@@ -1765,7 +1764,7 @@
 				|| ((72.0 / imageYScale()) < minres) 
 				|| ((72.0 / imageXScale()) > maxres) 
 				|| ((72.0 / imageYScale()) > maxres)) 
-				&& (isRaster) && (checkres) && (!view->m_canvas->isPreviewMode()) && (PrefsManager::instance()->appPrefs.displayPrefs.showVerifierWarningsOnCanvas))
+				&& (isRaster) && (checkres) && (!m_Doc->drawAsPreview) && (PrefsManager::instance()->appPrefs.displayPrefs.showVerifierWarningsOnCanvas))
 			{
 				double ofx = Width - 22.0;
 				double ofy = Height - 22.0;
@@ -1776,9 +1775,9 @@
 				p->restore();
 			}
 		}
-		if ((m_Doc->guidesPrefs().layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerID)) && (isGroup()) && (!view->m_canvas->isPreviewMode()))
-		{
-			p->setPen(Qt::black, 0.5/ m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		if ((m_Doc->guidesPrefs().layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerID)) && (isGroup()) && (!m_Doc->drawAsPreview))
+		{
+			p->setPen(Qt::black, 0.5/ p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 			p->setPenOpacity(1.0);
 			p->setBrush(m_Doc->layerMarker(LayerID));
 			p->setBrushOpacity(1.0);
@@ -1976,121 +1975,11 @@
 			embedded->isEmbedded = false;
 			p->restore();
 		}
-//		p->drawImage(pat.getPattern());
 		p->setWorldMatrix(savWM);
 		xpos += adv;
 		p->restore();
 	}
 	p->newPath();
-}
-
-void PageItem::paintObj(QPainter *p)
-{
-	if ((!m_Doc->DoDrawing) || (m_Doc->RePos))
-	{
-		FrameOnly = false;
-		return;
-	}
-	double sc = m_Doc->view()->scale();
-	double handleSize = 6.0 / sc;
-	double halfSize = 3.0 / sc;
-	if ((!FrameOnly) && (!m_Doc->RePos))
-	{
-		if (!m_Doc->m_Selection->isEmpty())
-		{
-//				qDebug() << "Item: " << ItemNr << "W: " << Width << "H: " << Height;
-			if (!isGroup())
-			{
-				//Locked line colour selection
-				if (m_Locked)
-					p->setPen(QPen(PrefsManager::instance()->appPrefs.displayPrefs.frameLockColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-				else
-					p->setPen(QPen(PrefsManager::instance()->appPrefs.displayPrefs.frameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-				p->setBrush(Qt::NoBrush);
-				double lw2 = 1.0 / sc;
-				double lw = 1.0 / sc;
-				Qt::PenCapStyle le = Qt::FlatCap;
-				if (NamedLStyle.isEmpty())
-				{
-					lw2 = (m_lineWidth / 2.0)  / sc;
-					lw = qMax(m_lineWidth, 1.0)  / sc;
-					le = PLineEnd;
-				}
-				else
-				{
-					multiLine ml = m_Doc->MLineStyles[NamedLStyle];
-					lw2 = (ml[ml.size()-1].Width / 2.0) / sc;
-					lw = qMax(ml[ml.size()-1].Width, 1.0) / sc;
-					le = static_cast<Qt::PenCapStyle>(ml[ml.size()-1].LineEnd);
-				}
-				//Draw our frame outline
-				if (asLine())
-				{
-					if (le != Qt::FlatCap)
-						p->drawRect(QRectF(-lw2, -lw2, Width+lw, lw));
-					else
-						p->drawRect(QRectF(-1 / sc, -lw2, Width, lw));
-				}
-				else
-					p->drawRect(QRectF(0, 0, Width, Height));
-//				p->setPen(QPen(PrefsManager::instance()->appPrefs.drameColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-				p->setBrush(PrefsManager::instance()->appPrefs.displayPrefs.frameColor);
-				p->setPen(Qt::NoPen);
-				if ((!m_Locked) && (!m_SizeLocked))
-				{
-					if (! asLine())
-					{
-						p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
-						p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
-						p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
-						p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
-						if (Width > 6)
-						{
-							p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
-							p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
-						}
-						if (Height > 6)
-						{
-							p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
-							p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
-						}
-					}
-					else
-					{
-						p->drawRect(QRectF(-halfSize, -halfSize, handleSize, handleSize));
-						p->drawRect(QRectF(Width + halfSize, -halfSize, -handleSize, handleSize));
-					}
-				}
-			}
-			else
-			{
-				p->setPen(QPen(PrefsManager::instance()->appPrefs.displayPrefs.frameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-				p->setBrush(Qt::NoBrush);
-				p->drawRect(QRectF(0.0, 0.0, Width, Height));
-				if (m_Doc->m_Selection->count() == 1)
-				{
-					p->setPen(Qt::NoPen);
-//					p->setPen(QPen(PrefsManager::instance()->appPrefs.frameGroupColor, 1.0 / sc, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-					p->setBrush(PrefsManager::instance()->appPrefs.displayPrefs.frameGroupColor);
-					p->drawRect(QRectF(0.0, 0.0, handleSize, handleSize));
-					p->drawRect(QRectF(Width - handleSize, Height - handleSize, handleSize, handleSize));
-					p->drawRect(QRectF(Width - handleSize, 0.0, handleSize, handleSize));
-					p->drawRect(QRectF(0.0, Height - handleSize, handleSize, handleSize));
-					if (Width > 6)
-					{
-						p->drawRect(QRectF(Width / 2.0 - halfSize, Height - handleSize, handleSize, handleSize));
-						p->drawRect(QRectF(Width / 2.0 - halfSize, 0.0, handleSize, handleSize));
-					}
-					if (Height > 6)
-					{
-						p->drawRect(QRectF(Width - handleSize, Height / 2.0 - halfSize, handleSize, handleSize));
-						p->drawRect(QRectF(0.0, Height / 2.0 - halfSize, handleSize, handleSize));
-					}
-				}
-			}
-		}
-	}
-	FrameOnly = false;
 }
 
 QImage PageItem::DrawObj_toImage()
@@ -5965,7 +5854,7 @@
 void PageItem::drawLockedMarker(ScPainter *p)
 {
 	//TODO: CB clean
-	double scp1 = 1 ;// / ScMW->view->scale();
+	double scp1 = p->zoomFactor() ;// / ScMW->view->scale();
 	double ofwh = 6 * scp1;
 	double ofx = Width - ofwh/2;
 	double ofy = Height - ofwh*1.5;
@@ -5973,8 +5862,7 @@
 	double by1= ofy+3 * scp1;
 	double bw= 4*scp1;
 	double bh= 2*scp1;
-	ScribusView* view = m_Doc->view();
-	p->setPen(Qt::black, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	p->setPen(Qt::black, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	p->setPenOpacity(1.0);
 	p->setBrush(Qt::white);
 	p->setBrushOpacity(1.0);
@@ -5982,7 +5870,7 @@
 	p->drawRect(ofx, ofy, ofwh, ofwh);
 	p->setBrush(Qt::black);
 	p->drawRect(bx1, by1, bw, bh);
-	p->setPen(Qt::black, 1.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
+	p->setPen(Qt::black, 1.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::RoundJoin);
 	if (m_Locked)
 		p->drawLine(FPoint(bx1+scp1/2, ofy+scp1), FPoint(bx1+scp1/2, by1));
 	p->drawLine(FPoint(bx1+scp1*3.5, ofy+scp1), FPoint(bx1+scp1*3.5, by1));

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Tue Dec 28 12:51:51 2010
@@ -275,7 +275,6 @@
 	virtual bool createInfoGroup(QFrame *, QGridLayout *) {return false;}
 	
   /** Zeichnet das Item */
-	void paintObj(QPainter *p);
 	void DrawObj(ScPainter *p, QRectF e);
 	void DrawObj_Pre(ScPainter *p);
 	virtual void DrawObj_Post(ScPainter *p);

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Tue Dec 28 12:51:51 2010
@@ -2686,7 +2686,6 @@
 
 void PageItem_TextFrame::DrawObj_Decoration(ScPainter *p)
 {
-	ScribusView* view = m_Doc->view();
 	p->save();
 	if (!isEmbedded)
 		p->translate(Xpos, Ypos);
@@ -2695,7 +2694,7 @@
 	{
 		// added to prevent fat frame outline due to antialiasing and considering you can’t pass a cosmetic pen to scpainter - pm
 		double aestheticFactor(5.0);
-		double scpInv = 1.0 / (qMax(view->scale(), 1.0) * aestheticFactor);
+		double scpInv = 1.0 / (qMax(p->zoomFactor(), 1.0) * aestheticFactor);
 		if ((Frame) && (m_Doc->guidesPrefs().framesShown))
 		{
 			p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameNormColor, scpInv, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
@@ -2738,14 +2737,14 @@
 		//Draw the overflow icon
 		if (frameOverflows())
 		{//CB && added here for jghali prior to commit access
-			if ((!view->m_canvas->isPreviewMode()))
+			if ((!m_Doc->drawAsPreview))
 				drawOverflowMarker(p);
 		}
-		if ((m_Doc->guidesPrefs().colBordersShown) && (!view->m_canvas->isPreviewMode()))
+		if ((m_Doc->guidesPrefs().colBordersShown) && (!m_Doc->drawAsPreview))
 			drawColumnBorders(p);
-		if ((m_Doc->guidesPrefs().layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerID)) && (!view->m_canvas->isPreviewMode()))
-		{
-			p->setPen(Qt::black, 0.5/ m_Doc->view()->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		if ((m_Doc->guidesPrefs().layerMarkersShown) && (m_Doc->layerCount() > 1) && (!m_Doc->layerOutline(LayerID)) && (!m_Doc->drawAsPreview))
+		{
+			p->setPen(Qt::black, 0.5/ p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 			p->setPenOpacity(1.0);
 			p->setBrush(m_Doc->layerMarker(LayerID));
 			p->setBrushOpacity(1.0);
@@ -3472,8 +3471,7 @@
 	p->drawLine(FPoint(scm_lineWidth16, scpheight3), FPoint(scm_lineWidth3, scpheight16));
 	*/
 	//TODO: CB clean
-	ScribusView* view = m_Doc->view();
-	double scp1 = 1 ;// / ScMW->view->scale();
+	double scp1 = p->zoomFactor() ;// / ScMW->view->scale();
 	double ofwh = 8 * scp1;
 	//CB moved down while locked marker disabled
 	//double ofx = Width - ofwh/2;
@@ -3484,15 +3482,15 @@
 	double ly1= ofy;
 	double lx2= ofx+ofwh;
 	double ly2= ofy+ofwh;
-	p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameNormColor, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameNormColor, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	if ((isBookmark) || (m_isAnnotation))
-		p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameAnnotationColor, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameAnnotationColor, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	if ((BackBox != 0) || (NextBox != 0))
-		p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameLinkColor, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameLinkColor, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	if (m_Locked)
-		p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameLockColor, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		p->setPen(PrefsManager::instance()->appPrefs.displayPrefs.frameLockColor, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	if (m_Doc->m_Selection->containsItem(this))
-		p->setPen(Qt::red, 0.5 / view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		p->setPen(Qt::red, 0.5 / p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	p->setPenOpacity(1.0);
 	p->setBrush(Qt::white);
 	p->setBrushOpacity(1.0);
@@ -3504,8 +3502,7 @@
 
 void PageItem_TextFrame::drawColumnBorders(ScPainter *p)
 {
-	ScribusView* view = m_Doc->view();
-	p->setPen(Qt::black, 0.5/ view->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	p->setPen(Qt::black, 0.5/ p->zoomFactor(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
 	p->setPenOpacity(1.0);
 	p->setBrush(Qt::white);
 	p->setBrushOpacity(1.0);

Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdtext.cpp Tue Dec 28 12:51:51 2010
@@ -310,7 +310,6 @@
 	if (ScCore->primaryMainWindow()->doc->DoDrawing)
 	{
 // FIXME adapt to Qt-4 painting style
-//		it->paintObj();
 		it->Dirty = false;
 	}
 //	Py_INCREF(Py_None);

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Dec 28 12:51:51 2010
@@ -243,6 +243,7 @@
 	docPrefsData.pdfPrefs.bleeds = docPrefsData.docSetupPrefs.bleeds;
 	docPrefsData.pdfPrefs.useDocBleeds = true;
 	Print_Options.firstUse = true;
+	drawAsPreview = false;
 }
 
 
@@ -333,6 +334,7 @@
 	docPrefsData.docSetupPrefs.pageOrientation=pagesSetup.orientation;
 	docPrefsData.docSetupPrefs.pagePositioning=pagesSetup.pageArrangement;
 	Print_Options.firstUse = true;
+	drawAsPreview = false;
 }
 
 
@@ -7175,11 +7177,6 @@
 		ma.scale(-1, 1);
 		currItem->ContourLine.map(ma);
 		regionsChanged()->update(QRectF());
-//		currItem->Tinput = true;
-//		currItem->FrameOnly = true;
-//		currItem->paintObj();
-//		currItem->FrameOnly = false;
-//		m_View->MarkClip(currItem, currItem->ContourLine, true);
 		changed();
 		return;
 	}
@@ -7224,11 +7221,6 @@
 		ma.scale(1, -1);
 		currItem->ContourLine.map(ma);
 		regionsChanged()->update(QRectF());
-//		currItem->Tinput = true;
-//		currItem->FrameOnly = true;
-//		currItem->paintObj();
-//		currItem->FrameOnly = false;
-//		m_View->MarkClip(currItem, currItem->ContourLine, true);
 		changed();
 		return;
 	}
@@ -11248,10 +11240,7 @@
 	currItem->OwnPage = OnPage(currItem);
 	if (currItem->Sizing)
 	{
-//		currItem->Tinput = true;
 		currItem->FrameOnly = true;
-//		if ((m_View->frameResizeHandle == 1) && !(currItem->asLine()))
-//			currItem->paintObj();
 
 		if (currItem->FrameType == 0 || currItem->asLine())
 		{

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Tue Dec 28 12:51:51 2010
@@ -1168,6 +1168,7 @@
 	QMap<QString, VGradient> docGradients;
 	QWidget* WinHan;
 	bool DoDrawing;
+	bool drawAsPreview;
 	struct OpenNodesList
 	{
 		int type;

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16177&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Tue Dec 28 12:51:51 2010
@@ -412,6 +412,7 @@
 void ScribusView::togglePreview()
 {
 	m_canvas->m_viewMode.viewAsPreview = !m_canvas->m_viewMode.viewAsPreview;
+	Doc->drawAsPreview = m_canvas->m_viewMode.viewAsPreview;
 	if (m_canvas->m_viewMode.viewAsPreview)
 	{
 		storedFramesShown = Doc->guidesPrefs().framesShown;
@@ -1812,20 +1813,6 @@
 			//emitting in prepend below so do it here.
 			//Doc->m_Selection->itemAt(0)->emitAllToGUI();
 		}
-	}
-	else
-	{
-	//CB Prepend used to occur to enable level changes to work properly, however with
-	//current selection code we dont seem to need that anymore
-	/*
-		if (Doc->m_Selection->count() > 1)
-		{
-			PageItem *bb = Doc->m_Selection->itemAt(0);
-			Doc->m_Selection->removeItem(currItem);
-			Doc->m_Selection->prependItem(currItem, false);
-			currItem->paintObj();
-			bb->paintObj();
-		}*/
 	}
 	if (draw)
 	{




More information about the scribus-commit mailing list