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: 71e3f222ce09
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: 7ba0cd6a10f4
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Oct 11, 2020

  1. When deleting a channel or closing a protocol analyzer window, destro…

    …y the analyzer window if there are no other references. Fixes #177.
    azonenberg committed Oct 11, 2020
    Copy the full SHA
    7ba0cd6 View commit details
29 changes: 29 additions & 0 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -2099,6 +2099,35 @@ void OscilloscopeWindow::OnRemoveChannel(WaveformArea* w)
GarbageCollectGroups();
}

void OscilloscopeWindow::GarbageCollectAnalyzers()
{
//Check out our analyzers and see if any of them now have no references other than the analyzer window itself.
//If the analyzer is hidden, and there's no waveform views for it, get rid of it
set<ProtocolAnalyzerWindow*> garbage;
for(auto a : m_analyzers)
{
//It's visible. Still active.
if(a->get_visible())
continue;

//If there is only one reference, it's to the analyzer itself.
//Which is hidden, so we want to get rid of it.
auto chan = a->GetDecoder();
if(chan->GetRefCount() == 1)
garbage.emplace(a);
}

for(auto a : garbage)
{
m_analyzers.erase(a);
delete a;
}

//Need to reload the menu in case we deleted the last reference to something
RefreshChannelsMenu();
RefreshAnalyzerMenu();
}

bool OscilloscopeWindow::PollScopes()
{
//Avoid infinite loop if we have no scope to poll
1 change: 1 addition & 0 deletions src/glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ class OscilloscopeWindow : public Gtk::Window
void ClearAllPersistence();

void OnRemoveChannel(WaveformArea* w);
void GarbageCollectAnalyzers();

//need to be public so it can be called by WaveformArea
void OnMoveNew(WaveformArea* w, bool horizontal);
6 changes: 6 additions & 0 deletions src/glscopeclient/ProtocolAnalyzerWindow.cpp
Original file line number Diff line number Diff line change
@@ -787,3 +787,9 @@ void ProtocolAnalyzerWindow::OnFileExport()
//Done
fclose(fp);
}

void ProtocolAnalyzerWindow::on_hide()
{
Gtk::Widget::on_hide();
m_parent->GarbageCollectAnalyzers();
}
2 changes: 2 additions & 0 deletions src/glscopeclient/ProtocolAnalyzerWindow.h
Original file line number Diff line number Diff line change
@@ -136,6 +136,8 @@ class ProtocolAnalyzerWindow : public Gtk::Dialog
PacketDecoder* m_decoder;
WaveformArea* m_area;

virtual void on_hide();

void OnApplyFilter();
void OnFilterChanged();
void OnFileExport();
3 changes: 1 addition & 2 deletions src/glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -160,8 +160,7 @@ void WaveformArea::OnRemoveOverlay(StreamDescriptor filter)

filter.m_channel->Release();

//Need to reload the menu in case we deleted the last reference to this overlay
m_parent->RefreshChannelsMenu();
m_parent->GarbageCollectAnalyzers();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////