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

@@ -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"),