Added status check for settings read/write operations.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2018-09-09 12:39:19 +03:00
parent 2858122d9d
commit 8a3d50520f
2 changed files with 50 additions and 22 deletions

View File

@ -2797,6 +2797,9 @@ void TMainWindow::MeasurementGUI()
void TMainWindow::ReadSettings() void TMainWindow::ReadSettings()
{ {
const VTapeSettings *settings = qApp->TapeSettings(); const VTapeSettings *settings = qApp->TapeSettings();
if (settings->status() == QSettings::NoError)
{
restoreGeometry(settings->GetGeometry()); restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState()); restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), APP_VERSION);
@ -2807,6 +2810,11 @@ void TMainWindow::ReadSettings()
// Stack limit // Stack limit
//qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount()); //qApp->getUndoStack()->setUndoLimit(settings->GetUndoCount());
} }
else
{
qWarning() << tr("Cannot read settings from a malformed INI file.");
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::WriteSettings() void TMainWindow::WriteSettings()
@ -2815,6 +2823,12 @@ void TMainWindow::WriteSettings()
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));
settings->sync();
if (settings->status() == QSettings::AccessError)
{
qWarning() << tr("Cannot save settings. Access denied.");
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -3700,6 +3700,9 @@ void MainWindow::ReadSettings()
{ {
qCDebug(vMainWindow, "Reading settings."); qCDebug(vMainWindow, "Reading settings.");
const VSettings *settings = qApp->ValentinaSettings(); const VSettings *settings = qApp->ValentinaSettings();
if (settings->status() == QSettings::NoError)
{
restoreGeometry(settings->GetGeometry()); restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState()); restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), APP_VERSION);
@ -3716,6 +3719,11 @@ void MainWindow::ReadSettings()
isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible(); isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible();
isDockGroupsVisible = ui->dockWidgetGroups->isVisible(); isDockGroupsVisible = ui->dockWidgetGroups->isVisible();
} }
else
{
qWarning() << tr("Cannot read settings from a malformed INI file.");
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -3725,10 +3733,16 @@ void MainWindow::WriteSettings()
{ {
ActionDraw(true); ActionDraw(true);
VSettings *setings = qApp->ValentinaSettings(); VSettings *settings = qApp->ValentinaSettings();
setings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
setings->SetWindowState(saveState()); settings->SetWindowState(saveState());
setings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));
settings->sync();
if (settings->status() == QSettings::AccessError)
{
qWarning() << tr("Cannot save settings. Access denied.");
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------