From c0349163fdeaea7fced0237194abc69215503a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Knoci=C5=84ski?= Date: Thu, 27 Mar 2014 20:51:03 +0100 Subject: [PATCH] Preferences/VirtualMemory: fixed crash when exiting from not fully initialized application. Signed-off-by: Augustin Cavalier --- .../virtualmemory/SettingsWindow.cpp | 17 ++++++++++++++--- src/preferences/virtualmemory/SettingsWindow.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/preferences/virtualmemory/SettingsWindow.cpp b/src/preferences/virtualmemory/SettingsWindow.cpp index a9d1d58483..155264e62f 100644 --- a/src/preferences/virtualmemory/SettingsWindow.cpp +++ b/src/preferences/virtualmemory/SettingsWindow.cpp @@ -120,8 +120,16 @@ SettingsWindow::SettingsWindow() : BWindow(BRect(0, 0, 269, 172), B_TRANSLATE_SYSTEM_NAME("VirtualMemory"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS - | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) - + | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS), + fSwapEnabledCheckBox(NULL), + fSwapAutomaticCheckBox(NULL), + fSizeSlider(NULL), + fDefaultsButton(NULL), + fRevertButton(NULL), + fWarningStringView(NULL), + fVolumeMenuField(NULL), + fSwapUsageBar(NULL), + fSetupComplete(false) { gBootDev = dev_for_path("/boot"); BAlignment align(B_ALIGN_LEFT, B_ALIGN_MIDDLE); @@ -252,6 +260,7 @@ SettingsWindow::SettingsWindow() // TODO: We may want to run this at an interval _UpdateSwapInfo(); + fSetupComplete = true; } @@ -341,8 +350,10 @@ SettingsWindow::MessageReceived(BMessage* message) bool SettingsWindow::QuitRequested() { - fSettings.SetWindowPosition(Frame().LeftTop()); + if (!fSetupComplete) + return true; + fSettings.SetWindowPosition(Frame().LeftTop()); _RecordChoices(); fSettings.WriteWindowSettings(); fSettings.WriteSwapSettings(); diff --git a/src/preferences/virtualmemory/SettingsWindow.h b/src/preferences/virtualmemory/SettingsWindow.h index d5df854d22..437876e8a0 100644 --- a/src/preferences/virtualmemory/SettingsWindow.h +++ b/src/preferences/virtualmemory/SettingsWindow.h @@ -83,6 +83,7 @@ private: BMenuField* fVolumeMenuField; BStatusBar* fSwapUsageBar; Settings fSettings; + bool fSetupComplete; }; #endif /* SETTINGS_WINDOW_H */