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: 5aaa9e801d32
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: 77c242decc21
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 13, 2020

  1. Fixed bug where selecting "delete" from the context menu on a protoco…

    …l decoder overlay would delete the parent signal instead
    azonenberg committed Feb 13, 2020
    Copy the full SHA
    a6838bf View commit details
  2. Remove protocol decoders from top level when the last reference is de…

    …leted. Prevents UaF crash. Fixes #47.
    azonenberg committed Feb 13, 2020
    Copy the full SHA
    93bd1b7 View commit details
  3. "Delete" context menu item on a protocol decode overlay correctly rem…

    …oves the overlay trace. Fixes #8.
    azonenberg committed Feb 13, 2020
    Copy the full SHA
    77c242d View commit details
Showing with 44 additions and 7 deletions.
  1. +4 −1 glscopeclient/OscilloscopeWindow.h
  2. +10 −1 glscopeclient/WaveformArea.cpp
  3. +5 −3 glscopeclient/WaveformArea.h
  4. +25 −2 glscopeclient/WaveformArea_events.cpp
5 changes: 4 additions & 1 deletion glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -76,6 +76,9 @@ class OscilloscopeWindow : public Gtk::Window
void AddDecoder(ProtocolDecoder* decode)
{ m_decoders.emplace(decode); }

void RemoveDecoder(ProtocolDecoder* decode)
{ m_decoders.erase(decode); }

size_t GetScopeCount()
{ return m_scopes.size(); }

11 changes: 10 additions & 1 deletion glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ WaveformArea::~WaveformArea()
CleanupBufferObjects();

for(auto d : m_overlays)
d->Release();
OnRemoveOverlay(d);
m_overlays.clear();

for(auto m : m_moveExistingGroupItems)
@@ -120,6 +120,15 @@ WaveformArea::~WaveformArea()
m_moveExistingGroupItems.clear();
}

void WaveformArea::OnRemoveOverlay(ProtocolDecoder* decode)
{
//If we're about to remove the last reference to a decoder, make sure the parent knows
if(decode->GetRefCount() == 1)
m_parent->RemoveDecoder(decode);

decode->Release();
}

void WaveformArea::CleanupBufferObjects()
{
for(auto a : m_traceVAOs)
8 changes: 5 additions & 3 deletions glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -251,12 +251,14 @@ class WaveformArea : public Gtk::GLArea
float PicosecondsToXPosition(int64_t t);
int64_t XPositionToPicoseconds(float pix);

void OnRemoveOverlay(ProtocolDecoder* decode);

Oscilloscope* m_scope;
OscilloscopeChannel* m_channel;
OscilloscopeChannel* m_selectedChannel;
OscilloscopeChannel* m_channel; //The main waveform for this view
OscilloscopeChannel* m_selectedChannel; //The selected channel (either m_channel or an overlay)
OscilloscopeWindow* m_parent;

std::vector<ProtocolDecoder*> m_overlays;
std::vector<ProtocolDecoder*> m_overlays; //List of protocol decoders drawn on top of the signal
std::map<ProtocolDecoder*, int> m_overlayPositions;

double m_lastFrameStart;
27 changes: 25 additions & 2 deletions glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -426,7 +426,26 @@ void WaveformArea::OnCopyToExistingGroup(WaveformGroup* group)

void WaveformArea::OnHide()
{
m_parent->OnRemoveChannel(this);
//Delete the entire waveform area
if(m_selectedChannel == m_channel)
m_parent->OnRemoveChannel(this);

//Deleting an overlay
else
{
//LogDebug("Deleting overlay %s\n", m_selectedChannel->m_displayname.c_str());

//Remove the overlay from the list
for(size_t i=0; i<m_overlays.size(); i++)
{
if(m_overlays[i] == m_selectedChannel)
{
OnRemoveOverlay(m_overlays[i]);
m_overlays.erase(m_overlays.begin() + i);
break;
}
}
}
}

void WaveformArea::OnTogglePersistence()
@@ -438,7 +457,7 @@ void WaveformArea::OnTogglePersistence()
void WaveformArea::OnProtocolDecode(string name)
{
//Create a new decoder for the incoming signal
string color = GetDefaultChannelColor(g_numDecodes ++);
string color = GetDefaultChannelColor(g_numDecodes);
auto decode = ProtocolDecoder::CreateDecoder(name, color);

//Only one input with no config required? Do default configuration
@@ -457,6 +476,10 @@ void WaveformArea::OnProtocolDecode(string name)
dialog.ConfigureDecoder();
}

//Increment the color chooser only after we've decided to add the decode.
//If the dialog is canceled, don't do anything.
g_numDecodes ++;

//Set the name of the decoder based on the input channels etc
decode->SetDefaultName();