Skip to content

Commit 2633bf1

Browse files
author
Frederic Borry
committed
Fixed state handling in ChannelPropertyDialog
1 parent 2c2a41d commit 2633bf1

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

src/ngscopeclient/ChannelPropertiesDialog.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,7 @@ ChannelPropertiesDialog::ChannelPropertiesDialog(InstrumentChannel* chan, MainWi
5252
std::shared_ptr<Instrument> scopeSharedPointer(chan->GetInstrument(), [](Instrument*){});
5353
shared_ptr<Oscilloscope> sharedScope = dynamic_pointer_cast<Oscilloscope>(scopeSharedPointer);
5454
if(sharedScope)
55-
{
5655
m_state = session.GetOscillopscopeState(sharedScope);
57-
if(!m_state)
58-
LogError("Could not get OscilloscopeState for scope %s.\n",chan->GetInstrument()->GetName().c_str());
59-
60-
}
61-
else
62-
{
63-
LogError("Could not get cast Instrument %s to Oscilloscope.\n",chan->GetInstrument()->GetName().c_str());
64-
}
6556

6657
auto ochan = dynamic_cast<OscilloscopeChannel*>(chan);
6758
if(!ochan)
@@ -359,7 +350,7 @@ bool ChannelPropertiesDialog::DoRender()
359350
m_threshold = yunit.PrettyPrint(m_committedThreshold);
360351

361352
// Tell intrument thread that the scope state has to be updated
362-
m_state->m_needsUpdate[index] = true;
353+
if(m_state) m_state->m_needsUpdate[index] = true;
363354
}
364355
HelpMarker("Switching threshold for the digital input buffer");
365356
}
@@ -376,7 +367,7 @@ bool ChannelPropertiesDialog::DoRender()
376367
m_hysteresis = yunit.PrettyPrint(m_committedHysteresis);
377368

378369
// Tell intrument thread that the scope state has to be updated
379-
m_state->m_needsUpdate[index] = true;
370+
if(m_state) m_state->m_needsUpdate[index] = true;
380371
}
381372
HelpMarker("Hysteresis for the digital input buffer");
382373
}
@@ -423,7 +414,7 @@ bool ChannelPropertiesDialog::DoRender()
423414
}
424415

425416
// Tell intrument thread that the scope state has to be updated
426-
m_state->m_needsUpdate[index] = true;
417+
if(m_state) m_state->m_needsUpdate[index] = true;
427418
}
428419
if(m_probe != "")
429420
ImGui::EndDisabled();
@@ -438,7 +429,7 @@ bool ChannelPropertiesDialog::DoRender()
438429
ochan->SetCoupling(m_couplings[m_coupling]);
439430

440431
// Tell intrument thread that the scope state has to be updated
441-
m_state->m_needsUpdate[index] = true;
432+
if(m_state) m_state->m_needsUpdate[index] = true;
442433
}
443434
HelpMarker("Coupling configuration for the input");
444435
}
@@ -452,7 +443,7 @@ bool ChannelPropertiesDialog::DoRender()
452443
ochan->SetBandwidthLimit(m_bwlValues[m_bwl]);
453444

454445
// Tell intrument thread that the scope state has to be updated
455-
m_state->m_needsUpdate[index] = true;
446+
if(m_state) m_state->m_needsUpdate[index] = true;
456447
}
457448
HelpMarker("Hardware bandwidth limiter setting");
458449
}
@@ -505,7 +496,7 @@ bool ChannelPropertiesDialog::DoRender()
505496
ochan->Invert(m_inverted);
506497

507498
// Tell intrument thread that the scope state has to be updated
508-
m_state->m_needsUpdate[index] = true;
499+
if(m_state) m_state->m_needsUpdate[index] = true;
509500
}
510501

511502
HelpMarker(
@@ -603,7 +594,7 @@ bool ChannelPropertiesDialog::DoRender()
603594
ochan->SetOffset(m_committedOffset[i], i);
604595

605596
// Tell intrument thread that the scope state has to be updated
606-
m_state->m_needsUpdate[index] = true;
597+
if(m_state) m_state->m_needsUpdate[index] = true;
607598
}
608599

609600
//Same for range
@@ -620,7 +611,7 @@ bool ChannelPropertiesDialog::DoRender()
620611
ochan->SetVoltageRange(m_committedRange[i], i);
621612

622613
// Tell intrument thread that the scope state has to be updated
623-
m_state->m_needsUpdate[index] = true;
614+
if(m_state) m_state->m_needsUpdate[index] = true;
624615
}
625616

626617
ImGui::PopID();

0 commit comments

Comments
 (0)