Fix #3224 Seg Fault in DrawProjGroup

- QGIViews for DrawProjGroupItem were not being deleted since
  DPGI belongs to DPG, not DrawPage.  Since there is a 1 to 1
  relationship between MDIViewPage and DrawPage, the check for
  membership in DrawPage is unnecessary.
This commit is contained in:
WandererFan
2017-11-24 19:59:12 -05:00
parent 56f07de8ad
commit 58e8cefc56
3 changed files with 6 additions and 11 deletions

View File

@@ -339,14 +339,9 @@ bool MDIViewPage::attachView(App::DocumentObject *obj)
void MDIViewPage::onDeleteObject(const App::DocumentObject& obj)
{
//if this page has a QView for this obj, delete it.
if (obj.isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
const App::DocumentObject* objPtr = &obj;
const TechDraw::DrawView* dv = static_cast<const TechDraw::DrawView*>(objPtr);
TechDraw::DrawPage* dvPg = dv->findParentPage();
if (dvPg == m_vpPage->getDrawPage()) {
//this is a DV that is on our page
(void) m_view->removeQViewByDrawView(dv);
}
(void) m_view->removeQViewByName(obj.getNameInDocument());
}
}

View File

@@ -217,14 +217,14 @@ int QGVPage::removeQView(QGIView *view)
return 0;
}
int QGVPage::removeQViewByDrawView(const TechDraw::DrawView* dv)
int QGVPage::removeQViewByName(const char* name)
{
std::vector<QGIView*> items = getViews();
QString qsName = QString::fromUtf8(dv->getNameInDocument());
QString qsName = QString::fromUtf8(name);
bool found = false;
QGIView* ourItem = nullptr;
for (auto& i:items) {
if (qsName == i->data(1).toString()) { //is there really a QGIV for this DV in scene?
if (qsName == i->data(1).toString()) { //is there a QGIV with this name in scene?
found = true;
ourItem = i;
break;

View File

@@ -84,7 +84,7 @@ public:
int addQView(QGIView * view);
int removeQView(QGIView *view);
int removeQViewByDrawView(const TechDraw::DrawView* dv);
int removeQViewByName(const char* name);
void removeQViewFromScene(QGIView *view);
//void setViews(const std::vector<QGIView *> &view) {views = view; }