Fix possible crash in various view providers, fix formatting of Coin debug output, fix warning and compiler errors with Coin2 in SoDatumLabel

This commit is contained in:
unknown 2012-07-18 10:40:36 +02:00
parent 4e9412c0ae
commit 9c974969f5
7 changed files with 24 additions and 22 deletions

View File

@ -1366,13 +1366,13 @@ void messageHandlerCoin(const SoError * error, void * userdata)
switch (dbg->getSeverity())
{
case SoDebugError::INFO:
Base::Console().Message( msg );
Base::Console().Message("%s\n", msg);
break;
case SoDebugError::WARNING:
Base::Console().Warning( msg );
Base::Console().Warning("%s\n", msg);
break;
default: // error
Base::Console().Error( msg );
Base::Console().Error("%s\n", msg);
break;
}
#ifdef FC_OS_WIN32

View File

@ -115,7 +115,7 @@ bool ViewProviderChamfer::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(getObject());
App::DocumentObject *pcSupport;
App::DocumentObject *pcSupport = 0;
if (pcChamfer->Base.getValue()){
pcSupport = static_cast<Sketcher::SketchObject*>(pcChamfer->Base.getValue());
}

View File

@ -115,7 +115,7 @@ bool ViewProviderFillet::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(getObject());
App::DocumentObject *pcSupport;
App::DocumentObject *pcSupport = 0;
if (pcFillet->Base.getValue()){
pcSupport = static_cast<Sketcher::SketchObject*>(pcFillet->Base.getValue());
}

View File

@ -122,8 +122,8 @@ bool ViewProviderGroove::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcGroove->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcGroove->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();

View File

@ -121,8 +121,8 @@ bool ViewProviderPad::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcPad->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();

View File

@ -122,8 +122,8 @@ bool ViewProviderRevolution::onDelete(const std::vector<std::string> &)
{
// get the support and Sketch
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(getObject());
Sketcher::SketchObject *pcSketch;
App::DocumentObject *pcSupport;
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcRevolution->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();

View File

@ -136,10 +136,12 @@ void SoDatumLabel::drawImage()
void SoDatumLabel::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center)
{
// Set the bounding box using stored parameters
box.setBounds(this->bbox.getMin(),this->bbox.getMax() );
SbVec3f bbcenter = this->bbox.getCenter();
center.setValue(bbcenter[0], bbcenter[1], bbcenter[2]);
if (!this->bbox.isEmpty()) {
// Set the bounding box using stored parameters
box.setBounds(this->bbox.getMin(),this->bbox.getMax() );
SbVec3f bbcenter = this->bbox.getCenter();
center.setValue(bbcenter[0], bbcenter[1], bbcenter[2]);
}
}
void SoDatumLabel::generatePrimitives(SoAction * action)
@ -344,14 +346,14 @@ void SoDatumLabel::generatePrimitives(SoAction * action)
// Calculate coordinates for the first arrow
SbVec3f ar0, ar1, ar2;
ar0 = p1 + dir * 5 * margin;
ar1 = ar0 - dir * 0.866 * 2 * margin; // Base Point of Arrow
ar1 = ar0 - dir * 0.866f * 2 * margin; // Base Point of Arrow
ar2 = ar1 + norm * margin; // Triangular corners
ar1 -= norm * margin;
// Calculate coordinates for the second arrow
SbVec3f ar3, ar4, ar5;
ar3 = p2 - dir * 5 * margin;
ar4 = ar3 + dir * 0.866 * 2 * margin; // Base Point of 2nd Arrow
ar4 = ar3 + dir * 0.866f * 2 * margin; // Base Point of 2nd Arrow
ar5 = ar4 + norm * margin; // Triangular corners
ar4 -= norm * margin;
@ -547,11 +549,11 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
glVertex2f(par4[0], par4[1]);
glEnd();
SbVec3f ar1 = par1 + ((flipTriang) ? -1 : 1) * dir * 0.866 * 2 * margin;
SbVec3f ar1 = par1 + ((flipTriang) ? -1 : 1) * dir * 0.866f * 2 * margin;
SbVec3f ar2 = ar1 + norm * margin;
ar1 -= norm * margin;
SbVec3f ar3 = par4 - ((flipTriang) ? -1 : 1) * dir * 0.866 * 2 * margin;
SbVec3f ar3 = par4 - ((flipTriang) ? -1 : 1) * dir * 0.866f * 2 * margin;
SbVec3f ar4 = ar3 + norm * margin ;
ar3 -= norm * margin;
@ -614,7 +616,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
// Create the arrowhead
SbVec3f ar0 = p2;
SbVec3f ar1 = p2 - dir * 0.866 * 2 * margin;
SbVec3f ar1 = p2 - dir * 0.866f * 2 * margin;
SbVec3f ar2 = ar1 + norm * margin;
ar1 -= norm * margin;
@ -778,7 +780,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
// Calculate coordinates for the first arrow
SbVec3f ar0, ar1, ar2;
ar0 = p1 + dir * 4 * margin; // Tip of Arrow
ar1 = ar0 - dir * 0.866 * 2 * margin;
ar1 = ar0 - dir * 0.866f * 2 * margin;
ar2 = ar1 + norm * margin;
ar1 -= norm * margin;
@ -794,7 +796,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
// Calculate coordinates for the second arrow
SbVec3f ar3, ar4, ar5;
ar3 = p2 - dir * 4 * margin; // Tip of 2nd Arrow
ar4 = ar3 + dir * 0.866 * 2 * margin;
ar4 = ar3 + dir * 0.866f * 2 * margin;
ar5 = ar4 + norm * margin;
ar4 -= norm * margin;