Esempio n. 1
0
void
VariablesView::ContainerListener::ValueNodeChanged(ValueNodeChild* nodeChild,
	ValueNode* oldNode, ValueNode* newNode)
{
	// If the looper is already locked, invoke the model's hook synchronously.
	if (fIndirectTarget->Looper()->IsLocked()) {
		fModel->ValueNodeChanged(nodeChild, oldNode, newNode);
		return;
	}

	// looper not locked yet -- call asynchronously to avoid reverse locking
	// order
	BReference<ValueNodeChild> nodeChildReference(nodeChild);
	BReference<ValueNode> oldNodeReference(oldNode);
	BReference<ValueNode> newNodeReference(newNode);

	BMessage message(MSG_VALUE_NODE_CHANGED);
	if (message.AddPointer("nodeChild", nodeChild) == B_OK
		&& message.AddPointer("oldNode", oldNode) == B_OK
		&& message.AddPointer("newNode", newNode) == B_OK
		&& fIndirectTarget->Looper()->PostMessage(&message, fIndirectTarget)
			== B_OK) {
		nodeChildReference.Detach();
		oldNodeReference.Detach();
		newNodeReference.Detach();
	}
}
void
ValueNodeManager::_AddNode(Variable* variable)
{
	// create the node child for the variable
	ValueNodeChild* nodeChild = new (std::nothrow) VariableValueNodeChild(
		variable);
	BReference<ValueNodeChild> nodeChildReference(nodeChild, true);
	if (nodeChild == NULL || !fContainer->AddChild(nodeChild)) {
		delete nodeChild;
		return;
	}

	// automatically add child nodes for the top level nodes
	AddChildNodes(nodeChild);
}
Esempio n. 3
0
void
VariablesView::VariableTableModel::_AddNode(Variable* variable)
{
	// create the node child for the variable
	ValueNodeChild* nodeChild = new (std::nothrow) VariableValueNodeChild(
		variable);
	BReference<ValueNodeChild> nodeChildReference(nodeChild, true);
	if (nodeChild == NULL || !fContainer->AddChild(nodeChild)) {
		delete nodeChild;
		return;
	}

	// create the model node
	status_t error = _AddNode(variable, NULL, nodeChild, false);
	if (error != B_OK)
		return;

	// automatically add child nodes for the top level nodes
	_AddChildNodes(nodeChild);
}
Esempio n. 4
0
status_t
ResolveValueNodeValueJob::_ResolveNodeValue()
{
    // get the node child and parent node
    AutoLocker<ValueNodeContainer> containerLocker(fContainer);
    ValueNodeChild* nodeChild = fValueNode->NodeChild();
    BReference<ValueNodeChild> nodeChildReference(nodeChild);

    ValueNode* parentNode = nodeChild->Parent();
    BReference<ValueNode> parentNodeReference(parentNode);

    // Check whether the node child location has been resolved already
    // (successfully).
    status_t nodeChildResolutionState = nodeChild->LocationResolutionState();
    bool nodeChildDone = nodeChildResolutionState != VALUE_NODE_UNRESOLVED;
    if (nodeChildDone && nodeChildResolutionState != B_OK)
        return nodeChildResolutionState;

    // If the child node location has not been resolved yet, check whether the
    // parent node location and value have been resolved already (successfully).
    bool parentDone = true;
    if (!nodeChildDone && parentNode != NULL) {
        status_t parentResolutionState
            = parentNode->LocationAndValueResolutionState();
        parentDone = parentResolutionState != VALUE_NODE_UNRESOLVED;
        if (parentDone && parentResolutionState != B_OK)
            return parentResolutionState;
    }

    containerLocker.Unlock();

    // resolve the parent node location and value, if necessary
    if (!parentDone) {
        status_t error = _ResolveParentNodeValue(parentNode);
        if (error != B_OK) {
            TRACE_LOCALS("ResolveValueNodeValueJob::_ResolveNodeValue(): value "
                         "node: %p (\"%s\"): _ResolveParentNodeValue(%p) failed\n",
                         fValueNode, fValueNode->Name().String(), parentNode);
            return error;
        }
    }

    // resolve the node child location, if necessary
    if (!nodeChildDone) {
        status_t error = _ResolveNodeChildLocation(nodeChild);
        if (error != B_OK) {
            TRACE_LOCALS("ResolveValueNodeValueJob::_ResolveNodeValue(): value "
                         "node: %p (\"%s\"): _ResolveNodeChildLocation(%p) failed\n",
                         fValueNode, fValueNode->Name().String(), nodeChild);
            return error;
        }
    }

    // resolve the node location and value
    ValueLoader valueLoader(fArchitecture, fDebuggerInterface,
                            fTypeInformation, fCpuState);
    ValueLocation* location;
    Value* value;
    status_t error = fValueNode->ResolvedLocationAndValue(&valueLoader,
                     location, value);
    if (error != B_OK) {
        TRACE_LOCALS("ResolveValueNodeValueJob::_ResolveNodeValue(): value "
                     "node: %p (\"%s\"): fValueNode->ResolvedLocationAndValue() "
                     "failed\n", fValueNode, fValueNode->Name().String());
        return error;
    }
    BReference<ValueLocation> locationReference(location, true);
    BReference<Value> valueReference(value, true);

    // set location and value on the node
    containerLocker.Lock();
    status_t nodeResolutionState
        = fValueNode->LocationAndValueResolutionState();
    if (nodeResolutionState != VALUE_NODE_UNRESOLVED)
        return nodeResolutionState;
    fValueNode->SetLocationAndValue(location, value, B_OK);
    containerLocker.Unlock();

    return B_OK;
}
Esempio n. 5
0
void
VariablesView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_VALUE_NODE_CHANGED:
		{
			ValueNodeChild* nodeChild;
			ValueNode* oldNode;
			ValueNode* newNode;
			if (message->FindPointer("nodeChild", (void**)&nodeChild) == B_OK
				&& message->FindPointer("oldNode", (void**)&oldNode) == B_OK
				&& message->FindPointer("newNode", (void**)&newNode) == B_OK) {
				BReference<ValueNodeChild> nodeChildReference(nodeChild, true);
				BReference<ValueNode> oldNodeReference(oldNode, true);
				BReference<ValueNode> newNodeReference(newNode, true);

				fVariableTableModel->ValueNodeChanged(nodeChild, oldNode,
					newNode);
			}

			break;
		}
		case MSG_VALUE_NODE_CHILDREN_CREATED:
		{
			ValueNode* node;
			if (message->FindPointer("node", (void**)&node) == B_OK) {
				BReference<ValueNode> newNodeReference(node, true);
				fVariableTableModel->ValueNodeChildrenCreated(node);
			}

			break;
		}
		case MSG_VALUE_NODE_CHILDREN_DELETED:
		{
			ValueNode* node;
			if (message->FindPointer("node", (void**)&node) == B_OK) {
				BReference<ValueNode> newNodeReference(node, true);
				fVariableTableModel->ValueNodeChildrenDeleted(node);
			}

			break;
		}
		case MSG_VALUE_NODE_VALUE_CHANGED:
		{
			ValueNode* node;
			if (message->FindPointer("node", (void**)&node) == B_OK) {
				BReference<ValueNode> newNodeReference(node, true);
				fVariableTableModel->ValueNodeValueChanged(node);
			}

			break;
		}
		case MSG_VARIABLES_VIEW_CONTEXT_MENU_DONE:
		{
			_FinishContextMenu(false);
			break;
		}
		case MSG_VARIABLES_VIEW_NODE_SETTINGS_CHANGED:
		{
			ModelNode* node;
			if (message->FindPointer("node", (void**)&node) != B_OK)
				break;
			BReference<ModelNode> nodeReference(node, true);

			fVariableTableModel->NotifyNodeChanged(node);
			break;
		}
		default:
			BGroupView::MessageReceived(message);
			break;
	}
}