From: Soeren Apel Date: Mon, 22 Apr 2019 13:39:13 +0000 (+0200) Subject: Style fixes X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=96dbf014dad1309d4ade9c14a8b46733e2f531c8;p=pulseview.git Style fixes --- diff --git a/main.cpp b/main.cpp index 1e4fe577..4bbddcc6 100644 --- a/main.cpp +++ b/main.cpp @@ -340,8 +340,7 @@ int main(int argc, char *argv[]) w.add_default_session(); else for (string& open_file : open_files) - w.add_session_with_file(open_file, open_file_format, - open_setup_file); + w.add_session_with_file(open_file, open_file_format, open_setup_file); #ifdef ENABLE_SIGNALS if (SignalHandler::prepare_signals()) { diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 638d75b5..fb749f57 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -399,13 +399,10 @@ void MainWindow::remove_session(shared_ptr session) } void MainWindow::add_session_with_file(string open_file_name, - string open_file_format, - string open_setup_file_name) + string open_file_format, string open_setup_file_name) { shared_ptr session = add_session(); - session->load_init_file(open_file_name, - open_file_format, - open_setup_file_name); + session->load_init_file(open_file_name, open_file_format, open_setup_file_name); } void MainWindow::add_default_session() diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index bf8be0ad..92fba45f 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -92,8 +92,7 @@ public: void remove_session(shared_ptr session); - void add_session_with_file(string open_file_name, - string open_file_format, + void add_session_with_file(string open_file_name, string open_file_format, string open_setup_file_name); void add_default_session(); diff --git a/pv/session.cpp b/pv/session.cpp index e412f501..c2fd2149 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -526,8 +526,7 @@ Session::input_format_options(vector user_spec, } void Session::load_init_file(const string &file_name, - const string &format, - const string &setup_file_name) + const string &format, const string &setup_file_name) { shared_ptr input_format; map input_opts; @@ -551,15 +550,12 @@ void Session::load_init_file(const string &file_name, input_format->options()); } - load_file(QString::fromStdString(file_name), - QString::fromStdString(setup_file_name), + load_file(QString::fromStdString(file_name), QString::fromStdString(setup_file_name), input_format, input_opts); } -void Session::load_file(QString file_name, - QString setup_file_name, - shared_ptr format, - const map &options) +void Session::load_file(QString file_name, QString setup_file_name, + shared_ptr format, const map &options) { const QString errorMessage( QString("Failed to load file %1").arg(file_name)); @@ -587,13 +583,13 @@ void Session::load_file(QString file_name, return; } - // Default the setup filename with a .pvs extension if none is provided + // Use the input file with .pvs extension if no setup file was given if (setup_file_name.isEmpty()) { setup_file_name = file_name; setup_file_name.truncate(setup_file_name.lastIndexOf('.')); setup_file_name.append(".pvs"); } - // Auto-load the setup if one exists + if (QFileInfo::exists(setup_file_name) && QFileInfo(setup_file_name).isReadable()) { QSettings settings_storage(setup_file_name, QSettings::IniFormat); restore_setup(settings_storage); diff --git a/pv/session.hpp b/pv/session.hpp index 7d9375a7..211fe1b3 100644 --- a/pv/session.hpp +++ b/pv/session.hpp @@ -172,12 +172,10 @@ public: void set_default_device(); - void load_init_file(const string &file_name, - const string &format, + void load_init_file(const string &file_name, const string &format, const string &setup_file_name); - void load_file(QString file_name, - QString setup_file_name = nullptr, + void load_file(QString file_name, QString setup_file_name = QString(), shared_ptr format = nullptr, const map &options = map()); diff --git a/pv/toolbars/mainbar.cpp b/pv/toolbars/mainbar.cpp index 02661023..666c28d3 100644 --- a/pv/toolbars/mainbar.cpp +++ b/pv/toolbars/mainbar.cpp @@ -705,7 +705,7 @@ void MainBar::import_file(shared_ptr format) options = dlg.options(); } - session_.load_file(file_name, nullptr, format, options); + session_.load_file(file_name, "", format, options); const QString abs_path = QFileInfo(file_name).absolutePath(); settings.setValue(SettingOpenDirectory, abs_path);