Skip to content

Commit 942bbcd

Browse files
committed
Fix casting problem
1 parent 10574fc commit 942bbcd

File tree

6 files changed

+49
-21
lines changed

6 files changed

+49
-21
lines changed

src/Core/Application/Preferences/Preferences.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <boost/filesystem.hpp>
3333
#include <boost/algorithm/string/predicate.hpp>
3434
#include <boost/algorithm/string/split.hpp>
35+
#include <boost/algorithm/string/replace.hpp>
3536
#include <boost/algorithm/string/classification.hpp>
3637
#ifdef BUILD_WITH_PYTHON
3738
#include <Core/Python/PythonInterpreter.h>
@@ -90,7 +91,8 @@ void Preferences::setDataDirectory(const boost::filesystem::path& path, bool run
9091
#ifdef BUILD_WITH_PYTHON
9192
if (runPython)
9293
{
93-
auto setDataDir = "import os; os.environ[\"SCIRUNDATADIR\"] = \"" + dataDir_.string() + "\"";
94+
auto forwardSlashPath = boost::replace_all_copy(dataDir_.string(), "\\", "/");
95+
auto setDataDir = "import os; os.environ[\"SCIRUNDATADIR\"] = \"" + forwardSlashPath + "\"";
9496
PythonInterpreter::Instance().run_string(setDataDir);
9597
}
9698
#endif

src/Core/Datatypes/Geometry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Datatypes
6161

6262
struct SCISHARE ModuleFeedback
6363
{
64-
// tag class
64+
virtual ~ModuleFeedback() {}
6565
};
6666

6767
}}}

src/Modules/Fields/EditMeshBoundingBox.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,19 @@ impl_(new EditMeshBoundingBoxImpl), widgetMoved_(false)
102102

103103
void EditMeshBoundingBox::processWidgetFeedback(const ModuleFeedback& var)
104104
{
105-
auto vsf = static_cast<const ViewSceneFeedback&>(var);
106-
if (vsf.selectionName.find(get_id()) != std::string::npos &&
107-
impl_->userWidgetTransform_ != vsf.transform)
105+
try
108106
{
109-
widgetMoved_ = true;
110-
adjustGeometryFromTransform(vsf.transform);
111-
enqueueExecuteAgain(false);
107+
auto vsf = dynamic_cast<const ViewSceneFeedback&>(var);
108+
if (vsf.selectionName.find(get_id()) != std::string::npos && impl_->userWidgetTransform_ != vsf.transform)
109+
{
110+
widgetMoved_ = true;
111+
adjustGeometryFromTransform(vsf.transform);
112+
enqueueExecuteAgain(false);
113+
}
114+
}
115+
catch (std::bad_cast&)
116+
{
117+
//ignore
112118
}
113119
}
114120

src/Modules/Legacy/Fields/GenerateSinglePointProbeFromField.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,19 @@ GenerateSinglePointProbeFromField::GenerateSinglePointProbeFromField()
102102

103103
void GenerateSinglePointProbeFromField::processWidgetFeedback(const ModuleFeedback& var)
104104
{
105-
auto vsf = static_cast<const ViewSceneFeedback&>(var);
106-
107-
if (vsf.selectionName.find(get_id()) != std::string::npos &&
108-
impl_->previousTransform_ != vsf.transform)
105+
try
106+
{
107+
auto vsf = dynamic_cast<const ViewSceneFeedback&>(var);
108+
if (vsf.selectionName.find(get_id()) != std::string::npos &&
109+
impl_->previousTransform_ != vsf.transform)
110+
{
111+
adjustPositionFromTransform(vsf.transform);
112+
enqueueExecuteAgain(false);
113+
}
114+
}
115+
catch (std::bad_cast&)
109116
{
110-
adjustPositionFromTransform(vsf.transform);
111-
enqueueExecuteAgain(false);
117+
//ignore
112118
}
113119
}
114120

src/Modules/Visualization/ShowField.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,18 @@ void ShowField::setStateDefaults()
195195

196196
void ShowField::processMeshComponentSelection(const ModuleFeedback& var)
197197
{
198-
auto sel = static_cast<const MeshComponentSelectionFeedback&>(var);
199-
if (sel.moduleId == get_id().id_)
198+
try
200199
{
200+
auto sel = dynamic_cast<const MeshComponentSelectionFeedback&>(var);
201+
if (sel.moduleId == get_id().id_)
202+
{
201203
get_state()->setValue(Name("Show" + sel.component), sel.selected);
202204
enqueueExecuteAgain(false);
205+
}
206+
}
207+
catch (std::bad_cast&)
208+
{
209+
//ignore
203210
}
204211
}
205212

src/Modules/Visualization/ShowString.cc

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,19 @@ void ShowString::setStateDefaults()
8282

8383
void ShowString::processWindowResizeFeedback(const ModuleFeedback& var)
8484
{
85-
auto vsf = static_cast<const ViewSceneFeedback&>(var);
86-
if (lastWindowSize_ != vsf.windowSize)
85+
try
8786
{
88-
lastWindowSize_ = vsf.windowSize;
89-
needReexecute_ = true;
90-
enqueueExecuteAgain(false);
87+
auto vsf = dynamic_cast<const ViewSceneFeedback&>(var);
88+
if (lastWindowSize_ != vsf.windowSize)
89+
{
90+
lastWindowSize_ = vsf.windowSize;
91+
needReexecute_ = true;
92+
enqueueExecuteAgain(false);
93+
}
94+
}
95+
catch (std::bad_cast&)
96+
{
97+
//ignore
9198
}
9299
}
93100

0 commit comments

Comments
 (0)