From d6a334fa213bee5774652d813b2534dc87429b31 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 2 Aug 2015 22:16:04 -0400 Subject: [PATCH] Debugger: Adjust TeamWindow to use ExpressionEvaluationWindow. - Requesting expression evaluation from the top level menu now invokes an expression eval window, rather than the past prompt. ExpressionPromptWindow: - Simplify, as it's now strictly used to add persistent expressions. --- .../gui/team_window/TeamWindow.cpp | 64 +++++++++---------- .../gui/team_window/TeamWindow.h | 2 + .../ExpressionPromptWindow.cpp | 24 +++---- .../utility_windows/ExpressionPromptWindow.h | 6 +- 4 files changed, 46 insertions(+), 50 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 f1c3d36bfa..7116614860 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -40,6 +40,7 @@ #include "CpuState.h" #include "DisassembledCode.h" #include "BreakpointEditWindow.h" +#include "ExpressionEvaluationWindow.h" #include "ExpressionPromptWindow.h" #include "FileSourceCode.h" #include "GuiSettingsUtils.h" @@ -145,6 +146,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener) fTeamSettingsWindow(NULL), fBreakpointEditWindow(NULL), fInspectorWindow(NULL), + fExpressionEvalWindow(NULL), fExpressionPromptWindow(NULL), fFilePanel(NULL), fActiveSourceWorker(-1) @@ -167,6 +169,10 @@ TeamWindow::~TeamWindow() if (fInspectorWindow->Lock()) fInspectorWindow->Quit(); } + if (fExpressionEvalWindow != NULL) { + if (fExpressionEvalWindow->Lock()) + fExpressionEvalWindow->Quit(); + } if (fExpressionPromptWindow != NULL) { if (fExpressionPromptWindow->Lock()) fExpressionPromptWindow->Quit(); @@ -345,55 +351,49 @@ TeamWindow::MessageReceived(BMessage* message) } case MSG_SHOW_EXPRESSION_WINDOW: + { + if (fExpressionEvalWindow != NULL) { + AutoLocker lock(fExpressionEvalWindow); + if (lock.IsLocked()) + fExpressionEvalWindow->Activate(true); + } else { + try { + fExpressionEvalWindow = ExpressionEvaluationWindow::Create( + this, fTeam, fListener); + if (fExpressionEvalWindow != NULL) + fExpressionEvalWindow->Show(); + } catch (...) { + // TODO: notify user + } + } + break; + } + case MSG_EXPRESSION_WINDOW_CLOSED: + { + fExpressionEvalWindow = NULL; + break; + } case MSG_SHOW_EXPRESSION_PROMPT_WINDOW: { - BHandler* addTarget; - if (message->what == MSG_SHOW_EXPRESSION_WINDOW) - addTarget = fVariablesView; - else if (message->FindPointer("target", - reinterpret_cast(&addTarget)) != B_OK) { - break; - } - if (fExpressionPromptWindow != NULL) { AutoLocker lock(fExpressionPromptWindow); if (lock.IsLocked()) fExpressionPromptWindow->Activate(true); } else { try { - // if the request was initiated via the evaluate - // expression top level menu item, then this evaluation - // should not be persisted. - bool persistentExpression = - message->what == MSG_SHOW_EXPRESSION_PROMPT_WINDOW; fExpressionPromptWindow = ExpressionPromptWindow::Create( - addTarget, this, persistentExpression); + fVariablesView, this); if (fExpressionPromptWindow != NULL) fExpressionPromptWindow->Show(); - } catch (...) { - // TODO: notify user - } + } catch (...) { + // TODO: notify user + } } break; } - case MSG_EXPRESSION_WINDOW_CLOSED: case MSG_EXPRESSION_PROMPT_WINDOW_CLOSED: { fExpressionPromptWindow = NULL; - - const char* expression; - BMessenger targetMessenger; - if (message->FindString("expression", &expression) == B_OK - && message->FindMessenger("target", &targetMessenger) - == B_OK) { - - BMessage addMessage(MSG_ADD_NEW_EXPRESSION); - addMessage.AddString("expression", expression); - addMessage.AddBool("persistent", message->FindBool( - "persistent")); - - targetMessenger.SendMessage(&addMessage); - } break; } case MSG_SHOW_TEAM_SETTINGS_WINDOW: 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 825ecf0d03..3a1657071a 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.h @@ -33,6 +33,7 @@ class BStringView; class BTabView; class ConsoleOutputView; class BreakpointEditWindow; +class ExpressionEvaluationWindow; class ExpressionPromptWindow; class Image; class InspectorWindow; @@ -240,6 +241,7 @@ private: TeamSettingsWindow* fTeamSettingsWindow; BreakpointEditWindow* fBreakpointEditWindow; InspectorWindow* fInspectorWindow; + ExpressionEvaluationWindow* fExpressionEvalWindow; ExpressionPromptWindow* fExpressionPromptWindow; GuiTeamUiSettings fUiSettings; BFilePanel* fFilePanel; diff --git a/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.cpp b/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.cpp index 6c142b5873..10adc1abc3 100644 --- a/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.cpp +++ b/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.cpp @@ -13,16 +13,15 @@ ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget, - BHandler* closeTarget, bool isPersistent) + BHandler* closeTarget) : - BWindow(BRect(), isPersistent ? "Add Expression" : "Evaluate Expression", - B_FLOATING_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), + BWindow(BRect(), "Add Expression", B_FLOATING_WINDOW, + B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), fExpressionInput(NULL), fCancelButton(NULL), fAddButton(NULL), fAddTarget(addTarget), - fCloseTarget(closeTarget), - fPersistentExpression(isPersistent) + fCloseTarget(closeTarget) { } @@ -33,11 +32,10 @@ ExpressionPromptWindow::~ExpressionPromptWindow() ExpressionPromptWindow* -ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget, - bool isPersistent) +ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget) { ExpressionPromptWindow* self = new ExpressionPromptWindow(addTarget, - closeTarget, isPersistent); + closeTarget); try { self->_Init(); @@ -54,8 +52,7 @@ ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget, void ExpressionPromptWindow::_Init() { - fExpressionInput = new BTextControl("Expression:", NULL, - new BMessage(MSG_EVALUATE_EXPRESSION)); + fExpressionInput = new BTextControl("Expression:", NULL, NULL); BLayoutItem* labelItem = fExpressionInput->CreateLabelLayoutItem(); BLayoutItem* inputItem = fExpressionInput->CreateTextViewLayoutItem(); inputItem->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET)); @@ -108,12 +105,11 @@ ExpressionPromptWindow::MessageReceived(BMessage* message) switch (message->what) { case MSG_ADD_NEW_EXPRESSION: { - BMessage addMessage(MSG_EXPRESSION_PROMPT_WINDOW_CLOSED); + BMessage addMessage(MSG_ADD_NEW_EXPRESSION); addMessage.AddString("expression", fExpressionInput->Text()); - addMessage.AddBool("persistent", fPersistentExpression); - addMessage.AddMessenger("target", BMessenger(fAddTarget)); + addMessage.AddBool("persistent", true); - BMessenger(fCloseTarget).SendMessage(&addMessage); + BMessenger(fAddTarget).SendMessage(&addMessage); Quit(); break; } diff --git a/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.h b/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.h index ca5b43a636..ce18792f55 100644 --- a/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.h +++ b/src/apps/debugger/user_interface/gui/utility_windows/ExpressionPromptWindow.h @@ -17,13 +17,12 @@ class ExpressionPromptWindow : public BWindow { public: ExpressionPromptWindow(BHandler* addTarget, - BHandler* closeTarget, bool isPersistent); + BHandler* closeTarget); ~ExpressionPromptWindow(); static ExpressionPromptWindow* Create(BHandler* addTarget, - BHandler* closeTarget, - bool isPersistent); + BHandler* closeTarget); // throws @@ -41,7 +40,6 @@ private: BButton* fAddButton; BHandler* fAddTarget; BHandler* fCloseTarget; - bool fPersistentExpression; }; #endif // EXPRESSION_PROMPT_WINDOW_H