From 10bbf8cb8d8bc8eb9e63e87be8dd21f9b73c7937 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 26 Jul 2015 14:20:04 -0400 Subject: [PATCH] Debugger: TeamWindow refactor. - When asked to load settings, post a message and do so in the window's message loop. This avoids a lock order reversal when asked to do so later as a result of exec() changing the target image out. --- .../gui/team_window/TeamWindow.cpp | 134 ++++++++++-------- .../gui/team_window/TeamWindow.h | 3 + 2 files changed, 77 insertions(+), 60 deletions(-) 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 ced49882b6..4b7f15ed8b 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -73,7 +73,8 @@ enum { MSG_DEBUG_REPORT_SAVED = 'drsa', MSG_LOCATE_SOURCE_IF_NEEDED = 'lsin', MSG_SOURCE_ENTRY_QUERY_COMPLETE = 'seqc', - MSG_CLEAR_STACK_TRACE = 'clst' + MSG_CLEAR_STACK_TRACE = 'clst', + MSG_HANDLE_LOAD_SETTINGS = 'hlst' }; @@ -513,6 +514,17 @@ TeamWindow::MessageReceived(BMessage* message) } break; } + case MSG_HANDLE_LOAD_SETTINGS: + { + GuiTeamUiSettings* settings; + if (message->FindPointer("settings", + reinterpret_cast(&settings)) != B_OK) { + break; + } + + _LoadSettings(settings); + break; + } case MSG_TEAM_RENAMED: { _UpdateTitle(); @@ -617,64 +629,9 @@ TeamWindow::QuitRequested() status_t TeamWindow::LoadSettings(const GuiTeamUiSettings* settings) { - AutoLocker lock(this); - if (!lock.IsLocked()) - return B_ERROR; - - 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); - } - - 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("consoleSplit", &archive) == B_OK) - GuiSettingsUtils::UnarchiveSplitView(archive, fConsoleSplitView); - - 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); - - if (teamWindowSettings.FindMessage("consoleOutputView", &archive) == B_OK) - fConsoleOutputView->LoadSettings(archive); - - fUiSettings = *settings; - - return B_OK; + BMessage message(MSG_HANDLE_LOAD_SETTINGS); + message.AddPointer("settings", settings); + return PostMessage(&message); } @@ -1148,11 +1105,68 @@ TeamWindow::_Init() } +void +TeamWindow::_LoadSettings(const GuiTeamUiSettings* settings) +{ + BMessage teamWindowSettings; + // no settings stored yet + if (settings->Settings("teamWindow", teamWindowSettings) != B_OK) + return; + + BRect frame; + if (teamWindowSettings.FindRect("frame", &frame) == B_OK) { + ResizeTo(frame.Width(), frame.Height()); + MoveTo(frame.left, frame.top); + } + + 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("consoleSplit", &archive) == B_OK) + GuiSettingsUtils::UnarchiveSplitView(archive, fConsoleSplitView); + + 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); + + if (teamWindowSettings.FindMessage("consoleOutputView", &archive) == B_OK) + fConsoleOutputView->LoadSettings(archive); + + fUiSettings = *settings; +} + + void TeamWindow::_UpdateTitle() { AutoLocker< ::Team> lock(fTeam); - BString name = fTeam->Name(); if (fTeam->ID() >= 0) name << " (" << fTeam->ID() << ")"; diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h index 627f4296dc..f9be9461df 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h @@ -158,6 +158,9 @@ private: void _Init(); + void _LoadSettings( + const GuiTeamUiSettings* settings); + void _UpdateTitle(); void _SetActiveThread(::Thread* thread); void _SetActiveImage(Image* image);