@@ -262,50 +262,49 @@ MainWindow::MainWindow(QWidget *parent)
});
}
MainWindow::~MainWindow()
{
if (serialPort.isOpen())
serialPort.close();
delete plotMan;
delete ui;
ui = NULL; // we check if ui is deleted in messageHandler
void MainWindow::closeEvent(QCloseEvent * event)
// save snapshots
if (!snapshotMan.isAllSaved())
auto clickedButton = QMessageBox::warning(
this, "Closing SerialPlot",
"There are un-saved snapshots. If you close you will loose the data.",
QMessageBox::Discard | QMessageBox::Discard,
QMessageBox::Cancel);
QMessageBox::Discard, QMessageBox::Cancel);
if (clickedButton == QMessageBox::Cancel)
event->ignore();
return;
// save settings
QSettings settings("serialplot", "serialplot");
saveAllSettings(&settings);
settings.sync();
if (settings.status() != QSettings::NoError)
QString errorText;
if (settings.status() == QSettings::AccessError)
QString file = settings.fileName();
errorText = QString("Serialplot cannot save settings due to access error. \
This happens if you have run serialplot as root (with sudo for ex.) previously. \
Try fixing the permissions of file: %1, or just delete it.").arg(file);
else
Status change: