Preferences/VirtualMemory: fixed crash when exiting from not fully initialized application.

Signed-off-by: Augustin Cavalier <[email protected]>
This commit is contained in:
Dariusz Knociński
2015-12-15 21:21:23 -05:00
committed by Augustin Cavalier
parent 485f533935
commit c0349163fd
2 changed files with 15 additions and 3 deletions
@@ -120,8 +120,16 @@ SettingsWindow::SettingsWindow()
: :
BWindow(BRect(0, 0, 269, 172), B_TRANSLATE_SYSTEM_NAME("VirtualMemory"), BWindow(BRect(0, 0, 269, 172), B_TRANSLATE_SYSTEM_NAME("VirtualMemory"),
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS 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"); gBootDev = dev_for_path("/boot");
BAlignment align(B_ALIGN_LEFT, B_ALIGN_MIDDLE); BAlignment align(B_ALIGN_LEFT, B_ALIGN_MIDDLE);
@@ -252,6 +260,7 @@ SettingsWindow::SettingsWindow()
// TODO: We may want to run this at an interval // TODO: We may want to run this at an interval
_UpdateSwapInfo(); _UpdateSwapInfo();
fSetupComplete = true;
} }
@@ -341,8 +350,10 @@ SettingsWindow::MessageReceived(BMessage* message)
bool bool
SettingsWindow::QuitRequested() SettingsWindow::QuitRequested()
{ {
fSettings.SetWindowPosition(Frame().LeftTop()); if (!fSetupComplete)
return true;
fSettings.SetWindowPosition(Frame().LeftTop());
_RecordChoices(); _RecordChoices();
fSettings.WriteWindowSettings(); fSettings.WriteWindowSettings();
fSettings.WriteSwapSettings(); fSettings.WriteSwapSettings();
@@ -83,6 +83,7 @@ private:
BMenuField* fVolumeMenuField; BMenuField* fVolumeMenuField;
BStatusBar* fSwapUsageBar; BStatusBar* fSwapUsageBar;
Settings fSettings; Settings fSettings;
bool fSetupComplete;
}; };
#endif /* SETTINGS_WINDOW_H */ #endif /* SETTINGS_WINDOW_H */