r20833 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Sun Jan 31 00:49:15 UTC 2016
Author: jghali
Date: Sun Jan 31 00:49:14 2016
New Revision: 20833
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20833
Log:
coverity #1350642: uninitialized pointer field
Modified:
trunk/Scribus/scribus/plugins/shapes/shapepalette.cpp
trunk/Scribus/scribus/plugins/shapes/shapepalette.h
Modified: trunk/Scribus/scribus/plugins/shapes/shapepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20833&path=/trunk/Scribus/scribus/plugins/shapes/shapepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/shapes/shapepalette.cpp (original)
+++ trunk/Scribus/scribus/plugins/shapes/shapepalette.cpp Sun Jan 31 00:49:14 2016
@@ -46,6 +46,9 @@
ShapeView::ShapeView(QWidget* parent) : QListWidget(parent)
{
+ shapes.clear();
+ scMW = NULL;
+
setDragEnabled(true);
setViewMode(QListView::IconMode);
setFlow(QListView::LeftToRight);
@@ -61,7 +64,7 @@
delegate->setIconOnly(false);
setItemDelegate(delegate);
setIconSize(QSize(48, 48));
- m_Shapes.clear();
+
connect(this, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(HandleContextMenu(QPoint)));
}
@@ -96,7 +99,7 @@
QMessageBox::Yes); // batch default
if (t == QMessageBox::No)
return;
- m_Shapes.clear();
+ shapes.clear();
clear();
}
@@ -106,7 +109,7 @@
if (it != NULL)
{
QString key = it->data(Qt::UserRole).toString();
- m_Shapes.remove(key);
+ shapes.remove(key);
updateShapeList();
}
}
@@ -158,9 +161,9 @@
if (it != NULL)
{
QString key = it->data(Qt::UserRole).toString();
- if (m_Shapes.contains(key))
+ if (shapes.contains(key))
{
- m_Shapes.remove(key);
+ shapes.remove(key);
updateShapeList();
e->accept();
}
@@ -206,18 +209,18 @@
void ShapeView::startDrag(Qt::DropActions supportedActions)
{
QString key = currentItem()->data(Qt::UserRole).toString();
- if (m_Shapes.contains(key))
- {
- int w = m_Shapes[key].width;
- int h = m_Shapes[key].height;
+ if (shapes.contains(key))
+ {
+ int w = shapes[key].width;
+ int h = shapes[key].height;
ScribusDoc *m_Doc = new ScribusDoc();
m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
m_Doc->setPage(w, h, 0, 0, 0, 0, 0, 0, false, false);
m_Doc->addPage(0);
- m_Doc->setGUI(false, m_scMW, 0);
+ m_Doc->setGUI(false, scMW, 0);
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset(), w, h, m_Doc->itemToolPrefs().shapeLineWidth, m_Doc->itemToolPrefs().shapeFillColor, m_Doc->itemToolPrefs().shapeLineColor);
PageItem* ite = m_Doc->Items->at(z);
- ite->PoLine = m_Shapes[key].path.copy();
+ ite->PoLine = shapes[key].path.copy();
FPoint wh = getMaxClipF(&ite->PoLine);
ite->setWidthHeight(wh.x(),wh.y());
ite->setTextFlowMode(PageItem::TextFlowDisabled);
@@ -241,7 +244,7 @@
{
clear();
setWordWrap(true);
- for (QHash<QString, shapeData>::Iterator it = m_Shapes.begin(); it != m_Shapes.end(); ++it)
+ for (QHash<QString, shapeData>::Iterator it = shapes.begin(); it != shapes.end(); ++it)
{
int w = it.value().width + 4;
int h = it.value().height + 4;
@@ -326,7 +329,7 @@
ShapeViewWidget = (ShapeView*)Frame3->widget(a);
QDomElement fil = docu.createElement("file");
fil.setAttribute("name", Frame3->itemText(a));
- for (QHash<QString, shapeData>::Iterator it = ShapeViewWidget->m_Shapes.begin(); it != ShapeViewWidget->m_Shapes.end(); ++it)
+ for (QHash<QString, shapeData>::Iterator it = ShapeViewWidget->shapes.begin(); it != ShapeViewWidget->shapes.end(); ++it)
{
QDomElement shp = docu.createElement("shape");
shp.setAttribute("width", it.value().width);
@@ -364,7 +367,7 @@
if (drawPag.tagName() == "file")
{
ShapeViewWidget = new ShapeView(this);
- ShapeViewWidget->m_scMW = m_scMW;
+ ShapeViewWidget->scMW = m_scMW;
Frame3->addItem(ShapeViewWidget, drawPag.attribute("name"));
for(QDomElement dpg = drawPag.firstChildElement(); !dpg.isNull(); dpg = dpg.nextSiblingElement() )
{
@@ -375,7 +378,7 @@
shData.width = dpg.attribute("width", "1").toInt();
shData.path.parseSVG(dpg.attribute("path"));
shData.name = dpg.attribute("name");
- ShapeViewWidget->m_Shapes.insert(dpg.attribute("uuid"), shData);
+ ShapeViewWidget->shapes.insert(dpg.attribute("uuid"), shData);
}
}
ShapeViewWidget->updateShapeList();
@@ -534,14 +537,14 @@
shData.width = bounds.width();
shData.path = clip2.copy();
shData.name = string;
- ShapeViewWidget->m_Shapes.insert(QString(uuid), shData);
+ ShapeViewWidget->shapes.insert(QString(uuid), shData);
ds.device()->seek(posi + shpLen);
shpCounter++;
}
file.close();
Frame3->setCurrentIndex(nIndex);
ShapeViewWidget->updateShapeList();
- ShapeViewWidget->m_scMW = m_scMW;
+ ShapeViewWidget->scMW = m_scMW;
QApplication::restoreOverrideCursor();
}
}
@@ -552,7 +555,7 @@
for (int a = 0; a < Frame3->count(); a++)
{
ShapeViewWidget = (ShapeView*)Frame3->widget(a);
- ShapeViewWidget->m_scMW = mw;
+ ShapeViewWidget->scMW = mw;
}
}
Modified: trunk/Scribus/scribus/plugins/shapes/shapepalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20833&path=/trunk/Scribus/scribus/plugins/shapes/shapepalette.h
==============================================================================
--- trunk/Scribus/scribus/plugins/shapes/shapepalette.h (original)
+++ trunk/Scribus/scribus/plugins/shapes/shapepalette.h Sun Jan 31 00:49:14 2016
@@ -59,9 +59,11 @@
public:
ShapeView( QWidget* parent);
~ShapeView() {};
+
void updateShapeList();
- QHash<QString, shapeData> m_Shapes;
- ScribusMainWindow *m_scMW;
+
+ QHash<QString, shapeData> shapes;
+ ScribusMainWindow *scMW;
public slots:
void HandleContextMenu(QPoint);
@@ -91,13 +93,13 @@
public:
ShapePalette(QWidget* parent);
~ShapePalette() {};
+
void writeToPrefs();
void readFromPrefs();
double decodePSDfloat(uint data);
void setMainWindow(ScribusMainWindow *mw);
void setDoc(ScribusDoc *);
void unsetDoc();
- ScribusMainWindow *m_scMW;
virtual void changeEvent(QEvent *e);
@@ -114,7 +116,9 @@
QHBoxLayout* buttonLayout;
QToolButton* importButton;
QToolButton* closeButton;
+
ScribusDoc *m_doc;
+ ScribusMainWindow *m_scMW;
};
#endif
More information about the scribus-commit
mailing list