X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=ec8082eb7cf0158ec0c85954a1bcc99e12227b86;hp=e42f730a4dc4d2900b6ee4e12f541f0c134ec0ee;hb=e6d85b8936b5b7aee80b03834f095fd5b52fe6f4;hpb=533b67b7af83c96af2692bac127b0023cca4dbe7 diff --git a/pv/session.cpp b/pv/session.cpp index e42f730a..ec8082eb 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -84,7 +84,6 @@ using std::string; using std::unique_lock; #endif using std::unique_ptr; -using std::unordered_set; using std::vector; using sigrok::Analog; @@ -106,6 +105,7 @@ using Gst::ElementFactory; using Gst::Pipeline; #endif +using pv::data::SignalGroup; using pv::util::Timestamp; using pv::views::trace::Signal; using pv::views::trace::AnalogSignal; @@ -116,6 +116,7 @@ namespace pv { shared_ptr Session::sr_context; Session::Session(DeviceManager &device_manager, QString name) : + shutting_down_(false), device_manager_(device_manager), default_name_(name), name_(name), @@ -127,8 +128,15 @@ Session::Session(DeviceManager &device_manager, QString name) : Session::~Session() { + shutting_down_ = true; + // Stop and join to the thread stop_capture(); + + for (SignalGroup* group : signal_groups_) { + group->clear(); + delete group; + } } DeviceManager& Session::device_manager() @@ -168,6 +176,16 @@ void Session::set_name(QString name) name_changed(); } +QString Session::save_path() const +{ + return save_path_; +} + +void Session::set_save_path(QString path) +{ + save_path_ = path; +} + const vector< shared_ptr > Session::views() const { return views_; @@ -235,7 +253,7 @@ void Session::save_setup(QSettings &settings) const int view_id = 0; i = 0; - for (const shared_ptr vb : views_) { + for (const shared_ptr& vb : views_) { shared_ptr tv = dynamic_pointer_cast(vb); if (tv) { for (const shared_ptr& time_item : tv->time_items()) { @@ -436,16 +454,17 @@ void Session::restore_settings(QSettings &settings) settings.endGroup(); } + + QString filename; if ((device_type == "sessionfile") || (device_type == "inputfile")) { if (device_type == "sessionfile") { settings.beginGroup("device"); - const QString filename = settings.value("filename").toString(); + filename = settings.value("filename").toString(); settings.endGroup(); - if (QFileInfo(filename).isReadable()) { + if (QFileInfo(filename).isReadable()) device = make_shared(device_manager_.context(), filename.toStdString()); - } } if (device_type == "inputfile") { @@ -464,6 +483,14 @@ void Session::restore_settings(QSettings &settings) set_name(QString::fromStdString( dynamic_pointer_cast(device)->display_name(device_manager_))); + + if (!filename.isEmpty()) { + // Only set the save path if we load an srzip file + if (device_type == "sessionfile") + set_save_path(QFileInfo(filename).absolutePath()); + + set_name(QFileInfo(filename).fileName()); + } } } @@ -501,14 +528,22 @@ void Session::set_device(shared_ptr device) // Remove all stored data and reset all views for (shared_ptr view : views_) { - view->clear_signals(); + view->clear_signalbases(); #ifdef ENABLE_DECODE view->clear_decode_signals(); #endif view->reset_view_state(); } + + for (SignalGroup* group : signal_groups_) { + group->clear(); + delete group; + } + signal_groups_.clear(); + for (const shared_ptr& d : all_signal_data_) d->clear(); + all_signal_data_.clear(); signalbases_.clear(); cur_logic_segment_.reset(); @@ -605,8 +640,12 @@ Session::input_format_options(vector user_spec, * data type. */ auto found = fmt_opts.find(key); - if (found == fmt_opts.end()) + if (found == fmt_opts.end()) { + qCritical() << "Supplied input option" << QString::fromStdString(key) << + "is not a valid option for this input module, it will be ignored!"; continue; + } + shared_ptr