fix Coverity issues

This commit is contained in:
wmayer 2016-08-21 14:03:02 +02:00
parent 8cc3ee64e8
commit 0824c5fd3c
29 changed files with 621 additions and 543 deletions

View File

@ -99,7 +99,7 @@ private:
Gui::PropertyView * prop;
QTreeView * tree;
Gui::TaskView::TaskView * taskPanel;
Gui::ProjectWidget * projectView;
//Gui::ProjectWidget * projectView;
};
} // namespace DockWnd

View File

@ -217,7 +217,14 @@ private:
};
StdCmdFreezeViews::StdCmdFreezeViews()
: Command("Std_FreezeViews"), maxViews(50), savedViews(0)
: Command("Std_FreezeViews")
, maxViews(50)
, savedViews(0)
, offset(0)
, saveView(0)
, freezeView(0)
, clearView(0)
, separator(0)
{
sGroup = QT_TR_NOOP("Standard-View");
sMenuText = QT_TR_NOOP("Freeze display");
@ -812,7 +819,7 @@ void StdCmdToggleSelectability::activated(int iMsg)
for (std::vector<App::DocumentObject*>::const_iterator ft=sel.begin();ft!=sel.end();++ft) {
ViewProvider *pr = pcDoc->getViewProviderByName((*ft)->getNameInDocument());
if (pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){
if (pr && pr->isDerivedFrom(ViewProviderGeometryObject::getClassTypeId())){
if (static_cast<ViewProviderGeometryObject*>(pr)->Selectable.getValue())
doCommand(Gui,"Gui.getDocument(\"%s\").getObject(\"%s\").Selectable=False"
, (*it)->getName(), (*ft)->getNameInDocument());

View File

@ -38,7 +38,9 @@ VertexProperty::VertexProperty() :
text(new QGraphicsTextItem()),
row(0),
column(0),
topoSortIndex(0),
lastVisibleState(VisibilityState::None),
lastFeatureState(FeatureState::None),
dagVisible(true)
{
//set z values.

View File

@ -58,8 +58,9 @@ std::list<DlgPreferencesImp::TGroupPages> DlgPreferencesImp::_pages;
* The dialog will by default be modeless, unless you set 'modal' to
* true to construct a modal dialog.
*/
DlgPreferencesImp::DlgPreferencesImp( QWidget* parent, Qt::WindowFlags fl )
: QDialog(parent, fl), ui(new Ui_DlgPreferences), canEmbedScrollArea(true)
DlgPreferencesImp::DlgPreferencesImp(QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl), ui(new Ui_DlgPreferences),
invalidParameter(false), canEmbedScrollArea(true)
{
ui->setupUi(this);

View File

@ -35,7 +35,7 @@ using namespace Gui::Dialog;
DownloadDialog::DownloadDialog(const QUrl& url, QWidget *parent)
: QDialog(parent), url(url)
: QDialog(parent), url(url), file(0), httpGetId(0), httpRequestAborted(false)
{
statusLabel = new QLabel(url.toString());
progressBar = new QProgressBar(this);

View File

@ -28,14 +28,16 @@ using namespace Gui;
*/
ExpressionCompleter::ExpressionCompleter(const App::Document * currentDoc, const App::DocumentObject * currentDocObj, QObject *parent)
: QCompleter(parent)
: QCompleter(parent), prefixStart(0)
{
QStandardItemModel* model = new QStandardItemModel(this);
std::vector<App::Document*> docs = App::GetApplication().getDocuments();
std::vector<App::Document*>::const_iterator di = docs.begin();
std::vector<DocumentObject*> deps = currentDocObj->getInList();
std::vector<DocumentObject*> deps;
if (currentDocObj)
deps = currentDocObj->getInList();
std::set<const DocumentObject*> forbidden;
for (std::vector<DocumentObject*>::const_iterator it = deps.begin(); it != deps.end(); ++it)

View File

@ -35,7 +35,7 @@ using namespace Gui;
TYPESYSTEM_SOURCE_ABSTRACT(Gui::GLGraphicsItem, Base::BaseClass);
GLPainter::GLPainter() : viewer(0), logicOp(false), lineStipple(false)
GLPainter::GLPainter() : viewer(0), width(0), height(0), logicOp(false), lineStipple(false)
{
}
@ -208,13 +208,23 @@ Rubberband::Rubberband(View3DInventorViewer* v) : viewer(v)
x_old = y_old = x_new = y_new = 0;
working = false;
stipple = true;
rgb_r = 1.0f;
rgb_g = 1.0f;
rgb_b = 1.0f;
rgb_a = 1.0f;
}
Rubberband::Rubberband()
Rubberband::Rubberband() : viewer(0)
{
x_old = y_old = x_new = y_new = 0;
working = false;
stipple = true;
rgb_r = 1.0f;
rgb_g = 1.0f;
rgb_b = 1.0f;
rgb_a = 1.0f;
}
Rubberband::~Rubberband()
@ -309,7 +319,7 @@ Polyline::Polyline(View3DInventorViewer* v) : viewer(v)
rgb_a = 1.0f;
}
Polyline::Polyline()
Polyline::Polyline() : viewer(0)
{
x_new = y_new = 0;
working = false;

View File

@ -52,6 +52,7 @@ MacroManager::MacroManager()
recordGui(true),
guiAsComment(true),
scriptToPyConsole(true),
localEnv(true),
pyConsole(0),
pyDebugger(new PythonDebugger())
{
@ -203,7 +204,7 @@ namespace Gui {
class PythonRedirector
{
public:
PythonRedirector(const char* type, PyObject* obj) : std_out(type), out(obj)
PythonRedirector(const char* type, PyObject* obj) : std_out(type), out(obj), old(0)
{
if (out) {
Base::PyGILStateLocker lock;

View File

@ -97,7 +97,7 @@ private:
};
}
MergeDocuments::MergeDocuments(App::Document* doc) : appdoc(doc)
MergeDocuments::MergeDocuments(App::Document* doc) : stream(0), appdoc(doc)
{
connectExport = doc->signalExportObjects.connect
(boost::bind(&MergeDocuments::exportObject, this, _1, _2));

View File

@ -47,6 +47,10 @@ using namespace Gui;
AbstractMouseSelection::AbstractMouseSelection() : _pcView3D(0)
{
m_iXold = 0;
m_iYold = 0;
m_iXnew = 0;
m_iYnew = 0;
m_bInner = true;
}
@ -245,6 +249,7 @@ static const char* cursor_cut_scissors[]= {
PolyPickerSelection::PolyPickerSelection()
{
lastConfirmed = false;
}
void PolyPickerSelection::setColor(float r, float g, float b, float a)

View File

@ -63,10 +63,12 @@ struct NavigationStyleP {
NavigationStyleP()
{
this->animationsteps = 0;
this->animationdelta = 0;
this->sensitivity = 2.0f;
this->resetcursorpos = false;
this->dragPointFound = false;
this->dragAtCursor = false;
this->animsensor = 0;
}
static void viewAnimationCB(void * data, SoSensor * sensor);
};

View File

@ -100,7 +100,13 @@ struct PythonConsoleP
PythonConsoleP()
{
type = Normal;
_stdoutPy = 0;
_stderrPy = 0;
_stdinPy = 0;
_stdin = 0;
interpreter = 0;
callTipsList = 0;
interactive = false;
colormap[QLatin1String("Text")] = Qt::black;
colormap[QLatin1String("Bookmark")] = Qt::cyan;
colormap[QLatin1String("Breakpoint")] = Qt::red;
@ -367,7 +373,6 @@ PythonConsole::PythonConsole(QWidget *parent)
: TextEdit(parent), WindowParameter( "Editor" ), _sourceDrain(NULL)
{
d = new PythonConsoleP();
d->interactive = false;
// create an instance of InteractiveInterpreter
try {

View File

@ -352,6 +352,9 @@ struct PythonDebuggerP {
PythonDebuggerP(PythonDebugger* that) :
init(false), trystop(false), running(false)
{
out_o = 0;
err_o = 0;
exc_o = 0;
Base::PyGILStateLocker lock;
out_n = new PythonDebugStdout();
err_n = new PythonDebugStderr();

View File

@ -976,12 +976,17 @@ void SelectionSingleton::slotDeletedObject(const App::DocumentObject& Obj)
*/
SelectionSingleton::SelectionSingleton()
{
hx = 0;
hy = 0;
hz = 0;
ActiveGate = 0;
App::GetApplication().signalDeletedObject.connect(boost::bind(&Gui::SelectionSingleton::slotDeletedObject, this, _1));
CurrentPreselection.pDocName = 0;
CurrentPreselection.pObjectName = 0;
CurrentPreselection.pSubName = 0;
CurrentPreselection.x = 0.0;
CurrentPreselection.y = 0.0;
CurrentPreselection.z = 0.0;
}
/**

View File

@ -362,10 +362,10 @@ bool SelectionFilter::parse(void)
TopBlock = 0;
SelectionParser::SelectionFilter_delete_buffer (my_string_buffer);
if(Errors == "")
if (Errors.empty()) {
return true;
else{
}
else {
return false;
delete Ast;
}
}

View File

@ -199,19 +199,19 @@ SoGroup* TDragger::buildGeometry()
void TDragger::startCB(void *, SoDragger *d)
{
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
TDragger *sudoThis = static_cast<TDragger *>(d);
sudoThis->dragStart();
}
void TDragger::motionCB(void *, SoDragger *d)
{
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
TDragger *sudoThis = static_cast<TDragger *>(d);
sudoThis->drag();
}
void TDragger::finishCB(void *, SoDragger *d)
{
TDragger *sudoThis = dynamic_cast<TDragger *>(d);
TDragger *sudoThis = static_cast<TDragger *>(d);
sudoThis->dragFinish();
}
@ -471,19 +471,19 @@ SoGroup* RDragger::buildGeometry()
void RDragger::startCB(void *, SoDragger *d)
{
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
RDragger *sudoThis = static_cast<RDragger *>(d);
sudoThis->dragStart();
}
void RDragger::motionCB(void *, SoDragger *d)
{
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
RDragger *sudoThis = static_cast<RDragger *>(d);
sudoThis->drag();
}
void RDragger::finishCB(void *, SoDragger *d)
{
RDragger *sudoThis = dynamic_cast<RDragger *>(d);
RDragger *sudoThis = static_cast<RDragger *>(d);
sudoThis->dragFinish();
}

View File

@ -108,6 +108,11 @@ SoFCColorBar::SoFCColorBar()
{
SO_NODE_CONSTRUCTOR(SoFCColorBar);
_fMaxX = 0;
_fMinX = 0;
_fMaxY = 0;
_fMinY = 0;
// SoEventCallback * cb = new SoEventCallback;
// cb->addEventCallback(SoMouseButtonEvent::getClassTypeId(), eventCallback, this);
// insertChild(cb, 0);

View File

@ -406,6 +406,7 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr,
this->pixelbuffer = NULL; // constructed later
this->framebuffer = NULL;
this->numSamples = -1;
this->cache_context = 0;
this->pbuffer = QGLPixelBuffer::hasOpenGLPbuffers();
}

View File

@ -825,7 +825,21 @@ namespace Gui {
class SoBoxSelectionRenderActionP {
public:
SoBoxSelectionRenderActionP(SoBoxSelectionRenderAction * master)
: master(master) { }
: master(master)
, searchaction(0)
, selectsearch(0)
, camerasearch(0)
, bboxaction(0)
, basecolor(0)
, postprocpath(0)
, highlightPath(0)
, localRoot(0)
, xform(0)
, cube(0)
, drawstyle(0)
{
}
SoBoxSelectionRenderAction * master;
SoSearchAction * searchaction;

View File

@ -57,7 +57,9 @@ class SoVectorizePoint : public SoVectorizeItem {
public:
SoVectorizePoint(void) {
this->type = POINT;
this->vidx = 0;
this->size = 1.0f;
this->col = 0;
}
int vidx; // index to BSPtree coordinate
float size; // Coin size (pixels)
@ -90,6 +92,9 @@ class SoVectorizeText : public SoVectorizeItem {
public:
SoVectorizeText(void) {
this->type = TEXT;
this->fontsize = 10;
this->col = 0;
this->justification = LEFT;
}
enum Justification {

View File

@ -58,7 +58,9 @@ class SoVectorizePoint : public SoVectorizeItem {
public:
SoVectorizePoint(void) {
this->type = POINT;
this->vidx = 0;
this->size = 1.0f;
this->col = 0;
}
int vidx; // index to BSPtree coordinate
float size; // Coin size (pixels)
@ -91,6 +93,9 @@ class SoVectorizeText : public SoVectorizeItem {
public:
SoVectorizeText(void) {
this->type = TEXT;
this->fontsize = 10;
this->col = 0;
this->justification = LEFT;
}
enum Justification {

View File

@ -121,13 +121,13 @@ SoGestureSwipeEvent::SoGestureSwipeEvent(QSwipeGesture *qwsipe, QWidget *widget)
}
switch (qwsipe->horizontalDirection()){
case QSwipeGesture::Right :
vertDir = +1;
horzDir = +1;
break;
case QSwipeGesture::Left :
vertDir = -1;
horzDir = -1;
break;
default:
vertDir = 0;
horzDir = 0;
break;
}

View File

@ -39,9 +39,9 @@ class SoGestureEvent : public SoEvent {
public:
static void initClass(){
SO_EVENT_INIT_CLASS(SoGestureEvent, SoEvent);
};
SoGestureEvent(){};
~SoGestureEvent(){};
}
SoGestureEvent() : state(SbGSNoGesture) {}
~SoGestureEvent(){}
SbBool isSoGestureEvent(const SoEvent* ev) const;
enum SbGestureState {
@ -59,10 +59,10 @@ class SoGesturePanEvent : public SoGestureEvent {
public:
static void initClass(){//needs to be called before the class can be used. Initializes type IDs of the class.
SO_EVENT_INIT_CLASS(SoGesturePanEvent, SoGestureEvent);
};
SoGesturePanEvent() {};
}
SoGesturePanEvent() {}
SoGesturePanEvent(QPanGesture *qpan, QWidget *widget);
~SoGesturePanEvent(){};
~SoGesturePanEvent(){}
SbBool isSoGesturePanEvent(const SoEvent* ev) const;
SbVec2f deltaOffset;
@ -74,10 +74,13 @@ class SoGesturePinchEvent : public SoGestureEvent {
public:
static void initClass(){
SO_EVENT_INIT_CLASS(SoGesturePinchEvent, SoGestureEvent);
};
SoGesturePinchEvent(){};
}
SoGesturePinchEvent() : deltaZoom(0), totalZoom(0),
deltaAngle(0), totalAngle(0)
{
}
SoGesturePinchEvent(QPinchGesture* qpinch, QWidget* widget);
~SoGesturePinchEvent(){};
~SoGesturePinchEvent(){}
SbBool isSoGesturePinchEvent(const SoEvent* ev) const;
SbVec2f startCenter;//in GL pixel coordinates (from bottom left corner of view area)
@ -95,10 +98,12 @@ class SoGestureSwipeEvent : public SoGestureEvent {
public:
static void initClass(){
SO_EVENT_INIT_CLASS(SoGestureSwipeEvent, SoGestureEvent);
};
SoGestureSwipeEvent(){};
}
SoGestureSwipeEvent() : angle(0), vertDir(0), horzDir(0)
{
}
SoGestureSwipeEvent(QSwipeGesture* qwsipe, QWidget *widget);
~SoGestureSwipeEvent(){};
~SoGestureSwipeEvent(){}
SbBool isSoGestureSwipeEvent(const SoEvent* ev) const;
double angle;

View File

@ -35,7 +35,7 @@ EventBase::EventBase(QEvent::Type event) : QInputEvent(static_cast<QEvent::Type>
}
MotionEvent::MotionEvent() : EventBase(static_cast<QEvent::Type>(MotionEventType)),
xTrans(0), yTrans(0), zTrans(0), xRot(0), yRot(0), zRot(0)
xTrans(0), yTrans(0), zTrans(0), xRot(0), yRot(0), zRot(0), handled(false)
{
}

View File

@ -69,6 +69,7 @@ TaskSelectLinkProperty::TaskSelectLinkProperty(const char *sFilter,App::Property
// property have to be set!
assert(prop);
StartObject = 0;
if (prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) {
LinkSub = dynamic_cast<App::PropertyLinkSub *>(prop);
}

View File

@ -86,6 +86,7 @@ TaskWatcherCommands::TaskWatcherCommands(const char* Filter,const char* commands
const char* name, const char* pixmap)
: TaskWatcher(Filter)
{
if (commands) {
CommandManager &mgr = Gui::Application::Instance->commandManager();
Gui::TaskView::TaskBox *tb = new Gui::TaskView::TaskBox
(BitmapFactory().pixmap(pixmap), trUtf8(name), true, 0);
@ -100,6 +101,7 @@ TaskWatcherCommands::TaskWatcherCommands(const char* Filter,const char* commands
}
Content.push_back(tb);
}
}

View File

@ -39,7 +39,7 @@ using namespace Gui;
* Constructs a TextEdit which is a child of 'parent'.
*/
TextEdit::TextEdit(QWidget* parent)
: QPlainTextEdit(parent), listBox(0)
: QPlainTextEdit(parent), cursorPosition(0), listBox(0)
{
//Note: Set the correct context to this shortcut as we may use several instances of this
//class at a time

View File

@ -62,7 +62,7 @@ const int TreeWidget::ObjectType = 1001;
/* TRANSLATOR Gui::TreeWidget */
TreeWidget::TreeWidget(QWidget* parent)
: QTreeWidget(parent), fromOutside(false)
: QTreeWidget(parent), contextItem(0), fromOutside(false)
{
this->setDragEnabled(true);
this->setAcceptDrops(true);

View File

@ -248,11 +248,8 @@ Py::Object View3DInventorViewerPy::seekToPoint(const Py::Tuple& args)
catch (const Py::Exception&) {
throw;
}
return Py::None();
}
Py::Object View3DInventorViewerPy::setFocalDistance(const Py::Tuple& args)
{
float distance;