Moved session creation into DevInst objects
[pulseview.git] / pv / mainwindow.cpp
index 9995e50ac2ef42650ba4d904a3d7b70c287336ff..57e9c51f8d51b647e8ea6164d61834c1d832d11a 100644 (file)
@@ -311,8 +311,9 @@ void MainWindow::update_device_list(
        }
 
        if (selected_device) {
+               // Setting the selected device in the sampling bar, generates
+               // an event which updates the selected device in the SigSession.
                _sampling_bar->set_selected_device(selected_device);
-               _session.set_device(selected_device);
        }
 }
 
@@ -321,9 +322,15 @@ void MainWindow::load_file(QString file_name)
        const QString errorMessage(
                QString("Failed to load file %1").arg(file_name));
        const QString infoMessage;
-       _session.load_file(file_name.toStdString(),
-               boost::bind(&MainWindow::session_error, this,
-                       errorMessage, infoMessage));
+
+       try {
+               _session.set_file(file_name.toStdString());
+       } catch(QString e) {
+               show_session_error(tr("Failed to load ") + file_name, e);
+       }
+
+       _session.start_capture(boost::bind(&MainWindow::session_error, this,
+               errorMessage, infoMessage));
 }
 
 void MainWindow::show_session_error(