Allow read-only flux sources in the GUI.

This commit is contained in:
David Given
2023-07-24 07:39:59 +02:00
parent b9ef5b7db8
commit 5b21e8798b
3 changed files with 33 additions and 10 deletions

View File

@@ -442,7 +442,7 @@ void Config::clearOptions()
invalidate();
}
static void setFluxSourceImpl(std::string filename, FluxSourceProto* proto)
static void setFluxSourceImpl(const std::string& filename, FluxSourceProto* proto)
{
for (const auto& it : fluxConstructors)
{
@@ -464,7 +464,7 @@ void Config::setFluxSource(std::string filename)
setFluxSourceImpl(filename, overrides()->mutable_flux_source());
}
static void setFluxSinkImpl(std::string filename, FluxSinkProto* proto)
static void setFluxSinkImpl(const std::string& filename, FluxSinkProto* proto)
{
for (const auto& it : fluxConstructors)
{

View File

@@ -224,8 +224,23 @@ public:
case SELECTEDSOURCE_FLUX:
{
globalConfig().setFluxSink(_selectedFluxfilename);
globalConfig().setFluxSource(_selectedFluxfilename);
try
{
globalConfig().setFluxSink(_selectedFluxfilename);
}
catch (const InapplicableValueException* e)
{
/* ignore */
}
try
{
globalConfig().setFluxSource(_selectedFluxfilename);
}
catch (const InapplicableValueException* e)
{
/* ignore */
}
break;
}
@@ -587,12 +602,12 @@ private:
/* The current set of options is invalid for some reason. Just
* swallow the errors. */
}
catch (const ErrorException& e)
{
/* This really isn't supposed to happen, but sometimes does and
* it crashes the whole program. */
return;
}
catch (const ErrorException& e)
{
/* This really isn't supposed to happen, but sometimes does and
* it crashes the whole program. */
return;
}
assert(!wxGetApp().IsWorkerThreadRunning());

View File

@@ -53,11 +53,19 @@ private:
bool FluxEngineApp::OnInit()
{
try
{
wxImage::AddHandler(new wxPNGHandler());
Bind(EXEC_EVENT_TYPE, &FluxEngineApp::OnExec, this);
_mainWindow = CreateMainWindow();
_mainWindow->Show(true);
return true;
}
catch (const ErrorException* e)
{
fmt::print(stderr, "Exception on startup: {}\n", e->message);
exit(1);
}
}
wxThread::ExitCode FluxEngineApp::Entry()