From 11102e3848bcd78ce9a90478ad6992f966fae5c6 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 19 Nov 2011 18:14:45 -0500 Subject: [PATCH] Reworked GUI settings storage. - Simplified things so each window simply records all its settings into a BMessage, which is what ultimately goes into the actual UI settings. - Added settings storage/retrieval to the various sub views of the team window. This means that the column widths/positioning on all views hosting a column list view are now also preserved and restored. --- .../gui/inspector_window/InspectorWindow.cpp | 42 ++--- .../gui/inspector_window/InspectorWindow.h | 8 +- .../gui/team_window/BreakpointListView.cpp | 28 ++++ .../gui/team_window/BreakpointListView.h | 3 + .../gui/team_window/BreakpointsView.cpp | 25 +++ .../gui/team_window/BreakpointsView.h | 3 + .../gui/team_window/ImageFunctionsView.cpp | 28 ++++ .../gui/team_window/ImageFunctionsView.h | 3 + .../gui/team_window/ImageListView.cpp | 28 ++++ .../gui/team_window/ImageListView.h | 3 + .../gui/team_window/RegistersView.cpp | 28 ++++ .../gui/team_window/RegistersView.h | 3 + .../gui/team_window/StackTraceView.cpp | 28 ++++ .../gui/team_window/StackTraceView.h | 3 + .../gui/team_window/TeamWindow.cpp | 153 ++++++++++++------ .../gui/team_window/ThreadListView.cpp | 30 ++++ .../gui/team_window/ThreadListView.h | 3 + .../gui/team_window/VariablesView.cpp | 29 ++++ .../gui/team_window/VariablesView.h | 3 + 19 files changed, 378 insertions(+), 73 deletions(-) diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp index 742e5b2acb..c3612e6576 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.cpp @@ -267,7 +267,7 @@ bool InspectorWindow::QuitRequested() { BMessage settings(MSG_INSPECTOR_WINDOW_CLOSED); - SaveSettings(&settings); + SaveSettings(settings); BMessenger(fTarget).SendMessage(&settings); return true; @@ -288,35 +288,40 @@ InspectorWindow::MemoryBlockRetrieved(TeamMemoryBlock* block) status_t -InspectorWindow::LoadSettings(const GUITeamUISettings* settings) +InspectorWindow::LoadSettings(const GUITeamUISettings& settings) { AutoLocker lock(this); if (!lock.IsLocked()) return B_ERROR; - BVariant value; - if (settings->Value("inspectorWindowFrame", value) == B_OK) { - BRect frameRect = value.ToRect(); + BMessage inspectorSettings; + if (settings.Settings("inspectorWindow", inspectorSettings) == B_OK) + return B_OK; + + BRect frameRect; + if (inspectorSettings.FindRect("frame", &frameRect) == B_OK) { ResizeTo(frameRect.Width(), frameRect.Height()); MoveTo(frameRect.left, frameRect.top); } - _LoadMenuFieldMode(fHexMode, "Hex", settings); - _LoadMenuFieldMode(fEndianMode, "Endian", settings); - _LoadMenuFieldMode(fTextMode, "Text", settings); + _LoadMenuFieldMode(fHexMode, "Hex", inspectorSettings); + _LoadMenuFieldMode(fEndianMode, "Endian", inspectorSettings); + _LoadMenuFieldMode(fTextMode, "Text", inspectorSettings); return B_OK; } status_t -InspectorWindow::SaveSettings(BMessage* settings) +InspectorWindow::SaveSettings(BMessage& settings) { AutoLocker lock(this); if (!lock.IsLocked()) return B_ERROR; - status_t error = settings->AddRect("inspectorWindowFrame", Frame()); + settings.MakeEmpty(); + + status_t error = settings.AddRect("frame", Frame()); if (error != B_OK) return error; @@ -338,17 +343,16 @@ InspectorWindow::SaveSettings(BMessage* settings) void InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name, - const GUITeamUISettings* settings) + const BMessage& settings) { - BVariant value; BString fieldName; - fieldName.SetToFormat("inspectorWindow%sMode", name); - status_t error = settings->Value(fieldName.String(), value); - if (error == B_OK) { + int32 mode; + fieldName.SetToFormat("%sMode", name); + if (settings.FindInt32(fieldName.String(), &mode) == B_OK) { BMenu* menu = field->Menu(); for (int32 i = 0; i < menu->CountItems(); i++) { BInvoker* item = menu->ItemAt(i); - if (item->Message()->FindInt32("mode") == value.ToInt32()) { + if (item->Message()->FindInt32("mode") == mode) { item->Invoke(); break; } @@ -359,14 +363,14 @@ InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name, status_t InspectorWindow::_SaveMenuFieldMode(BMenuField* field, const char* name, - BMessage* settings) + BMessage& settings) { BMenuItem* item = field->Menu()->FindMarked(); if (item && item->Message()) { int32 mode = item->Message()->FindInt32("mode"); BString fieldName; - fieldName.SetToFormat("inspectorWindow%sMode", name); - return settings->AddInt32(fieldName.String(), mode); + fieldName.SetToFormat("%sMode", name); + return settings.AddInt32(fieldName.String(), mode); } return B_OK; diff --git a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h index 12e9abd328..9c85112cb3 100644 --- a/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h +++ b/src/apps/debugger/user_interface/gui/inspector_window/InspectorWindow.h @@ -41,18 +41,18 @@ public: virtual void MemoryBlockRetrieved(TeamMemoryBlock* block); status_t LoadSettings( - const GUITeamUISettings* settings); + const GUITeamUISettings& settings); status_t SaveSettings( - BMessage* settings); + BMessage& settings); private: void _Init(); void _LoadMenuFieldMode(BMenuField* field, const char* name, - const GUITeamUISettings* settings); + const BMessage& settings); status_t _SaveMenuFieldMode(BMenuField* field, const char* name, - BMessage* settings); + BMessage& settings); private: UserInterfaceListener* fListener; diff --git a/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.cpp b/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.cpp index 3ffc74e7e4..e05ca08dce 100644 --- a/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -14,6 +15,7 @@ #include #include "FunctionID.h" +#include "GUISettingsUtils.h" #include "LocatableFile.h" #include "table/TableColumns.h" #include "Team.h" @@ -234,6 +236,32 @@ BreakpointListView::UserBreakpointChanged(UserBreakpoint* breakpoint) } +void +BreakpointListView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("breakpointsTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fBreakpointsTable); + } +} + + +status_t +BreakpointListView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fBreakpointsTable); + if (result == B_OK) + result = settings.AddMessage("breakpointsTable", &tableSettings); + + return result; +} + + void BreakpointListView::TableSelectionChanged(Table* table) { diff --git a/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.h b/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.h index d997aacce8..73ebc0e3bf 100644 --- a/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.h +++ b/src/apps/debugger/user_interface/gui/team_window/BreakpointListView.h @@ -33,6 +33,9 @@ public: void UserBreakpointChanged( UserBreakpoint* breakpoint); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: class BreakpointsTableModel; diff --git a/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp b/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp index c644b41b23..176d6cab3b 100644 --- a/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -126,6 +127,30 @@ BreakpointsView::AttachedToWindow() } +void +BreakpointsView::LoadSettings(const BMessage& settings) +{ + BMessage breakpointListSettings; + if (settings.FindMessage("breakpointList", &breakpointListSettings) + == B_OK) + fListView->LoadSettings(breakpointListSettings); +} + + +status_t +BreakpointsView::SaveSettings(BMessage& settings) +{ + BMessage breakpointListSettings; + if (fListView->SaveSettings(breakpointListSettings) != B_OK) + return B_NO_MEMORY; + + if (settings.AddMessage("breakpointList", &breakpointListSettings) != B_OK) + return B_NO_MEMORY; + + return B_OK; +} + + void BreakpointsView::BreakpointSelectionChanged(UserBreakpoint* breakpoint) { diff --git a/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.h b/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.h index ebc9ef7c4e..2240252ee7 100644 --- a/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.h +++ b/src/apps/debugger/user_interface/gui/team_window/BreakpointsView.h @@ -35,6 +35,9 @@ public: virtual void MessageReceived(BMessage* message); virtual void AttachedToWindow(); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: // BreakpointListView::Listener virtual void BreakpointSelectionChanged( diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp index f39a73b9fe..79315020fc 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -15,6 +16,7 @@ #include "table/TableColumns.h" #include "FunctionInstance.h" +#include "GUISettingsUtils.h" #include "Image.h" #include "ImageDebugInfo.h" #include "LocatableFile.h" @@ -391,6 +393,32 @@ ImageFunctionsView::SetFunction(FunctionInstance* function) } +void +ImageFunctionsView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("functionsTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fFunctionsTable); + } +} + + +status_t +ImageFunctionsView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fFunctionsTable); + if (result == B_OK) + result = settings.AddMessage("functionsTable", &tableSettings); + + return result; +} + + void ImageFunctionsView::TreeTableSelectionChanged(TreeTable* table) { diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h index cf64b38642..eb4ed2674e 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h +++ b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h @@ -31,6 +31,9 @@ public: ImageDebugInfo* imageDebugInfo); void SetFunction(FunctionInstance* function); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: class FunctionsTableModel; diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp index cbc9a3dd06..4371ac8a83 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ImageListView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -15,6 +16,7 @@ #include #include +#include "GUISettingsUtils.h" #include "table/TableColumns.h" #include "Tracing.h" @@ -224,6 +226,32 @@ ImageListView::MessageReceived(BMessage* message) } +void +ImageListView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("imagesTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fImagesTable); + } +} + + +status_t +ImageListView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fImagesTable); + if (result == B_OK) + result = settings.AddMessage("imagesTable", &tableSettings); + + return result; +} + + void ImageListView::ImageAdded(const Team::ImageEvent& event) { diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageListView.h b/src/apps/debugger/user_interface/gui/team_window/ImageListView.h index a27c20b7b6..e66665bed3 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ImageListView.h +++ b/src/apps/debugger/user_interface/gui/team_window/ImageListView.h @@ -29,6 +29,9 @@ public: virtual void MessageReceived(BMessage* message); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: class ImagesTableModel; diff --git a/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp b/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp index bb20391905..12a86550a7 100644 --- a/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -15,6 +16,7 @@ #include "Architecture.h" #include "CpuState.h" +#include "GUISettingsUtils.h" #include "Register.h" @@ -226,6 +228,32 @@ RegistersView::SetCpuState(CpuState* cpuState) } +void +RegistersView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("registerTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fRegisterTable); + } +} + + +status_t +RegistersView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fRegisterTable); + if (result == B_OK) + result = settings.AddMessage("registerTable", &tableSettings); + + return result; +} + + void RegistersView::TableRowInvoked(Table* table, int32 rowIndex) { diff --git a/src/apps/debugger/user_interface/gui/team_window/RegistersView.h b/src/apps/debugger/user_interface/gui/team_window/RegistersView.h index bffb6f7fd7..8c680928c8 100644 --- a/src/apps/debugger/user_interface/gui/team_window/RegistersView.h +++ b/src/apps/debugger/user_interface/gui/team_window/RegistersView.h @@ -24,6 +24,9 @@ public: void SetCpuState(CpuState* cpuState); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: class RegisterValueColumn; class RegisterTableModel; diff --git a/src/apps/debugger/user_interface/gui/team_window/StackTraceView.cpp b/src/apps/debugger/user_interface/gui/team_window/StackTraceView.cpp index ed79bda9fb..0ac14d923c 100644 --- a/src/apps/debugger/user_interface/gui/team_window/StackTraceView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/StackTraceView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -15,6 +16,7 @@ #include "table/TableColumns.h" #include "FunctionInstance.h" +#include "GUISettingsUtils.h" #include "Image.h" #include "StackTrace.h" #include "TargetAddressTableColumn.h" @@ -196,6 +198,32 @@ StackTraceView::SetStackFrame(StackFrame* stackFrame) } +void +StackTraceView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("framesTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fFramesTable); + } +} + + +status_t +StackTraceView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fFramesTable); + if (result == B_OK) + result = settings.AddMessage("framesTable", &tableSettings); + + return result; +} + + void StackTraceView::TableSelectionChanged(Table* table) { diff --git a/src/apps/debugger/user_interface/gui/team_window/StackTraceView.h b/src/apps/debugger/user_interface/gui/team_window/StackTraceView.h index fc751f2eff..5ce2fbe9bb 100644 --- a/src/apps/debugger/user_interface/gui/team_window/StackTraceView.h +++ b/src/apps/debugger/user_interface/gui/team_window/StackTraceView.h @@ -30,6 +30,9 @@ public: void SetStackTrace(StackTrace* stackTrace); void SetStackFrame(StackFrame* stackFrame); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: class FramesTableModel; diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index d34bc109ba..36895208c4 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -224,7 +224,8 @@ TeamWindow::MessageReceived(BMessage* message) fInspectorWindow = InspectorWindow::Create(fTeam, fListener, this); if (fInspectorWindow != NULL) { - fInspectorWindow->LoadSettings(&fUISettings); + BMessage settings; + fInspectorWindow->LoadSettings(fUISettings); fInspectorWindow->Show(); } } catch (...) { @@ -354,22 +355,50 @@ TeamWindow::LoadSettings(const GUITeamUISettings* settings) if (!lock.IsLocked()) return B_ERROR; - BVariant value; - status_t error = settings->Value("teamWindowFrame", value); - if (error == B_OK) { - BRect rect = value.ToRect(); - ResizeTo(rect.Width(), rect.Height()); - MoveTo(rect.left, rect.top); + BMessage teamWindowSettings; + // no settings stored yet + if (settings->Settings("teamWindow", teamWindowSettings) != B_OK) + return B_OK; + + BRect frame; + if (teamWindowSettings.FindRect("frame", &frame) == B_OK) { + ResizeTo(frame.Width(), frame.Height()); + MoveTo(frame.left, frame.top); } - GUISettingsUtils::UnarchiveSplitView(Name(), "Source", settings, - fSourceSplitView); - GUISettingsUtils::UnarchiveSplitView(Name(), "Function", settings, - fFunctionSplitView); - GUISettingsUtils::UnarchiveSplitView(Name(), "Image", settings, - fImageSplitView); - GUISettingsUtils::UnarchiveSplitView(Name(), "Thread", settings, - fThreadSplitView); + BMessage archive; + if (teamWindowSettings.FindMessage("sourceSplit", &archive) == B_OK) + GUISettingsUtils::UnarchiveSplitView(archive, fSourceSplitView); + + if (teamWindowSettings.FindMessage("functionSplit", &archive) == B_OK) + GUISettingsUtils::UnarchiveSplitView(archive, fFunctionSplitView); + + if (teamWindowSettings.FindMessage("imageSplit", &archive) == B_OK) + GUISettingsUtils::UnarchiveSplitView(archive, fImageSplitView); + + if (teamWindowSettings.FindMessage("threadSplit", &archive) == B_OK) + GUISettingsUtils::UnarchiveSplitView(archive, fThreadSplitView); + + if (teamWindowSettings.FindMessage("imageListView", &archive) == B_OK) + fImageListView->LoadSettings(archive); + + if (teamWindowSettings.FindMessage("imageFunctionsView", &archive) == B_OK) + fImageFunctionsView->LoadSettings(archive); + + if (teamWindowSettings.FindMessage("threadListView", &archive) == B_OK) + fThreadListView->LoadSettings(archive); + + if (teamWindowSettings.FindMessage("variablesView", &archive) == B_OK) + fVariablesView->LoadSettings(archive); + + if (teamWindowSettings.FindMessage("registersView", &archive) == B_OK) + fRegistersView->LoadSettings(archive); + + if (teamWindowSettings.FindMessage("stackTraceView", &archive) == B_OK) + fStackTraceView->LoadSettings(archive); + + if (teamWindowSettings.FindMessage("breakpointsView", &archive) == B_OK) + fBreakpointsView->LoadSettings(archive); fUISettings = *settings; @@ -384,40 +413,73 @@ TeamWindow::SaveSettings(GUITeamUISettings* settings) if (!lock.IsLocked()) return B_ERROR; - // save the settings from the cached copy first, - // then overwrite them with our most current set - // this is necessary in order to preserve the settings - // of things like the inspector in case we haven't actually - // invoked them at all in this session - const BMessage& values = fUISettings.Values(); - char *name; - type_code type; - BVariant value; - for (int32 i = 0; values.GetInfo(B_ANY_TYPE, i, &name, &type) == B_OK; - i++) { - if (value.SetFromMessage(values, name) == B_OK) { - if (!settings->SetValue(name, value)) - return B_NO_MEMORY; - } + BMessage inspectorSettings; + if (fUISettings.Settings("inspectorWindow", inspectorSettings) == B_OK) { + if (!settings->AddSettings("inspectorWindow", inspectorSettings)) + return B_NO_MEMORY; } - if (!settings->SetValue("teamWindowFrame", Frame())) + BMessage archive; + BMessage teamWindowSettings; + if (teamWindowSettings.AddRect("frame", Frame()) != B_OK) return B_NO_MEMORY; - if (GUISettingsUtils::ArchiveSplitView(Name(), "Source", - settings, fSourceSplitView) != B_OK) + if (GUISettingsUtils::ArchiveSplitView(archive, fSourceSplitView) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("sourceSplit", &archive) != B_OK) return B_NO_MEMORY; - if (GUISettingsUtils::ArchiveSplitView(Name(), "Function", - settings, fFunctionSplitView) != B_OK) + if (GUISettingsUtils::ArchiveSplitView(archive, fFunctionSplitView) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("functionSplit", &archive) != B_OK) return B_NO_MEMORY; - if (GUISettingsUtils::ArchiveSplitView(Name(), "Image", - settings, fImageSplitView) != B_OK) + if (GUISettingsUtils::ArchiveSplitView(archive, fImageSplitView) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("imageSplit", &archive)) return B_NO_MEMORY; - if (GUISettingsUtils::ArchiveSplitView(Name(), "Thread", - settings, fThreadSplitView) != B_OK) + if (GUISettingsUtils::ArchiveSplitView(archive, fThreadSplitView) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("threadSplit", &archive)) + return B_NO_MEMORY; + + if (fImageListView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("imageListView", &archive)) + return B_NO_MEMORY; + + if (fImageFunctionsView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("imageFunctionsView", &archive)) + return B_NO_MEMORY; + + if (fThreadListView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("threadListView", &archive)) + return B_NO_MEMORY; + + if (fVariablesView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("variablesView", &archive)) + return B_NO_MEMORY; + + if (fRegistersView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("registersView", &archive)) + return B_NO_MEMORY; + + if (fStackTraceView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("stackTraceView", &archive)) + return B_NO_MEMORY; + + if (fBreakpointsView->SaveSettings(archive) != B_OK) + return B_NO_MEMORY; + if (teamWindowSettings.AddMessage("breakpointsView", &archive)) + return B_NO_MEMORY; + + if (!settings->AddSettings("teamWindow", teamWindowSettings)) return B_NO_MEMORY; return B_OK; @@ -1186,17 +1248,8 @@ TeamWindow::_HandleResolveMissingSourceFile(entry_ref& locatedPath) status_t TeamWindow::_SaveInspectorSettings(const BMessage* settings) { - char *name; - type_code type; - BVariant value; - - for (int32 i = 0; settings->GetInfo(B_ANY_TYPE, i, &name, &type) == B_OK; - i++) { - if (value.SetFromMessage(*settings, name) == B_OK) { - if (!fUISettings.SetValue(name, value)) - return B_NO_MEMORY; - } - } + if (fUISettings.AddSettings("inspectorWindow", *settings) != B_OK) + return B_NO_MEMORY; return B_OK; } diff --git a/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp b/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp index 4a3ab01b2c..4799286ffa 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/ThreadListView.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2011, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -15,6 +16,7 @@ #include #include +#include "GUISettingsUtils.h" #include "table/TableColumns.h" @@ -306,6 +308,34 @@ ThreadListView::MessageReceived(BMessage* message) } +void +ThreadListView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("threadsTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fThreadsTable); + } +} + + +status_t +ThreadListView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fThreadsTable); + if (result == B_OK) + result = settings.AddMessage("threadsTable", &tableSettings); + + return result; +} + + + + void ThreadListView::ThreadAdded(const Team::ThreadEvent& event) { diff --git a/src/apps/debugger/user_interface/gui/team_window/ThreadListView.h b/src/apps/debugger/user_interface/gui/team_window/ThreadListView.h index 2d65b363b0..e5fb090293 100644 --- a/src/apps/debugger/user_interface/gui/team_window/ThreadListView.h +++ b/src/apps/debugger/user_interface/gui/team_window/ThreadListView.h @@ -33,6 +33,9 @@ public: virtual void MessageReceived(BMessage* message); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: class ThreadsTableModel; diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 15206ae8c8..922d8d49b7 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -22,6 +22,7 @@ #include "Architecture.h" #include "FunctionID.h" #include "FunctionInstance.h" +#include "GUISettingsUtils.h" #include "MessageCodes.h" #include "SettingsMenu.h" #include "StackFrame.h" @@ -1519,6 +1520,34 @@ VariablesView::DetachedFromWindow() } +void +VariablesView::LoadSettings(const BMessage& settings) +{ + BMessage tableSettings; + if (settings.FindMessage("variableTable", &tableSettings) == B_OK) { + GUISettingsUtils::UnarchiveTableSettings(tableSettings, + fVariableTable); + } +} + + +status_t +VariablesView::SaveSettings(BMessage& settings) +{ + settings.MakeEmpty(); + + BMessage tableSettings; + status_t result = GUISettingsUtils::ArchiveTableSettings(tableSettings, + fVariableTable); + if (result == B_OK) + result = settings.AddMessage("variableTable", &tableSettings); + + return result; +} + + + + void VariablesView::TreeTableNodeExpandedChanged(TreeTable* table, const TreeTablePath& path, bool expanded) diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h index 223d8f73f0..0310dbd4de 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h @@ -41,6 +41,9 @@ public: virtual void DetachedFromWindow(); + void LoadSettings(const BMessage& settings); + status_t SaveSettings(BMessage& settings); + private: // TreeTableListener virtual void TreeTableNodeExpandedChanged(TreeTable* table,