Skip to content

Commit

Permalink
Debugger: TeamWindow refactor.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Jul 26, 2015
1 parent 754b42a commit 10bbf8c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 60 deletions.
134 changes: 74 additions & 60 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};


Expand Down Expand Up @@ -513,6 +514,17 @@ TeamWindow::MessageReceived(BMessage* message)
}
break;
}
case MSG_HANDLE_LOAD_SETTINGS:
{
GuiTeamUiSettings* settings;
if (message->FindPointer("settings",
reinterpret_cast<void**>(&settings)) != B_OK) {
break;
}

_LoadSettings(settings);
break;
}
case MSG_TEAM_RENAMED:
{
_UpdateTitle();
Expand Down Expand Up @@ -617,64 +629,9 @@ TeamWindow::QuitRequested()
status_t
TeamWindow::LoadSettings(const GuiTeamUiSettings* settings)
{
AutoLocker<BWindow> 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);
}


Expand Down Expand Up @@ -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() << ")";
Expand Down
3 changes: 3 additions & 0 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ class TeamWindow : public BWindow, ThreadListView::Listener,

void _Init();

void _LoadSettings(
const GuiTeamUiSettings* settings);

void _UpdateTitle();
void _SetActiveThread(::Thread* thread);
void _SetActiveImage(Image* image);
Expand Down

0 comments on commit 10bbf8c

Please sign in to comment.