fix CIDs 154873, 154874, 153875, 153876, 154883, 154884, 154886

This commit is contained in:
wmayer 2016-12-18 13:27:34 +01:00
parent 5e0a972999
commit df8f7cfb7e
5 changed files with 21 additions and 12 deletions

View File

@ -21,7 +21,7 @@ std::string DrawProjGroupPy::representation(void) const
PyObject* DrawProjGroupPy::addProjection(PyObject* args)
{
const char* projType;
char* projType;
if (!PyArg_ParseTuple(args, "s", &projType)) {
throw Py::Exception();
@ -30,13 +30,17 @@ PyObject* DrawProjGroupPy::addProjection(PyObject* args)
DrawProjGroup* projGroup = getDrawProjGroupPtr();
App::DocumentObject* docObj = projGroup->addProjection(projType);
TechDraw::DrawProjGroupItem* newProj = dynamic_cast<TechDraw::DrawProjGroupItem *>( docObj );
if (!newProj) {
PyErr_SetString(PyExc_TypeError, "wrong type for adding projection");
return nullptr;
}
return new DrawProjGroupItemPy(newProj);
}
PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
{
const char* projType;
char* projType;
if (!PyArg_ParseTuple(args, "s", &projType)) {
throw Py::Exception();
@ -45,7 +49,7 @@ PyObject* DrawProjGroupPy::removeProjection(PyObject* args)
DrawProjGroup* projGroup = getDrawProjGroupPtr();
int i = projGroup->removeProjection(projType);
return PyInt_FromLong((long) i);;
return PyInt_FromLong((long) i);
}
PyObject* DrawProjGroupPy::purgeProjections(PyObject* /*args*/)
@ -53,12 +57,12 @@ PyObject* DrawProjGroupPy::purgeProjections(PyObject* /*args*/)
DrawProjGroup* projGroup = getDrawProjGroupPtr();
int i = projGroup->purgeProjections();
return PyInt_FromLong((long) i);;
return PyInt_FromLong((long) i);
}
PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
{
const char* projType;
char* projType;
if (!PyArg_ParseTuple(args, "s", &projType)) {
throw Py::Exception();
@ -67,6 +71,10 @@ PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
DrawProjGroup* projGroup = getDrawProjGroupPtr();
App::DocumentObject* docObj = projGroup->getProjObj(projType);
TechDraw::DrawProjGroupItem* newProj = dynamic_cast<TechDraw::DrawProjGroupItem *>( docObj );
if (!newProj) {
PyErr_SetString(PyExc_TypeError, "wrong type for getting item");
return nullptr;
}
return new DrawProjGroupItemPy(newProj);
}
@ -74,7 +82,7 @@ PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args)
//TODO: this is no longer required?
PyObject* DrawProjGroupPy::setViewOrientation(PyObject* args)
{
const char* projType;
char* projType;
PyObject* pcObj;
if (!PyArg_ParseTuple(args, "Os", &pcObj,&projType))
throw Py::Exception();

View File

@ -112,7 +112,7 @@ void QGIViewImage::draw()
return;
}
auto viewImage( dynamic_cast<TechDraw::DrawViewImage*>(getViewObject()) );
auto viewImage( static_cast<TechDraw::DrawViewImage*>(getViewObject()) );
QRectF newRect(0.0,0.0,viewImage->Width.getValue(),viewImage->Height.getValue());
m_cliparea->setRect(newRect.adjusted(-1,-1,1,1));

View File

@ -615,7 +615,7 @@ void QGIViewPart::drawMatting()
{
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
TechDraw::DrawViewDetail* dvd = nullptr;
if (viewPart->isDerivedFrom(TechDraw::DrawViewDetail::getClassTypeId())) {
if (viewPart && viewPart->isDerivedFrom(TechDraw::DrawViewDetail::getClassTypeId())) {
dvd = static_cast<TechDraw::DrawViewDetail*>(viewPart);
} else {
return;

View File

@ -108,7 +108,7 @@ void TaskLinkDim::loadAvailDims()
int found = 0;
for (; itView != pageViews.end(); itView++) {
if ((*itView)->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>((*itView));
TechDraw::DrawViewDimension* dim = static_cast<TechDraw::DrawViewDimension*>((*itView));
int dimRefType = dim->getRefType();
if (dimRefType == selRefType) { //potential matches
found++;
@ -190,7 +190,6 @@ bool TaskLinkDim::dimReferencesSelection(const TechDraw::DrawViewDimension* dim)
void TaskLinkDim::updateDims()
{
int iDim;
int count = ui->selector->selectedTreeWidget()->topLevelItemCount();
for (iDim=0; iDim<count; iDim++) {
@ -198,6 +197,8 @@ void TaskLinkDim::updateDims()
QString name = child->data(0, Qt::UserRole).toString();
App::DocumentObject* obj = m_page->getDocument()->getObject(name.toStdString().c_str());
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(obj);
if (!dim)
continue;
// std::vector<App::DocumentObject*> parts;
// for (unsigned int iPart = 0; iPart < m_subs.size(); iPart++) {
// parts.push_back(m_part);
@ -215,7 +216,7 @@ void TaskLinkDim::updateDims()
QString name = child->data(0, Qt::UserRole).toString();
App::DocumentObject* obj = m_page->getDocument()->getObject(name.toStdString().c_str());
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(obj);
if (dimReferencesSelection(dim)) {
if (dim && dimReferencesSelection(dim)) {
std::string measureType = "Projected";
std::string DimName = dim->getNameInDocument();
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.MeasureType = \'%s\'",

View File

@ -111,7 +111,7 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
m_page = multiView->findParentPage();
Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_page->getDocument());
Gui::ViewProvider* vp = activeGui->getViewProvider(m_page);
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
ViewProviderPage* dvp = static_cast<ViewProviderPage*>(vp);
m_mdi = dvp->getMDIViewPage();
setUiPrimary();