]> sigrok.org Git - pulseview.git/blobdiff - pv/storesession.cpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / storesession.cpp
index f024a36cb8a8c49792eb5d8bd14d424429f42d2c..5eb6a8ad25aacbec2085500ad95a6ec9363a0ad1 100644 (file)
@@ -45,7 +45,6 @@ using std::mutex;
 using std::pair;
 using std::shared_ptr;
 using std::string;
-using std::unordered_set;
 using std::vector;
 
 using Glib::VariantBase;
@@ -93,7 +92,7 @@ const QString& StoreSession::error() const
 
 bool StoreSession::start()
 {
-       const unordered_set< shared_ptr<data::SignalBase> > sigs(session_.signalbases());
+       const vector< shared_ptr<data::SignalBase> > sigs(session_.signalbases());
 
        shared_ptr<data::Segment> any_segment;
        shared_ptr<data::LogicSegment> lsegment;
@@ -185,6 +184,9 @@ bool StoreSession::start()
                        {{ConfigKey::SAMPLERATE, Glib::Variant<guint64>::create(
                                any_segment->samplerate())}});
                output_->receive(meta);
+
+               auto header = context->create_header_packet(session_.get_acquisition_start_time());
+               output_->receive(header);
        } catch (Error& error) {
                error_ = tr("Error while saving: ") + error.what();
                return false;
@@ -302,10 +304,14 @@ void StoreSession::store_proc(vector< shared_ptr<data::SignalBase> > achannel_li
                units_stored_ = unit_count_ - (sample_count_ >> progress_scale);
        }
 
-       auto dfend = context->create_end_packet();
-       const string ldata_str = output_->receive(dfend);
-       if (output_stream_.is_open())
-               output_stream_ << ldata_str;
+       try {
+               auto dfend = context->create_end_packet();
+               const string ldata_str = output_->receive(dfend);
+               if (output_stream_.is_open())
+                       output_stream_ << ldata_str;
+       } catch (Error& error) {
+               error_ = tr("Error while saving: ") + error.what();
+       }
 
        // Zeroing the progress variables indicates completion
        units_stored_ = unit_count_ = 0;