]> sigrok.org Git - pulseview.git/blobdiff - pv/view/decodetrace.cpp
DecodeTrace: Don't dereference iterator pointing at end of container.
[pulseview.git] / pv / view / decodetrace.cpp
index c0c4d167e109f17f16eeb374aba8420d863dd86f..020ce77090acd4d86bc06ba49185be1282106a02 100644 (file)
@@ -29,6 +29,8 @@ extern "C" {
 #include <tuple>
 
 #include <boost/functional/hash.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
 
 #include <QAction>
 #include <QApplication>
@@ -708,8 +710,7 @@ QComboBox* DecodeTrace::create_channel_selector(
 {
        assert(dec);
 
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const auto &sigs(session_.signals());
+       const auto sigs(session_.signals());
 
        vector< shared_ptr<Signal> > sig_list(sigs.begin(), sigs.end());
        std::sort(sig_list.begin(), sig_list.end(),
@@ -732,7 +733,9 @@ QComboBox* DecodeTrace::create_channel_selector(
                {
                        selector->addItem(s->name(),
                                qVariantFromValue((void*)s.get()));
-                       if ((*channel_iter).second == s)
+
+                       if (channel_iter != dec->channels().end() &&
+                               (*channel_iter).second == s)
                                selector->setCurrentIndex(
                                        selector->count() - 1);
                }
@@ -747,8 +750,7 @@ void DecodeTrace::commit_decoder_channels(shared_ptr<data::decode::Decoder> &dec
 
        map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
 
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const unordered_set< shared_ptr<Signal> > &sigs(session_.signals());
+       const unordered_set< shared_ptr<Signal> > sigs(session_.signals());
 
        for (const ChannelSelector &s : channel_selectors_)
        {