]> sigrok.org Git - pulseview.git/commitdiff
SigSession: Tidied update_signals
authorJoel Holdsworth <redacted>
Sat, 18 Jan 2014 16:04:07 +0000 (16:04 +0000)
committerJoel Holdsworth <redacted>
Sat, 18 Jan 2014 21:34:38 +0000 (21:34 +0000)
pv/sigsession.cpp

index 82fa877065254cd05c38f82aa64c19c54063732e..ecc125039303f36aae1b558722e3910e5b54c8e4 100644 (file)
@@ -384,7 +384,6 @@ void SigSession::update_signals(const sr_dev_inst *const sdi)
 {
        assert(_capture_state == Stopped);
 
-       shared_ptr<view::Signal> signal;
        unsigned int logic_probe_count = 0;
        unsigned int analog_probe_count = 0;
 
@@ -429,34 +428,42 @@ void SigSession::update_signals(const sr_dev_inst *const sdi)
        }
 
        // Make the Signals list
-       {
+       do {
                lock_guard<mutex> lock(_signals_mutex);
 
                _signals.clear();
 
-               if(sdi) {
-                       for (const GSList *l = sdi->probes; l; l = l->next) {
-                               sr_probe *const probe = (sr_probe *)l->data;
-                               assert(probe);
-
-                               switch(probe->type) {
-                               case SR_PROBE_LOGIC:
-                                       signal = shared_ptr<view::Signal>(
-                                               new view::LogicSignal(*this, probe,
-                                                       _logic_data));
-                                       break;
-
-                               case SR_PROBE_ANALOG:
-                                       signal = shared_ptr<view::Signal>(
-                                               new view::AnalogSignal(*this, probe,
-                                                       _analog_data));
-                                       break;
-                               }
-
-                               _signals.push_back(signal);
+               if(!sdi)
+                       break;
+
+               for (const GSList *l = sdi->probes; l; l = l->next) {
+                       shared_ptr<view::Signal> signal;
+                       sr_probe *const probe = (sr_probe *)l->data;
+                       assert(probe);
+
+                       switch(probe->type) {
+                       case SR_PROBE_LOGIC:
+                               signal = shared_ptr<view::Signal>(
+                                       new view::LogicSignal(*this, probe,
+                                               _logic_data));
+                               break;
+
+                       case SR_PROBE_ANALOG:
+                               signal = shared_ptr<view::Signal>(
+                                       new view::AnalogSignal(*this, probe,
+                                               _analog_data));
+                               break;
+
+                       default:
+                               assert(0);
+                               break;
                        }
+
+                       assert(signal);
+                       _signals.push_back(signal);
                }
-       }
+
+       } while(0);
 
        signals_changed();
 }