From 9c974969f5ea99178996bd16849d53bb7dc4b852 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Jul 2012 10:40:36 +0200 Subject: [PATCH] Fix possible crash in various view providers, fix formatting of Coin debug output, fix warning and compiler errors with Coin2 in SoDatumLabel --- src/Gui/Application.cpp | 6 ++--- .../PartDesign/Gui/ViewProviderChamfer.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderFillet.cpp | 2 +- src/Mod/PartDesign/Gui/ViewProviderGroove.cpp | 4 ++-- src/Mod/PartDesign/Gui/ViewProviderPad.cpp | 4 ++-- .../PartDesign/Gui/ViewProviderRevolution.cpp | 4 ++-- src/Mod/Sketcher/Gui/SoDatumLabel.cpp | 24 ++++++++++--------- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 5fdc7ed29..b7b8a8ea3 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -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 diff --git a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp index 0b8b0c289..bceabe64b 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderChamfer.cpp @@ -115,7 +115,7 @@ bool ViewProviderChamfer::onDelete(const std::vector &) { // get the support and Sketch PartDesign::Chamfer* pcChamfer = static_cast(getObject()); - App::DocumentObject *pcSupport; + App::DocumentObject *pcSupport = 0; if (pcChamfer->Base.getValue()){ pcSupport = static_cast(pcChamfer->Base.getValue()); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp index cd427c3c0..0e2b26c06 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderFillet.cpp @@ -115,7 +115,7 @@ bool ViewProviderFillet::onDelete(const std::vector &) { // get the support and Sketch PartDesign::Fillet* pcFillet = static_cast(getObject()); - App::DocumentObject *pcSupport; + App::DocumentObject *pcSupport = 0; if (pcFillet->Base.getValue()){ pcSupport = static_cast(pcFillet->Base.getValue()); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp b/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp index af7a24854..7b46d7681 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp @@ -122,8 +122,8 @@ bool ViewProviderGroove::onDelete(const std::vector &) { // get the support and Sketch PartDesign::Groove* pcGroove = static_cast(getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcGroove->Sketch.getValue()){ pcSketch = static_cast(pcGroove->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp index 1bb696ab7..e73e3dc5a 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp @@ -121,8 +121,8 @@ bool ViewProviderPad::onDelete(const std::vector &) { // get the support and Sketch PartDesign::Pad* pcPad = static_cast(getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcPad->Sketch.getValue()){ pcSketch = static_cast(pcPad->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp index 016764b5a..60b81c095 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp @@ -122,8 +122,8 @@ bool ViewProviderRevolution::onDelete(const std::vector &) { // get the support and Sketch PartDesign::Revolution* pcRevolution = static_cast(getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcRevolution->Sketch.getValue()){ pcSketch = static_cast(pcRevolution->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp index 7f3d1e260..45de2331c 100644 --- a/src/Mod/Sketcher/Gui/SoDatumLabel.cpp +++ b/src/Mod/Sketcher/Gui/SoDatumLabel.cpp @@ -136,10 +136,12 @@ void SoDatumLabel::drawImage() void SoDatumLabel::computeBBox(SoAction *action, SbBox3f &box, SbVec3f ¢er) { - // 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;