Coverity fixes

CID 174671
CID 174670
CID 174669
CID 174668
CID 174667
CID 174664
This commit is contained in:
wandererfan
2018-04-02 12:42:29 -04:00
committed by wmayer
parent a4ae54f65a
commit 4f3f620720
6 changed files with 18 additions and 11 deletions

View File

@@ -433,6 +433,7 @@ double DrawUtil::getDefaultLineWeight(std::string lineType)
auto lg = LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight(lineType);
delete lg; //Coverity CID 174671
return weight;
}

View File

@@ -75,19 +75,9 @@ using namespace TechDrawGui;
//find a page in Selection, Document or CurrentWindow.
TechDraw::DrawPage* DrawGuiUtil::findPage(Gui::Command* cmd)
{
TechDraw::DrawPage* page = nullptr;
TechDraw::DrawPage* page;
bool warn = true;
//default to currently displayed DrawPage is there is one
Gui::MainWindow* w = Gui::getMainWindow();
Gui::MDIView* mv = w->activeWindow();
MDIViewPage* mvp = dynamic_cast<MDIViewPage*>(mv);
if (mvp) {
QString windowTitle = mvp->windowTitle();
QGVPage* qp = mvp->getQGVPage();
page = qp->getDrawPage();
}
//check Selection and/or Document for a DrawPage
std::vector<App::DocumentObject*> selPages = cmd->getSelection().getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
if (selPages.empty()) { //no page in selection
@@ -114,6 +104,18 @@ TechDraw::DrawPage* DrawGuiUtil::findPage(Gui::Command* cmd)
page = static_cast<TechDraw::DrawPage*>(selPages.front());
}
//default to currently displayed DrawPage is there is one //code moved Coverity CID 174668
if (page == nullptr) {
Gui::MainWindow* w = Gui::getMainWindow();
Gui::MDIView* mv = w->activeWindow();
MDIViewPage* mvp = dynamic_cast<MDIViewPage*>(mv);
if (mvp) {
QString windowTitle = mvp->windowTitle();
QGVPage* qp = mvp->getQGVPage();
page = qp->getDrawPage();
}
}
if ((page == nullptr) &&
(warn) ) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No page found"),

View File

@@ -44,6 +44,7 @@ QGICenterLine::QGICenterLine()
setWidth(0.0);
setStyle(getCenterStyle());
setColor(getCenterColor());
m_isintersection = false; //Coverity CID 174669
}
void QGICenterLine::draw()

View File

@@ -68,6 +68,7 @@ ViewProviderDimension::ViewProviderDimension()
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Thin");
delete lg; //Coverity CID 174670
ADD_PROPERTY_TYPE(LineWidth,(weight) ,group,(App::PropertyType)(App::Prop_None),"Dimension line weight");
hGrp = App::GetApplication().GetUserParameter()

View File

@@ -194,6 +194,7 @@ void ViewProviderGeomHatch::getParameters(void)
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
double weight = lg->getWeight("Graphic");
delete lg; //Coverity CID 174667
WeightPattern.setValue(weight);
}

View File

@@ -76,6 +76,7 @@ ViewProviderViewPart::ViewProviderViewPart()
weight = lg->getWeight("Extra");
ADD_PROPERTY_TYPE(ExtraWidth,(weight),group,App::Prop_None,"The thickness of LineGroup Extra lines, if enabled");
delete lg; //Coverity CID 174664
//decorations
ADD_PROPERTY_TYPE(HorizCenterLine ,(false),dgroup,App::Prop_None,"Show a horizontal centerline through view");