X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=008ee6a282cc3ba326abe6b106a503576d7d753c;hp=a9bb554efd08a34e14b3375955b0ee6679ae31ea;hb=30677c1392b54604b01558cf29b44572731659fc;hpb=feeb4a7ea1a286d95bfb8d218b1b0ea3faf1604e diff --git a/pv/session.cpp b/pv/session.cpp index a9bb554e..008ee6a2 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -521,7 +521,7 @@ void Session::load_file(QString file_name, new devices::SessionFile( device_manager_.context(), file_name.toStdString()))); - } catch (Error e) { + } catch (Error& e) { main_bar_->session_error(tr("Failed to load ") + file_name, e.what()); set_default_device(); main_bar_->update_device_list(); @@ -732,7 +732,7 @@ shared_ptr Session::add_decode_signal() // Add the decode signal to all views for (shared_ptr view : views_) view->add_decode_signal(signal); - } catch (runtime_error e) { + } catch (runtime_error& e) { remove_decode_signal(signal); return nullptr; } @@ -934,7 +934,7 @@ void Session::sample_thread_proc(function error_handler) try { device_->start(); - } catch (Error e) { + } catch (Error& e) { error_handler(e.what()); return; } @@ -944,7 +944,7 @@ void Session::sample_thread_proc(function error_handler) try { device_->run(); - } catch (Error e) { + } catch (Error& e) { error_handler(e.what()); set_capture_state(Stopped); return; @@ -1080,10 +1080,21 @@ void Session::feed_in_trigger() } } - // If no frame began then this is a trigger for a new segment - const uint32_t segment_id = - (frame_began_) ? highest_segment_id_ : (highest_segment_id_ + 1); + uint32_t segment_id = 0; // Default segment when no frames are used + + // If a frame began, we'd ideally be able to use the highest segment ID for + // the trigger. However, as new segments are only created when logic or + // analog data comes in, this doesn't work if the trigger appears right + // after the beginning of the frame, before any sample data. + // For this reason, we use highest segment ID + 1 if no sample data came in + // yet and the highest segment ID otherwise. + if (frame_began_) { + segment_id = highest_segment_id_; + if (!cur_logic_segment_ && (cur_analog_segments_.size() == 0)) + segment_id++; + } + // TODO Create timestamp from segment start time + segment's current sample count util::Timestamp timestamp = sample_count / get_samplerate(); trigger_list_.emplace_back(segment_id, timestamp); trigger_event(segment_id, timestamp); @@ -1242,7 +1253,7 @@ void Session::data_feed_in(shared_ptr device, case SR_DF_LOGIC: try { feed_in_logic(dynamic_pointer_cast(packet->payload())); - } catch (bad_alloc) { + } catch (bad_alloc&) { out_of_memory_ = true; device_->stop(); } @@ -1251,7 +1262,7 @@ void Session::data_feed_in(shared_ptr device, case SR_DF_ANALOG: try { feed_in_analog(dynamic_pointer_cast(packet->payload())); - } catch (bad_alloc) { + } catch (bad_alloc&) { out_of_memory_ = true; device_->stop(); }