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: 6ad13bbf86e0
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: 965cf9cbd255
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 2, 2021

  1. Copy the full SHA
    bbcf5ae View commit details
  2. Copy the full SHA
    965cf9c View commit details
Showing with 86 additions and 28 deletions.
  1. +28 −10 src/glscopeclient/ProtocolAnalyzerWindow.cpp
  2. +58 −18 src/glscopeclient/ProtocolTreeModel.cpp
38 changes: 28 additions & 10 deletions src/glscopeclient/ProtocolAnalyzerWindow.cpp
Original file line number Diff line number Diff line change
@@ -81,9 +81,9 @@ ProtocolDisplayFilter::~ProtocolDisplayFilter()

bool ProtocolDisplayFilter::Validate(vector<string> headers)
{
//No clauses? error
//No clauses? valid all-pass filter
if(m_clauses.empty())
return false;
return true;

//We should always have one more clause than operator
if( (m_operators.size() + 1) != m_clauses.size())
@@ -131,7 +131,10 @@ bool ProtocolDisplayFilter::Match(
const Gtk::TreeRow& row,
ProtocolAnalyzerColumns& cols)
{
return Evaluate(row, cols) != "0";
if(m_clauses.empty())
return true;
else
return Evaluate(row, cols) != "0";
}

std::string ProtocolDisplayFilter::Evaluate(
@@ -740,16 +743,21 @@ void ProtocolAnalyzerWindow::OnApplyFilter()
{
//Parse the filter
size_t i = 0;
ProtocolDisplayFilter filter(m_filterBox.get_text(), i);
auto text = m_filterBox.get_text();
ProtocolDisplayFilter filter(text, i);

//If filter is invalid, can't do anything!
auto headers = m_decoder->GetHeaders();
if(!filter.Validate(headers))
return;

auto children = m_internalmodel->children();
for(auto row : children)
{
for(auto it = children.begin(); (*it); it++) //foreach loop will crash, can't use it!
{ //Something is funky with ProtocolTreeModel.
//The invalid iterators it returns don't compare equal to end().
//So cast the row to bool to see if it's really the end.
auto row = *it;

//No children? Filter this row
auto rowchildren = row->children();
if(rowchildren.empty())
@@ -759,8 +767,11 @@ void ProtocolAnalyzerWindow::OnApplyFilter()
else
{
row[m_columns.m_visible] = false;
for(auto child : rowchildren)

for(auto jt = rowchildren.begin(); (*jt); jt++) //same foreach problem here
{
auto child = *jt;

if(filter.Match(child, m_columns))
{
row[m_columns.m_visible] = true;
@@ -771,19 +782,26 @@ void ProtocolAnalyzerWindow::OnApplyFilter()
}

//Done
m_filterBox.set_name("activefilter");
if(text == "")
m_filterBox.set_name("");
else
m_filterBox.set_name("activefilter");
m_filterApplyButton.set_sensitive(false);
}

void ProtocolAnalyzerWindow::OnFilterChanged()
{
//Parse the filter
size_t i = 0;
ProtocolDisplayFilter filter(m_filterBox.get_text(), i);
auto text = m_filterBox.get_text();
ProtocolDisplayFilter filter(text, i);

if(filter.Validate(m_decoder->GetHeaders()))
{
m_filterBox.set_name("validfilter");
if(text == "")
m_filterBox.set_name("");
else
m_filterBox.set_name("validfilter");
m_filterApplyButton.set_sensitive();
}
else
76 changes: 58 additions & 18 deletions src/glscopeclient/ProtocolTreeModel.cpp
Original file line number Diff line number Diff line change
@@ -80,8 +80,10 @@ bool ProtocolTreeModel::iter_next_vfunc(const iterator& iter, iterator& iter_nex
ichild ++;
if(ichild >= (int)m_rows[irow].m_children.size())
{
g->user_data = GINT_TO_POINTER(-1);
g->user_data2 = GINT_TO_POINTER(-1);
g->user_data = GINT_TO_POINTER(0);
g->user_data2 = GINT_TO_POINTER(0);
g->user_data3 = GINT_TO_POINTER(0);
g->stamp = 0;
return false;
}
}
@@ -93,14 +95,18 @@ bool ProtocolTreeModel::iter_next_vfunc(const iterator& iter, iterator& iter_nex
//Save the final iterator
if(irow >= (int)m_rows.size())
{
g->user_data = GINT_TO_POINTER(-1);
g->user_data2 = GINT_TO_POINTER(-1);
g->user_data = GINT_TO_POINTER(0);
g->user_data2 = GINT_TO_POINTER(0);
g->user_data3 = GINT_TO_POINTER(0);
g->stamp = 0;
return false;
}
else
{
g->user_data = GINT_TO_POINTER(irow);
g->user_data2 = GINT_TO_POINTER(ichild);
g->stamp = 1;
return true;
}
return true;
}
@@ -112,14 +118,15 @@ bool ProtocolTreeModel::iter_children_vfunc(const iterator& parent, iterator& it
int irow = GPOINTER_TO_INT(g->user_data);
int ichild = GPOINTER_TO_INT(g->user_data2);

iter = iterator();
auto h = iter.gobj();

//If we're a child node, or have no children, nothing to do
if( (ichild >= 0) || m_rows[irow].m_children.empty() )
{
h->user_data = GINT_TO_POINTER(-1);
h->user_data2 = GINT_TO_POINTER(-1);
h->user_data = GINT_TO_POINTER(0);
h->user_data2 = GINT_TO_POINTER(0);
h->user_data3 = GINT_TO_POINTER(0);
h->stamp = 0;
return false;
}

@@ -128,6 +135,7 @@ bool ProtocolTreeModel::iter_children_vfunc(const iterator& parent, iterator& it
{
h->user_data = GINT_TO_POINTER(irow);
h->user_data2 = GINT_TO_POINTER(0);
h->stamp = 1;
return true;
}
}
@@ -178,8 +186,10 @@ bool ProtocolTreeModel::iter_nth_child_vfunc(const iterator& parent, int n, iter
//If we're a child node, or have insufficient children, nothing to do
if( (ichild >= 0) || ((int)m_rows[irow].m_children.size() <= n ) )
{
h->user_data = GINT_TO_POINTER(-1);
h->user_data2 = GINT_TO_POINTER(-1);
h->user_data = GINT_TO_POINTER(0);
h->user_data2 = GINT_TO_POINTER(0);
h->user_data3 = GINT_TO_POINTER(0);
h->stamp = 0;
return false;
}

@@ -188,24 +198,54 @@ bool ProtocolTreeModel::iter_nth_child_vfunc(const iterator& parent, int n, iter
{
h->user_data = GINT_TO_POINTER(irow);
h->user_data2 = GINT_TO_POINTER(n);
h->stamp = 1;
return true;
}
}

bool ProtocolTreeModel::iter_nth_root_child_vfunc(int n, iterator& iter) const
{
iter = iterator();
bool valid = n <= (int)m_rows.size();

auto g = iter.gobj();
g->user_data = GINT_TO_POINTER(n);
g->user_data2 = GINT_TO_POINTER(-1);
if(valid)
{
g->user_data = GINT_TO_POINTER(n);
g->user_data2 = GINT_TO_POINTER(-1);
g->stamp = 1;
}
else
{
g->user_data = GINT_TO_POINTER(0);
g->user_data2 = GINT_TO_POINTER(0);
g->user_data3 = GINT_TO_POINTER(0);
g->stamp = 0;
}

return n <= (int)m_rows.size();
return valid;
}

bool ProtocolTreeModel::iter_parent_vfunc(const iterator& /*child*/, iterator& /*iter*/) const
bool ProtocolTreeModel::iter_parent_vfunc(const iterator& child, iterator& iter) const
{
LogError("ProtocolTreeModel::iter_parent_vfunc unimplemented\n");
return false;
auto g = child.gobj();
auto second = GPOINTER_TO_INT(g->user_data2);

auto h = iter.gobj();
h->user_data2 = GINT_TO_POINTER(-1);

//Top level node, no parent available
if(second != -1)
{
h->user_data = GINT_TO_POINTER(0);
h->user_data2 = GINT_TO_POINTER(0);
h->user_data3 = GINT_TO_POINTER(0);
h->stamp = 0;
return false;
}

h->user_data = g->user_data;
h->stamp = 1;
return true;
}

Gtk::TreePath ProtocolTreeModel::get_path_vfunc(const iterator& iter) const
@@ -223,10 +263,9 @@ Gtk::TreePath ProtocolTreeModel::get_path_vfunc(const iterator& iter) const

bool ProtocolTreeModel::get_iter_vfunc(const Gtk::TreePath& path, iterator& iter) const
{
iter = iterator();

//we have children
auto g = iter.gobj();
g->stamp = 1;
if(path.size() > 1)
{
g->user_data = GINT_TO_POINTER(path[0]);
@@ -436,6 +475,7 @@ Gtk::TreeModel::iterator ProtocolTreeModel::erase(const iterator& iter)
path.push_back(second);
row_deleted(path);

h->stamp = 1;
return ret;
}