r22281 by craig -

scribus-commit scribus-commit at lists.scribus.net
Wed Dec 27 17:30:14 UTC 2017


Author: craig
Date: Wed Dec 27 17:30:14 2017
New Revision: 22281

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22281
Log:
Fix some coverity issues

Modified:
    trunk/Scribus/scribus/canvasgesture_rulermove.cpp
    trunk/Scribus/scribus/canvasmode_editweldpoint.cpp
    trunk/Scribus/scribus/colorblind.cpp
    trunk/Scribus/scribus/fileloader.cpp
    trunk/Scribus/scribus/fonts/sfnt.cpp
    trunk/Scribus/scribus/fonts/sfnt.h
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pageitem_textframe.h
    trunk/Scribus/scribus/third_party/zip/unzip.cpp
    trunk/Scribus/scribus/ui/contextmenu.cpp
    trunk/Scribus/scribus/ui/extimageprops.h
    trunk/Scribus/scribus/ui/newfile.cpp
    trunk/Scribus/scribus/ui/newfile.h
    trunk/Scribus/scribus/util_math.cpp

Modified: trunk/Scribus/scribus/canvasgesture_rulermove.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/canvasgesture_rulermove.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_rulermove.cpp	(original)
+++ trunk/Scribus/scribus/canvasgesture_rulermove.cpp	Wed Dec 27 17:30:14 2017
@@ -31,12 +31,15 @@
 RulerGesture::RulerGesture(ScribusView *view, RulerGesture::Mode mode) :
 	CanvasGesture(view),
 	m_ScMW(m_view->m_ScMW),
-	m_mode(mode), m_haveGuide(false),
+	m_mode(mode),
+	m_haveGuide(false),
+	m_page(0),
+	m_guide(0.0),
+	m_currentGuide(0.0),
 	m_haveCursor(false),
 	m_xy(0,0),
 	m_mousePoint(0,0)
 {
-
 }
 
 

Modified: trunk/Scribus/scribus/canvasmode_editweldpoint.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/canvasmode_editweldpoint.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editweldpoint.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_editweldpoint.cpp	Wed Dec 27 17:30:14 2017
@@ -63,11 +63,16 @@
 #include "util_math.h"
 
 
-CanvasMode_EditWeldPoint::CanvasMode_EditWeldPoint(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
-{
-	m_Mxp = m_Myp = -1;
-	m_selectedPoint = -1;
-	m_editWeldMode = true;
+CanvasMode_EditWeldPoint::CanvasMode_EditWeldPoint(ScribusView* view) : CanvasMode(view),
+	m_Mxp(-1.0),
+	m_Myp(1.0),
+	m_selectedPoint(-1),
+	m_ScMW(view->m_ScMW),
+	m_keyRepeat(false),
+	m_currItem(NULL),
+	m_ModeDialog(NULL),
+	m_editWeldMode(true)
+{
 }
 
 inline bool CanvasMode_EditWeldPoint::GetItem(PageItem** pi)

Modified: trunk/Scribus/scribus/colorblind.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/colorblind.cpp
==============================================================================
--- trunk/Scribus/scribus/colorblind.cpp	(original)
+++ trunk/Scribus/scribus/colorblind.cpp	Wed Dec 27 17:30:14 2017
@@ -41,6 +41,10 @@
 
 void VisionDefectColor::init()
 {
+	deficiency = 0;
+	m_a1 = m_a2 = m_b1 = m_b2 = m_c1 = m_c2 = 0.0;
+	m_inflection = 0.0;
+
 	m_rgb2lms[0] = 0.05059983;
 	m_rgb2lms[1] = 0.08585369;
 	m_rgb2lms[2] = 0.00952420;

Modified: trunk/Scribus/scribus/fileloader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/fileloader.cpp
==============================================================================
--- trunk/Scribus/scribus/fileloader.cpp	(original)
+++ trunk/Scribus/scribus/fileloader.cpp	Wed Dec 27 17:30:14 2017
@@ -82,16 +82,16 @@
 	QStringList fmts = LoadSavePlugin::fileDialogLoadFilter();
 	QString fmtString = QObject::tr("All Supported Formats")+" (";
 	int ind = -1;
-	for (int a = 0; a < fmts.count()-1; a++)
-	{
-		QString fmt = fmts[a];
+	for (int i = 0; i < fmts.count()-1; i++)
+	{
+		QString fmt = fmts[i];
 		int s = fmt.indexOf("(");
 		int e = fmt.lastIndexOf(")");
 		QString f = fmt.mid(s+1, e-s-1);
 #ifndef HAVE_POPPLER
 		if (f.contains("pdf"))	// for removing PDF from the list
 		{
-			ind = a;
+			ind = i;
 			continue;
 		}
 #endif

Modified: trunk/Scribus/scribus/fonts/sfnt.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/fonts/sfnt.cpp
==============================================================================
--- trunk/Scribus/scribus/fonts/sfnt.cpp	(original)
+++ trunk/Scribus/scribus/fonts/sfnt.cpp	Wed Dec 27 17:30:14 2017
@@ -656,7 +656,7 @@
 	{
 		QByteArray result;
 		QList<std::pair<qint16,quint16> >::const_iterator it;
-		int i = 0;
+		//int i = 0;
 		for (it = longHorMetrics.cbegin(); it < longHorMetrics.cend(); ++it)
 		{
 			//qDebug() << "hmtx" << i++ << it->first << it->second;
@@ -908,7 +908,7 @@
 			uint idRangeOffsetAddress = startOfIdRangeOffsetTable + 2*i;
 			if (rangeOffsets[i] == 0)
 			{
-				quint16 dbg = startCodes[i] + idDeltas[i];
+				//quint16 dbg = startCodes[i] + idDeltas[i];
 				//qDebug() << QChar(startCodes[i]) << "-" << QChar(endCodes[i]) << "/" << (endCodes[i]-startCodes[i]+1) << "+" << idDeltas[i] << "-->" << dbg;
 				putWord16(result, idRangeOffsetAddress, 0);
 			}
@@ -1021,7 +1021,7 @@
 		uint glyphStart = srcLoca[srcGid];
 		uint glyphLength = srcLoca[srcGid+1] - glyphStart;
 		destLoca.append(destGlyf.size());
-		int i = 0;
+		//int i = 0;
 		if (glyphLength > 0)
 		{
 			quint16 nrOfContours = word16(srcGlyf, glyphStart);

Modified: trunk/Scribus/scribus/fonts/sfnt.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/fonts/sfnt.h
==============================================================================
--- trunk/Scribus/scribus/fonts/sfnt.h	(original)
+++ trunk/Scribus/scribus/fonts/sfnt.h	Wed Dec 27 17:30:14 2017
@@ -42,14 +42,15 @@
  This class checks the post table of a ttf font.
  */
 class SCRIBUS_API PostTable {
-public:
-	bool usable;
-	QString errorMsg;
-	uint numberOfGlyphs() const;
-	QString nameFor(uint glyphId) const;
-	void readFrom(FT_Face face);
-private:
-	QList<QString> m_names;
+	public:
+		PostTable() {usable=false;}
+		bool usable;
+		QString errorMsg;
+		uint numberOfGlyphs() const;
+		QString nameFor(uint glyphId) const;
+		void readFrom(FT_Face face);
+	private:
+		QList<QString> m_names;
 };
 
 } //namespace

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Wed Dec 27 17:30:14 2017
@@ -871,6 +871,16 @@
 	hatchBackgroundQ = QColor();
 	hatchForeground = "Black";
 	hatchForegroundQ = qcol;
+	selectedMeshControlPoint=0;
+	snapToPatchGrid=0;
+	gridOffset_=0.0;
+	gridValue_=0.0;
+	FrameOnly=false;
+	inlineCharID=0;
+	GrStrokeExtend=VGradient::none;
+	tagged=false;
+	no_fill=false;
+	no_stroke=false;
 }
 
 PageItem::~PageItem()
@@ -3097,7 +3107,7 @@
 
 void PageItem::createGradientMesh(int rows, int cols)
 {
-	QString MColor = fillColorVal;
+	QString MColor(fillColorVal);
 	QColor MQColor;
 	if (fillColorVal != CommonStrings::None)
 	{

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp	Wed Dec 27 17:30:14 2017
@@ -75,27 +75,26 @@
 PageItem_TextFrame::PageItem_TextFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline)
 	: PageItem(pa, PageItem::TextFrame, x, y, w, h, w2, fill, outline)
 {
-	invalid = true;
+	init();
 	firstChar = 0;
-	cursorBiasBackward = false;
-	unicodeTextEditMode = false;
-	unicodeInputCount = 0;
-	unicodeInputString = "";
-	m_origAnnotPos = QRectF(xPos(), yPos(), width(), height());
-	verticalAlign = 0;
-	connect(&itemText,SIGNAL(changed(int, int)), this, SLOT(slotInvalidateLayout(int, int)));
 }
 
 PageItem_TextFrame::PageItem_TextFrame(const PageItem & p) : PageItem(p)
+{
+	init();
+	m_notesFramesMap.clear();
+}
+
+void PageItem_TextFrame::init()
 {
 	invalid = true;
 	cursorBiasBackward = false;
 	unicodeTextEditMode = false;
 	unicodeInputCount = 0;
-	unicodeInputString = "";
-	m_notesFramesMap.clear();
 	m_origAnnotPos = QRectF(xPos(), yPos(), width(), height());
 	verticalAlign = 0;
+	incompleteLines = 0;
+	maxY = 0.0;
 	connect(&itemText,SIGNAL(changed(int, int)), this, SLOT(slotInvalidateLayout(int, int)));
 }
 
@@ -5966,7 +5965,7 @@
 void PageItem_TextFrame::setMaxY(double y)
 {
 	if (y == -1)
-		maxY = 0;
+		maxY = 0.0;
 	else
 		maxY = qMax(y, maxY);
 }

Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h	(original)
+++ trunk/Scribus/scribus/pageitem_textframe.h	Wed Dec 27 17:30:14 2017
@@ -50,6 +50,8 @@
 	PageItem_TextFrame(ScribusDoc *pa, double x, double y, double w, double h, double w2, QString fill, QString outline);
 	PageItem_TextFrame(const PageItem & p);
 	~PageItem_TextFrame() {}
+
+	void init();
 
 	virtual PageItem_TextFrame * asTextFrame() { return this; }
 	virtual bool isTextFrame() const { return true; }

Modified: trunk/Scribus/scribus/third_party/zip/unzip.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/third_party/zip/unzip.cpp
==============================================================================
--- trunk/Scribus/scribus/third_party/zip/unzip.cpp	(original)
+++ trunk/Scribus/scribus/third_party/zip/unzip.cpp	Wed Dec 27 17:30:14 2017
@@ -286,47 +286,47 @@
   header.  The correct values are put in the data descriptor
   immediately following the compressed data."
  */
-    bool hasDataDescriptor = entry.hasDataDescriptor();
-
-    bool checkFailed = false;
-
-    if (!checkFailed)
-        checkFailed = entry.compMethod != getUShort(uBuffer, UNZIP_LH_OFF_CMETHOD);
-    if (!checkFailed)
-        checkFailed = entry.gpFlag[0] != uBuffer[UNZIP_LH_OFF_GPFLAG];
-    if (!checkFailed)
-        checkFailed = entry.gpFlag[1] != uBuffer[UNZIP_LH_OFF_GPFLAG + 1];
-    if (!checkFailed)
-        checkFailed = entry.modTime[0] != uBuffer[UNZIP_LH_OFF_MODT];
-    if (!checkFailed)
-        checkFailed = entry.modTime[1] != uBuffer[UNZIP_LH_OFF_MODT + 1];
-    if (!checkFailed)
-        checkFailed = entry.modDate[0] != uBuffer[UNZIP_LH_OFF_MODD];
-    if (!checkFailed)
-        checkFailed = entry.modDate[1] != uBuffer[UNZIP_LH_OFF_MODD + 1];
-    if (!hasDataDescriptor)
-    {
-        if (!checkFailed)
-            checkFailed = entry.crc != getULong(uBuffer, UNZIP_LH_OFF_CRC32);
-        if (!checkFailed)
-            checkFailed = entry.szComp != getULong(uBuffer, UNZIP_LH_OFF_CSIZE);
-        if (!checkFailed)
-            checkFailed = entry.szUncomp != getULong(uBuffer, UNZIP_LH_OFF_USIZE);
-    }
-
-    if (checkFailed)
-        return UnZip::HeaderConsistencyError;
-
-    // Check filename
-    quint16 szName = getUShort(uBuffer, UNZIP_LH_OFF_NAMELEN);
-    if (szName == 0)
-        return UnZip::HeaderConsistencyError;
+	bool hasDataDescriptor = entry.hasDataDescriptor();
+
+	bool checkFailed = false;
+
+	if (!checkFailed)
+		checkFailed = entry.compMethod != getUShort(uBuffer, UNZIP_LH_OFF_CMETHOD);
+	if (!checkFailed)
+		checkFailed = entry.gpFlag[0] != uBuffer[UNZIP_LH_OFF_GPFLAG];
+	if (!checkFailed)
+		checkFailed = entry.gpFlag[1] != uBuffer[UNZIP_LH_OFF_GPFLAG + 1];
+	if (!checkFailed)
+		checkFailed = entry.modTime[0] != uBuffer[UNZIP_LH_OFF_MODT];
+	if (!checkFailed)
+		checkFailed = entry.modTime[1] != uBuffer[UNZIP_LH_OFF_MODT + 1];
+	if (!checkFailed)
+		checkFailed = entry.modDate[0] != uBuffer[UNZIP_LH_OFF_MODD];
+	if (!checkFailed)
+		checkFailed = entry.modDate[1] != uBuffer[UNZIP_LH_OFF_MODD + 1];
+	if (!hasDataDescriptor)
+	{
+		if (!checkFailed)
+			checkFailed = entry.crc != getULong(uBuffer, UNZIP_LH_OFF_CRC32);
+		if (!checkFailed)
+			checkFailed = entry.szComp != getULong(uBuffer, UNZIP_LH_OFF_CSIZE);
+		if (!checkFailed)
+			checkFailed = entry.szUncomp != getULong(uBuffer, UNZIP_LH_OFF_USIZE);
+	}
+
+	if (checkFailed)
+		return UnZip::HeaderConsistencyError;
+
+	// Check filename
+	quint16 szName = getUShort(uBuffer, UNZIP_LH_OFF_NAMELEN);
+	if (szName == 0)
+		return UnZip::HeaderConsistencyError;
 
 	memset(buffer2, 0, szName);
-    if (device->read(buffer2, szName) != szName)
-        return UnZip::ReadFailed;
-
-	QString filename = "";
+	if (device->read(buffer2, szName) != szName)
+		return UnZip::ReadFailed;
+
+	QString filename;
 	for (quint16 fc = 0; fc < szName; fc++)
 	{
 		if (buffer2[fc] > 0)

Modified: trunk/Scribus/scribus/ui/contextmenu.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/ui/contextmenu.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/contextmenu.cpp	(original)
+++ trunk/Scribus/scribus/ui/contextmenu.cpp	Wed Dec 27 17:30:14 2017
@@ -530,11 +530,11 @@
 	addSeparator();
 	if (selectedItemCount > 0 && m_doc->appMode != modeEdit)
 	{
-		PageItem *currItem;
-		for (int a = 0; a < m_Sel.count(); ++a)
-		{
-			currItem = m_Sel.itemAt(a);
-			if (currItem->isWelded())
+		PageItem *currItem2;
+		for (int i = 0; i < m_Sel.count(); ++i)
+		{
+			currItem2 = m_Sel.itemAt(i);
+			if (currItem2->isWelded())
 			{
 				addAction(m_ScMW->scrActions["itemsUnWeld"]);
 				break;
@@ -558,7 +558,7 @@
 	addAction(m_ScMW->scrActions["toolsProperties"]);
 	
 	bool containsTextFrame = false;
-	if (currItem && currItem->asTextFrame())
+	if (currItem->asTextFrame())
 		containsTextFrame = true;
 	if (m_doc->appMode == modeEditTable)
 		containsTextFrame = true;

Modified: trunk/Scribus/scribus/ui/extimageprops.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/ui/extimageprops.h
==============================================================================
--- trunk/Scribus/scribus/ui/extimageprops.h	(original)
+++ trunk/Scribus/scribus/ui/extimageprops.h	Wed Dec 27 17:30:14 2017
@@ -36,7 +36,7 @@
 
 public:
 	ExtImageProps( QWidget* parent, ImageInfoRecord *info, PageItem *item, ScribusView *view );
-	~ExtImageProps() {};
+	~ExtImageProps() {}
 
 public slots:
 	void leaveOK();

Modified: trunk/Scribus/scribus/ui/newfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/ui/newfile.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/newfile.cpp	(original)
+++ trunk/Scribus/scribus/ui/newfile.cpp	Wed Dec 27 17:30:14 2017
@@ -45,7 +45,9 @@
 #include "units.h"
 #include "iconmanager.h"
 
-PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : QListWidget(parent)
+PageLayoutsWidget::PageLayoutsWidget(QWidget* parent) : QListWidget(parent),
+	maxX(0),
+	maxY(0)
 {
 	setDragEnabled(false);
 	setViewMode(QListView::IconMode);

Modified: trunk/Scribus/scribus/ui/newfile.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/ui/newfile.h
==============================================================================
--- trunk/Scribus/scribus/ui/newfile.h	(original)
+++ trunk/Scribus/scribus/ui/newfile.h	Wed Dec 27 17:30:14 2017
@@ -42,7 +42,7 @@
 
 public:
 	PageLayoutsWidget(QWidget* parent);
-	~PageLayoutsWidget() {};
+	~PageLayoutsWidget() {}
 	void arrangeIcons();
 	QSize minimumSizeHint() const;
 	int maxX;

Modified: trunk/Scribus/scribus/util_math.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22281&path=/trunk/Scribus/scribus/util_math.cpp
==============================================================================
--- trunk/Scribus/scribus/util_math.cpp	(original)
+++ trunk/Scribus/scribus/util_math.cpp	Wed Dec 27 17:30:14 2017
@@ -396,32 +396,30 @@
 {
 	QPolygon cli, outa;
 	Segs.clear();
-	if (ina.size() > 3)
-	{
-		for (int poi=0; poi<ina.size()-3; poi += 4)
-		{
-			if (ina.isMarker(poi)) // && cli.size() > 0)
-			{
-//				outa << cli.point(cli.size()-1);
-				Segs.append(outa.size());
-				continue;
-			}
-			FPoint a1 = ina.point(poi);
-			FPoint a2 = ina.point(poi+1);
-			FPoint a3 = ina.point(poi+3);
-			FPoint a4 = ina.point(poi+2);
-			QPainterPath Bez;
-			Bez.moveTo(a1.x(), a1.y());
-			Bez.cubicTo(a2.x(), a2.y(), a3.x(), a3.y(), a4.x(), a4.y());
-			cli = Bez.toFillPolygon().toPolygon();
-			if (cli.size() > 1)
-				outa.putPoints(outa.size(), cli.size()-2, cli);
-			else
-				outa << QPoint(qRound(a4.x()), qRound(a4.y()));
-		}
-//		if (cli.size() > 0)
-//			outa << cli.point(cli.size()-1);
-	}
+	if (ina.size() <= 3)
+		return outa;
+	int limit=ina.size()-3;
+	for (int poi=0; poi<limit; poi += 4)
+	{
+		if (ina.isMarker(poi)) // && cli.size() > 0)
+		{
+			Segs.append(outa.size());
+			continue;
+		}
+		FPoint a1 = ina.point(poi);
+		FPoint a2 = ina.point(poi+1);
+		FPoint a3 = ina.point(poi+3);
+		FPoint a4 = ina.point(poi+2);
+		QPainterPath Bez;
+		Bez.moveTo(a1.x(), a1.y());
+		Bez.cubicTo(a2.x(), a2.y(), a3.x(), a3.y(), a4.x(), a4.y());
+		cli = Bez.toFillPolygon().toPolygon();
+		if (cli.size() > 1)
+			outa.putPoints(outa.size(), cli.size()-2, cli);
+		else
+			outa << QPoint(qRound(a4.x()), qRound(a4.y()));
+	}
+
 	return outa;
 }
 
@@ -484,7 +482,7 @@
 	double constrainTo=constrain;
 	if (newAngle<0.0)
 		newAngle+=360.0;
-	newAngle=qRound(angle/constrainTo)*constrainTo;
+	newAngle=qRound(newAngle/constrainTo)*constrainTo;
 	if (newAngle==360.0)
 		newAngle=0.0;
 	return newAngle;




More information about the scribus-commit mailing list