Skip to content

Commit 73035b8

Browse files
committed
Merge branch 'master' into ConvertMatricesToMesh
2 parents e21becd + 7f12b38 commit 73035b8

File tree

10 files changed

+45
-31
lines changed

10 files changed

+45
-31
lines changed

src/Dataflow/Engine/Controller/PythonImpl.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,15 @@ namespace SCIRun {
582582

583583
PythonImpl::PythonImpl(NetworkEditorController& nec, GlobalCommandFactoryHandle cmdFactory) : impl_(new PythonImplImpl), nec_(nec), cmdFactory_(cmdFactory)
584584
{
585-
nec_.connectNetworkExecutionFinished([this](int) { executionFromPythonFinish(0); });
586-
nec_.connectModuleAdded([this](const std::string& id, ModuleHandle m, ModuleCounter mc) { pythonModuleAddedSlot(id, m, mc); });
587-
nec_.connectModuleRemoved([this](const ModuleId& id) { pythonModuleRemovedSlot(id); });
585+
connections_.push_back(nec_.connectNetworkExecutionFinished([this](int) { executionFromPythonFinish(0); }));
586+
connections_.push_back(nec_.connectModuleAdded([this](const std::string& id, ModuleHandle m, ModuleCounter mc) { pythonModuleAddedSlot(id, m, mc); }));
587+
connections_.push_back(nec_.connectModuleRemoved([this](const ModuleId& id) { pythonModuleRemovedSlot(id); }));
588+
}
589+
590+
PythonImpl::~PythonImpl()
591+
{
592+
for (const auto& c : connections_)
593+
c.disconnect();
588594
}
589595

590596
void PythonImpl::setUnlockFunc(boost::function<void()> unlock)

src/Dataflow/Engine/Controller/PythonImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace Engine {
4949
{
5050
public:
5151
PythonImpl(NetworkEditorController& nec, Core::Commands::GlobalCommandFactoryHandle cmdFactory);
52+
~PythonImpl();
5253
virtual boost::shared_ptr<PyModule> addModule(const std::string& name) override;
5354
virtual std::string removeModule(const std::string& id) override;
5455
virtual std::vector<boost::shared_ptr<PyModule>> moduleList() const override;
@@ -71,6 +72,7 @@ namespace Engine {
7172
NetworkEditorController& nec_;
7273
Core::Commands::GlobalCommandFactoryHandle cmdFactory_;
7374
boost::function<void()> unlock_;
75+
std::vector<boost::signals2::connection> connections_;
7476
};
7577

7678
}}}

src/Dataflow/Engine/Python/Tests/NetworkEditorPythonAPITests.cc

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ TEST_F(PythonControllerFunctionalTests, CanAddModule)
6464

6565
ASSERT_EQ(0, controller.getNetwork()->nmodules());
6666

67-
std::string command = "addModule(\"CreateLatVol\")";
67+
std::string command = "scirun_add_module(\"CreateLatVol\")";
6868
PythonInterpreter::Instance().run_string(command);
6969
//TODO: expose API directly on NEC?
7070
//controller.runPython("addModule(\"CreateLatVol\")");
@@ -80,7 +80,7 @@ TEST_F(PythonControllerFunctionalTests, CanAddMultipleModule)
8080

8181
ASSERT_EQ(0, controller.getNetwork()->nmodules());
8282

83-
std::string command = "addModule(\"CreateLatVol\")";
83+
std::string command = "scirun_add_module(\"CreateLatVol\")";
8484
PythonInterpreter::Instance().run_string(command);
8585
PythonInterpreter::Instance().run_string(command);
8686

@@ -96,14 +96,14 @@ TEST_F(PythonControllerFunctionalTests, CanChangeModuleState)
9696

9797
ASSERT_EQ(0, controller.getNetwork()->nmodules());
9898

99-
std::string command = "m = addModule(\"CreateLatVol\")";
99+
std::string command = "m = scirun_add_module(\"CreateLatVol\")";
100100
PythonInterpreter::Instance().run_string(command);
101101

102102
ASSERT_EQ(1, controller.getNetwork()->nmodules());
103103
auto mod = controller.getNetwork()->module(0);
104104
ASSERT_TRUE(mod != nullptr);
105105
EXPECT_EQ(16, mod->get_state()->getValue(CreateLatVol::XSize).toInt());
106-
command = "m.XSize = 14";
106+
command = "scirun_set_module_state(m, \"XSize\", 14)";
107107
PythonInterpreter::Instance().run_string(command);
108108
EXPECT_EQ(14, mod->get_state()->getValue(CreateLatVol::XSize).toInt());
109109
}
@@ -116,14 +116,14 @@ TEST_F(PythonControllerFunctionalTests, CanConnectModules)
116116

117117
ASSERT_EQ(0, controller.getNetwork()->nmodules());
118118

119-
PythonInterpreter::Instance().run_string("m1 = addModule(\"CreateLatVol\")");
120-
PythonInterpreter::Instance().run_string("m2 = addModule(\"CreateLatVol\")");
119+
PythonInterpreter::Instance().run_string("m1 = scirun_add_module(\"CreateLatVol\")");
120+
PythonInterpreter::Instance().run_string("m2 = scirun_add_module(\"CreateLatVol\")");
121121

122122
ASSERT_EQ(2, controller.getNetwork()->nmodules());
123123

124124
ASSERT_EQ(0, controller.getNetwork()->nconnections());
125125

126-
PythonInterpreter::Instance().run_string("m1.output[0] >> m2.input[0]");
126+
PythonInterpreter::Instance().run_string("scirun_connect_modules(m1, 0, m2, 0)");
127127
ASSERT_EQ(1, controller.getNetwork()->nconnections());
128128
}
129129

@@ -136,11 +136,11 @@ TEST_F(PythonControllerFunctionalTests, DISABLED_CanExecuteNetwork)
136136
NetworkEditorController controller(mf, sf, exe, nullptr, nullptr, nullptr);
137137
initModuleParameters(false);
138138

139-
PythonInterpreter::Instance().run_string("m1 = addModule(\"CreateLatVol\")");
139+
PythonInterpreter::Instance().run_string("m1 = scirun_add_module(\"CreateLatVol\")");
140140
ASSERT_TRUE(controller.getNetwork()->module(0)->executionState().currentState() == ModuleExecutionState::NotExecuted);
141-
PythonInterpreter::Instance().run_string("m2 = addModule(\"CreateLatVol\")");
142-
PythonInterpreter::Instance().run_string("m1.output[0] >> m2.input[0]");
143-
PythonInterpreter::Instance().run_string("executeAll()");
141+
PythonInterpreter::Instance().run_string("m2 = scirun_add_module(\"CreateLatVol\")");
142+
PythonInterpreter::Instance().run_string("scirun_connect_modules(m1, 0, m2, 0)");
143+
PythonInterpreter::Instance().run_string("scirun_execute_all()");
144144
// boost::this_thread::sleep(boost::posix_time::milliseconds(500));
145145
ASSERT_TRUE(controller.getNetwork()->module(0)->executionState().currentState() == ModuleExecutionState::Completed);
146146
//TODO: how do i assert on
@@ -193,12 +193,10 @@ TEST_F(PythonControllerFunctionalTests, CanGetModuleStateWithStaticFunction)
193193
auto mod = controller.getNetwork()->module(0);
194194
ASSERT_TRUE(mod != nullptr);
195195
EXPECT_EQ(16, mod->get_state()->getValue(CreateLatVol::XSize).toInt());
196-
command = "xs = scirun_get_module_state(m, \"XSize\")";
196+
command = "scirun_get_module_state(m, \"XSize\")";
197197
PythonInterpreter::Instance().run_string(command);
198198

199199
////???? need to get value back!!! how??
200-
201-
FAIL() << "todo";
202200
}
203201

204202
TEST_F(PythonControllerFunctionalTests, CanChangeModuleStateWithStaticFunction)
@@ -220,7 +218,7 @@ TEST_F(PythonControllerFunctionalTests, CanChangeModuleStateWithStaticFunction)
220218
command = "scirun_set_module_state(m, \"XSize\", 14)";
221219
PythonInterpreter::Instance().run_string(command);
222220
EXPECT_EQ(14, mod->get_state()->getValue(CreateLatVol::XSize).toInt());
223-
FAIL() << "todo";
221+
// FAIL() << "todo";
224222
}
225223

226224
TEST_F(PythonControllerFunctionalTests, CanConnectModulesWithStaticFunction)
@@ -244,7 +242,6 @@ TEST_F(PythonControllerFunctionalTests, CanConnectModulesWithStaticFunction)
244242

245243
TEST_F(PythonControllerFunctionalTests, CanDisconnectModulesWithStaticFunction)
246244
{
247-
248245
ModuleFactoryHandle mf(new HardCodedModuleFactory);
249246
NetworkEditorController controller(mf, nullptr, nullptr, nullptr, nullptr, nullptr);
250247
initModuleParameters(false);

src/Dataflow/Serialization/Network/Tests/LegacyNetworkFileImporterTests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ TEST(LegacyNetworkFileImporterTests, CanLoadNetworkFileWithDynamicPorts)
309309
EXPECT_EQ(0, networkFile->moduleTags.tags.size());
310310
}
311311

312-
TEST(LegacyNetworkFileImporterTests, CanLoadNetworkFileWithLotsOfState)
312+
TEST(LegacyNetworkFileImporterTests, DISABLED_CanLoadNetworkFileWithLotsOfState)
313313
{
314314
FAIL() << "todo";
315315
}

src/ExampleNets/regression/applyFEMVoltageSource.srn5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<name>Filename</name>
135135
<value>
136136
<which>2</which>
137-
<value>D:/SCIRunTestData/Matrices/bigSparse.mat</value>
137+
<value>%SCIRUNDATADIR%/Matrices/bigSparse.mat</value>
138138
</value>
139139
</second>
140140
</item>

src/Interface/Modules/Render/Tests/SRInterfaceTests.cc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,15 @@
3535
using namespace SCIRun;
3636
using namespace Render;
3737
using namespace Gui;
38+
#ifdef WIN32
39+
//TODO: these tests crash on OSX
40+
#define TEST_NAME(name) name
41+
#else
42+
#define TEST_NAME(name) DISABLED_##name
43+
#endif
3844

39-
TEST(SRInterfaceTest, CanInstantiateSRInterface)
45+
//TODO: crashes on Mac, works on Windows
46+
TEST(SRInterfaceTest, TEST_NAME(CanInstantiateSRInterface))
4047
{
4148
std::shared_ptr<GLContext> context;
4249
SRInterface srinterface(context);
@@ -46,8 +53,8 @@ class DummyGLContext : public GLContext
4653
{
4754
public:
4855
DummyGLContext() : GLContext(nullptr) {}
49-
virtual void makeCurrent() override
50-
{
56+
virtual void makeCurrent() override
57+
{
5158
std::cout << "DummyGLContext::makeCurrent called" << std::endl;
5259
}
5360
virtual void swapBuffers() override
@@ -56,12 +63,13 @@ class DummyGLContext : public GLContext
5663
}
5764
};
5865

59-
60-
TEST(SRInterfaceTest, CanRenderEmptyFrame)
66+
//TODO: this one crashes on windows now too.
67+
TEST(SRInterfaceTest,
68+
//TEST_NAME(CanRenderEmptyFrame))
69+
DISABLED_CanRenderEmptyFrame)
6170
{
6271
std::shared_ptr<GLContext> context(new DummyGLContext);
6372
SRInterface srinterface(context);
6473

6574
srinterface.doFrame(0, 50);
6675
}
67-

src/Modules/Legacy/Inverse/Tests/TikhonovFunctionalTest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ TEST_F(TikhonovFunctionalTest, loadIDNonSquareFwdMatrixANDRandData2)
156156
}
157157

158158
// ID square fwd matrix + RAND measured data - different sizes
159-
TEST_F(TikhonovFunctionalTest, loadIDSquareFwdMatrixANDRandDataDiffSizes)
159+
//TODO: waiting on text fix from @jcollfont
160+
TEST_F(TikhonovFunctionalTest, DISABLED_loadIDSquareFwdMatrixANDRandDataDiffSizes)
160161
{
161162
// create inputs
162163
auto tikAlgImp = makeModule("SolveInverseProblemWithTikhonov");

src/Modules/Legacy/Teem/Converters/Tests/ConvertNrrdToFieldTests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConvertNrrdToFieldTests : public ModuleTest
3737
{
3838
};
3939

40-
TEST_F(ConvertNrrdToFieldTests, CanCreate)
40+
TEST_F(ConvertNrrdToFieldTests, DISABLED_CanCreate)
4141
{
4242
auto rn = makeModule("ConvertNrrdToField");
4343

src/Modules/Legacy/Teem/Converters/Tests/ConvertNrrdToMatrixTests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ConvertNrrdToMatrixTests : public ModuleTest
3737
{
3838
};
3939

40-
TEST_F(ConvertNrrdToMatrixTests, CanCreate)
40+
TEST_F(ConvertNrrdToMatrixTests, DISABLED_CanCreate)
4141
{
4242
auto rn = makeModule("ConvertNrrdToMatrix");
4343

src/Modules/Legacy/Teem/DataIO/Tests/ReadNrrdTests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ReadNrrdTests : public ModuleTest
3737
{
3838
};
3939

40-
TEST_F(ReadNrrdTests, CanCreate)
40+
TEST_F(ReadNrrdTests, DISABLED_CanCreate)
4141
{
4242
auto rn = makeModule("ReadNrrd");
4343

0 commit comments

Comments
 (0)