Debugger: Finish variable edit support.
VariablesView: - Intercept table node invocations. If the invocation corresponds to a writable variable, request a corresponding editor and bring up a an edit window for it. - Handle requests from the edit window to write the final updated value of the variable. This implements the last missing piece for ticket #9708, except for an editor for floats.
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
#include "StringValue.h"
|
#include "StringValue.h"
|
||||||
#include "SyntheticPrimitiveType.h"
|
#include "SyntheticPrimitiveType.h"
|
||||||
|
#include "TableCellValueEditor.h"
|
||||||
#include "TableCellValueRenderer.h"
|
#include "TableCellValueRenderer.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "TeamDebugInfo.h"
|
#include "TeamDebugInfo.h"
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
#include "ValueNode.h"
|
#include "ValueNode.h"
|
||||||
#include "ValueNodeManager.h"
|
#include "ValueNodeManager.h"
|
||||||
#include "Variable.h"
|
#include "Variable.h"
|
||||||
|
#include "VariableEditWindow.h"
|
||||||
#include "VariableValueNodeChild.h"
|
#include "VariableValueNodeChild.h"
|
||||||
#include "VariablesViewState.h"
|
#include "VariablesViewState.h"
|
||||||
#include "VariablesViewStateHistory.h"
|
#include "VariablesViewStateHistory.h"
|
||||||
@@ -1773,6 +1775,7 @@ VariablesView::VariablesView(Listener* listener)
|
|||||||
fPendingTypecastInfo(NULL),
|
fPendingTypecastInfo(NULL),
|
||||||
fTemporaryExpression(NULL),
|
fTemporaryExpression(NULL),
|
||||||
fFrameClearPending(false),
|
fFrameClearPending(false),
|
||||||
|
fEditWindow(NULL),
|
||||||
fListener(listener)
|
fListener(listener)
|
||||||
{
|
{
|
||||||
SetName("Variables");
|
SetName("Variables");
|
||||||
@@ -1781,6 +1784,9 @@ VariablesView::VariablesView(Listener* listener)
|
|||||||
|
|
||||||
VariablesView::~VariablesView()
|
VariablesView::~VariablesView()
|
||||||
{
|
{
|
||||||
|
if (fEditWindow != NULL)
|
||||||
|
BMessenger(fEditWindow).SendMessage(B_QUIT_REQUESTED);
|
||||||
|
|
||||||
SetStackFrame(NULL, NULL);
|
SetStackFrame(NULL, NULL);
|
||||||
fVariableTable->SetTreeTableModel(NULL);
|
fVariableTable->SetTreeTableModel(NULL);
|
||||||
|
|
||||||
@@ -1887,6 +1893,66 @@ VariablesView::MessageReceived(BMessage* message)
|
|||||||
Looper()->PostMessage(message);
|
Looper()->PostMessage(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MSG_SHOW_VARIABLE_EDIT_WINDOW:
|
||||||
|
{
|
||||||
|
TableCellValueEditor* editor = NULL;
|
||||||
|
if (message->FindPointer("editor", reinterpret_cast<void**>(
|
||||||
|
&editor)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BReference<TableCellValueEditor> editorReference(editor, true);
|
||||||
|
if (fEditWindow != NULL)
|
||||||
|
fEditWindow->Activate();
|
||||||
|
else {
|
||||||
|
ValueNode* node = NULL;
|
||||||
|
if (message->FindPointer("node", reinterpret_cast<void**>(
|
||||||
|
&node)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value* value = NULL;
|
||||||
|
if (message->FindPointer("value", reinterpret_cast<void**>(
|
||||||
|
&value)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fEditWindow = VariableEditWindow::Create(value, node,
|
||||||
|
editor, this);
|
||||||
|
} catch (...) {
|
||||||
|
fEditWindow = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fEditWindow->Show();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MSG_VARIABLE_EDIT_WINDOW_CLOSED:
|
||||||
|
{
|
||||||
|
fEditWindow = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MSG_WRITE_VARIABLE_VALUE:
|
||||||
|
{
|
||||||
|
Value* value = NULL;
|
||||||
|
if (message->FindPointer("value", reinterpret_cast<void**>(
|
||||||
|
&value)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BReference<Value> valueReference(value, true);
|
||||||
|
|
||||||
|
ValueNode* node = NULL;
|
||||||
|
if (message->FindPointer("node", reinterpret_cast<void**>(
|
||||||
|
&node)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fListener->ValueNodeWriteRequested(node,
|
||||||
|
fStackFrame->GetCpuState(), value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MSG_SHOW_TYPECAST_NODE_PROMPT:
|
case MSG_SHOW_TYPECAST_NODE_PROMPT:
|
||||||
{
|
{
|
||||||
BMessage* promptMessage = new(std::nothrow) BMessage(
|
BMessage* promptMessage = new(std::nothrow) BMessage(
|
||||||
@@ -2328,6 +2394,54 @@ VariablesView::TreeTableNodeExpandedChanged(TreeTable* table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
VariablesView::TreeTableNodeInvoked(TreeTable* table,
|
||||||
|
const TreeTablePath& path)
|
||||||
|
{
|
||||||
|
ModelNode* node = (ModelNode*)fVariableTableModel->NodeForPath(path);
|
||||||
|
if (node == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ValueNodeChild* child = node->NodeChild();
|
||||||
|
|
||||||
|
if (child->LocationResolutionState() != B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ValueLocation* location = child->Location();
|
||||||
|
if (!location->IsWritable())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Value* value = node->GetValue();
|
||||||
|
if (value == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// get a value handler
|
||||||
|
ValueHandler* valueHandler;
|
||||||
|
status_t error = ValueHandlerRoster::Default()->FindValueHandler(value,
|
||||||
|
valueHandler);
|
||||||
|
if (error != B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BReference<ValueHandler> handlerReference(valueHandler, true);
|
||||||
|
TableCellValueRenderer* renderer = node->TableCellRenderer();
|
||||||
|
TableCellValueEditor* editor = NULL;
|
||||||
|
error = valueHandler->GetTableCellValueEditor(value,
|
||||||
|
renderer != NULL ? renderer->GetSettings() : NULL, editor);
|
||||||
|
if (error != B_OK || editor == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BReference<TableCellValueEditor> editorReference(editor, true);
|
||||||
|
|
||||||
|
BMessage message(MSG_SHOW_VARIABLE_EDIT_WINDOW);
|
||||||
|
message.AddPointer("editor", editor);
|
||||||
|
message.AddPointer("node", node->NodeChild()->Node());
|
||||||
|
message.AddPointer("value", value);
|
||||||
|
|
||||||
|
if (BMessenger(this).SendMessage(&message) == B_OK)
|
||||||
|
editorReference.Detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VariablesView::TreeTableCellMouseDown(TreeTable* table,
|
VariablesView::TreeTableCellMouseDown(TreeTable* table,
|
||||||
const TreeTablePath& path, int32 columnIndex, BPoint screenWhere,
|
const TreeTablePath& path, int32 columnIndex, BPoint screenWhere,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2012-2014, Rene Gollent, [email protected].
|
* Copyright 2012-2015, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef VARIABLES_VIEW_H
|
#ifndef VARIABLES_VIEW_H
|
||||||
@@ -22,11 +22,13 @@ class StackFrame;
|
|||||||
class Thread;
|
class Thread;
|
||||||
class Type;
|
class Type;
|
||||||
class TypeComponentPath;
|
class TypeComponentPath;
|
||||||
|
class ValueLocation;
|
||||||
class ValueNode;
|
class ValueNode;
|
||||||
class ValueNodeChild;
|
class ValueNodeChild;
|
||||||
class ValueNodeContainer;
|
class ValueNodeContainer;
|
||||||
class Value;
|
class Value;
|
||||||
class Variable;
|
class Variable;
|
||||||
|
class VariableEditWindow;
|
||||||
class VariablesViewState;
|
class VariablesViewState;
|
||||||
class VariablesViewStateHistory;
|
class VariablesViewStateHistory;
|
||||||
|
|
||||||
@@ -59,7 +61,8 @@ private:
|
|||||||
// TreeTableListener
|
// TreeTableListener
|
||||||
virtual void TreeTableNodeExpandedChanged(TreeTable* table,
|
virtual void TreeTableNodeExpandedChanged(TreeTable* table,
|
||||||
const TreeTablePath& path, bool expanded);
|
const TreeTablePath& path, bool expanded);
|
||||||
|
virtual void TreeTableNodeInvoked(TreeTable* table,
|
||||||
|
const TreeTablePath& path);
|
||||||
virtual void TreeTableCellMouseDown(TreeTable* table,
|
virtual void TreeTableCellMouseDown(TreeTable* table,
|
||||||
const TreeTablePath& path,
|
const TreeTablePath& path,
|
||||||
int32 columnIndex, BPoint screenWhere,
|
int32 columnIndex, BPoint screenWhere,
|
||||||
@@ -143,6 +146,7 @@ private:
|
|||||||
VariablesExpressionInfo* fPendingTypecastInfo;
|
VariablesExpressionInfo* fPendingTypecastInfo;
|
||||||
ExpressionInfo* fTemporaryExpression;
|
ExpressionInfo* fTemporaryExpression;
|
||||||
bool fFrameClearPending;
|
bool fFrameClearPending;
|
||||||
|
VariableEditWindow* fEditWindow;
|
||||||
Listener* fListener;
|
Listener* fListener;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user