Commit 9a2bd0d9 authored by pixhawk's avatar pixhawk

Persistence fixes

parent 98f17071
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#define WITH_TEXT_TO_SPEECH 1 #define WITH_TEXT_TO_SPEECH 1
#define QGC_APPLICATION_NAME "QGroundControl" #define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION "v. 0.9.2 (Alpha RC1)" #define QGC_APPLICATION_VERSION "v. 0.9.0 (Alpha RC4)"
namespace QGC namespace QGC
......
...@@ -210,9 +210,6 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -210,9 +210,6 @@ MainWindow::MainWindow(QWidget *parent):
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
// Store settings
storeSettings();
delete mavlink; delete mavlink;
delete joystick; delete joystick;
...@@ -629,6 +626,7 @@ void MainWindow::showCentralWidget() ...@@ -629,6 +626,7 @@ void MainWindow::showCentralWidget()
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (isVisible()) storeViewState();
storeSettings(); storeSettings();
aboutToCloseFlag = true; aboutToCloseFlag = true;
mavlink->storeSettings(); mavlink->storeSettings();
...@@ -752,6 +750,8 @@ void MainWindow::storeSettings() ...@@ -752,6 +750,8 @@ void MainWindow::storeSettings()
settings.setValue("AUTO_RECONNECT", autoReconnect); settings.setValue("AUTO_RECONNECT", autoReconnect);
settings.setValue("CURRENT_STYLE", currentStyle); settings.setValue("CURRENT_STYLE", currentStyle);
settings.endGroup(); settings.endGroup();
if (!aboutToCloseFlag && isVisible())
{
settings.setValue(getWindowGeometryKey(), saveGeometry()); settings.setValue(getWindowGeometryKey(), saveGeometry());
// Save the last current view in any case // Save the last current view in any case
settings.setValue("CURRENT_VIEW", currentView); settings.setValue("CURRENT_VIEW", currentView);
...@@ -760,6 +760,7 @@ void MainWindow::storeSettings() ...@@ -760,6 +760,7 @@ void MainWindow::storeSettings()
// Save the current view only if a UAS is connected // Save the current view only if a UAS is connected
if (UASManager::instance()->getUASList().length() > 0) settings.setValue("CURRENT_VIEW_WITH_UAS_CONNECTED", currentView); if (UASManager::instance()->getUASList().length() > 0) settings.setValue("CURRENT_VIEW_WITH_UAS_CONNECTED", currentView);
// Save the current power mode // Save the current power mode
}
settings.setValue("LOW_POWER_MODE", lowPowerMode); settings.setValue("LOW_POWER_MODE", lowPowerMode);
settings.sync(); settings.sync();
} }
...@@ -1314,6 +1315,8 @@ void MainWindow::UASCreated(UASInterface* uas) ...@@ -1314,6 +1315,8 @@ void MainWindow::UASCreated(UASInterface* uas)
*/ */
void MainWindow::storeViewState() void MainWindow::storeViewState()
{ {
if (!aboutToCloseFlag)
{
// Save current state // Save current state
settings.setValue(getWindowStateKey(), saveState(QGC::applicationVersion())); settings.setValue(getWindowStateKey(), saveState(QGC::applicationVersion()));
settings.setValue(getWindowStateKey()+"CENTER_WIDGET", centerStack->currentIndex()); settings.setValue(getWindowStateKey()+"CENTER_WIDGET", centerStack->currentIndex());
...@@ -1322,6 +1325,7 @@ void MainWindow::storeViewState() ...@@ -1322,6 +1325,7 @@ void MainWindow::storeViewState()
// perspective. // perspective.
windowStateVal = this->windowState(); windowStateVal = this->windowState();
settings.setValue(getWindowGeometryKey(), saveGeometry()); settings.setValue(getWindowGeometryKey(), saveGeometry());
}
} }
void MainWindow::loadViewState() void MainWindow::loadViewState()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment