Skip to content

Commit

Permalink
Debugger: Adjust TeamWindow to use ExpressionEvaluationWindow.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
anevilyak committed Nov 10, 2015
1 parent 94acd92 commit d6a334f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 50 deletions.
64 changes: 32 additions & 32 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -145,6 +146,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener)
fTeamSettingsWindow(NULL),
fBreakpointEditWindow(NULL),
fInspectorWindow(NULL),
fExpressionEvalWindow(NULL),
fExpressionPromptWindow(NULL),
fFilePanel(NULL),
fActiveSourceWorker(-1)
Expand All @@ -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();
Expand Down Expand Up @@ -345,55 +351,49 @@ TeamWindow::MessageReceived(BMessage* message)

}
case MSG_SHOW_EXPRESSION_WINDOW:
case MSG_SHOW_EXPRESSION_PROMPT_WINDOW:
{
BHandler* addTarget;
if (message->what == MSG_SHOW_EXPRESSION_WINDOW)
addTarget = fVariablesView;
else if (message->FindPointer("target",
reinterpret_cast<void**>(&addTarget)) != B_OK) {
break;
if (fExpressionEvalWindow != NULL) {
AutoLocker<BWindow> 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:
{
if (fExpressionPromptWindow != NULL) {
AutoLocker<BWindow> 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:
Expand Down
2 changes: 2 additions & 0 deletions src/apps/debugger/user_interface/gui/team_window/TeamWindow.h
Expand Up @@ -33,6 +33,7 @@ class BStringView;
class BTabView;
class ConsoleOutputView;
class BreakpointEditWindow;
class ExpressionEvaluationWindow;
class ExpressionPromptWindow;
class Image;
class InspectorWindow;
Expand Down Expand Up @@ -240,6 +241,7 @@ class TeamWindow : public BWindow, ThreadListView::Listener,
TeamSettingsWindow* fTeamSettingsWindow;
BreakpointEditWindow* fBreakpointEditWindow;
InspectorWindow* fInspectorWindow;
ExpressionEvaluationWindow* fExpressionEvalWindow;
ExpressionPromptWindow* fExpressionPromptWindow;
GuiTeamUiSettings fUiSettings;
BFilePanel* fFilePanel;
Expand Down
Expand Up @@ -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)
{
}

Expand All @@ -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();
Expand All @@ -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));
Expand Down Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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


Expand All @@ -41,7 +40,6 @@ class ExpressionPromptWindow : public BWindow
BButton* fAddButton;
BHandler* fAddTarget;
BHandler* fCloseTarget;
bool fPersistentExpression;
};

#endif // EXPRESSION_PROMPT_WINDOW_H

0 comments on commit d6a334f

Please sign in to comment.