Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 96afff9c8202
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 12f521db1918
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Nov 12, 2020

  1. Sanity check connection config in startup dialog rather than letting …

    …user pick invalid/crashing configs. Fixes #199.
    azonenberg committed Nov 12, 2020
    Copy the full SHA
    12f521d View commit details
Showing with 47 additions and 2 deletions.
  1. +19 −0 src/glscopeclient/InstrumentConnectionDialog.cpp
  2. +2 −0 src/glscopeclient/InstrumentConnectionDialog.h
  3. +26 −2 src/glscopeclient/main.cpp
19 changes: 19 additions & 0 deletions src/glscopeclient/InstrumentConnectionDialog.cpp
Original file line number Diff line number Diff line change
@@ -110,3 +110,22 @@ string InstrumentConnectionDialog::GetConnectionString()
m_pathEntry.get_text().c_str());
return tmp;
}

bool InstrumentConnectionDialog::ValidateConfig()
{
//Must have stuff in each box
if(m_driverBox.get_active_text() == "")
return false;
if(m_transportBox.get_active_text() == "")
return false;
if(m_pathEntry.get_text() == "")
return false;

//For now, hard code check of null being legal only with siggen
if(m_transportBox.get_active_text() != "null")
return true;
if(m_driverBox.get_active_text() == "siggen")
return true;

return false;
}
2 changes: 2 additions & 0 deletions src/glscopeclient/InstrumentConnectionDialog.h
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@ class InstrumentConnectionDialog : public Gtk::Dialog

std::string GetConnectionString();

bool ValidateConfig();

protected:

Gtk::Grid m_grid;
28 changes: 26 additions & 2 deletions src/glscopeclient/main.cpp
Original file line number Diff line number Diff line change
@@ -244,8 +244,32 @@ int main(int argc, char* argv[])
if(scopes.empty() && fileToLoad.empty())
{
InstrumentConnectionDialog dlg;
if(dlg.run() != Gtk::RESPONSE_OK)
return 0;

while(true)
{
if(dlg.run() != Gtk::RESPONSE_OK)
return 0;

//If the user requested an illegal configuration, repeat

if(!dlg.ValidateConfig())
{
Gtk::MessageDialog mdlg(
"Invalid configuration specified.\n"
"\n"
"A driver and transport must always be selected.\n"
"\n"
"The NULL transport is only legal with the \"siggen\" driver.",
false,
Gtk::MESSAGE_ERROR,
Gtk::BUTTONS_OK,
true);
mdlg.run();
}

else
break;
}

scopes.push_back(dlg.GetConnectionString());
}