[haiku-commits] haiku: hrev45511 - in src/apps/debugger/user_interface/gui: team_window model

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 16 Apr 2013 05:19:02 +0200 (CEST)

hrev45511 adds 1 changeset to branch 'master'
old head: 3f7664ad1cb9e1f24fa550f7599acaf06c3120c5
new head: 41cec3e6d4273471b8cd44704d97f220f5bb0857
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=41cec3e+%5E3f7664a

----------------------------------------------------------------------------

41cec3e: Remember any applied typecasts in VariableViewState.
  
  Preserves and restores typecasts across steps like we already do
  for node expansion states.

                                      [ Rene Gollent <anevilyak@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev45511
Commit:      41cec3e6d4273471b8cd44704d97f220f5bb0857
URL:         http://cgit.haiku-os.org/haiku/commit/?id=41cec3e
Author:      Rene Gollent <anevilyak@xxxxxxxxx>
Date:        Tue Apr 16 03:17:27 2013 UTC

----------------------------------------------------------------------------

3 files changed, 75 insertions(+), 6 deletions(-)
.../gui/model/VariablesViewState.cpp             | 31 ++++++++++++++-
.../gui/model/VariablesViewState.h               |  8 ++++
.../gui/team_window/VariablesView.cpp            | 42 ++++++++++++++++++--

----------------------------------------------------------------------------

diff --git a/src/apps/debugger/user_interface/gui/model/VariablesViewState.cpp 
b/src/apps/debugger/user_interface/gui/model/VariablesViewState.cpp
index e47def9..87e0280 100644
--- a/src/apps/debugger/user_interface/gui/model/VariablesViewState.cpp
+++ b/src/apps/debugger/user_interface/gui/model/VariablesViewState.cpp
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx.
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
  * Distributed under the terms of the MIT License.
  */
@@ -10,6 +11,7 @@
 
 #include "FunctionID.h"
 #include "StackFrameValues.h"
+#include "Type.h"
 #include "TypeComponentPath.h"
 
 
@@ -18,15 +20,26 @@
 
 VariablesViewNodeInfo::VariablesViewNodeInfo()
        :
-       fNodeExpanded(false)
+       fNodeExpanded(false),
+       fCastedType(NULL)
 {
 }
 
 
 VariablesViewNodeInfo::VariablesViewNodeInfo(const VariablesViewNodeInfo& 
other)
        :
-       fNodeExpanded(other.fNodeExpanded)
+       fNodeExpanded(other.fNodeExpanded),
+       fCastedType(other.fCastedType)
 {
+       if (fCastedType != NULL)
+               fCastedType->AcquireReference();
+}
+
+
+VariablesViewNodeInfo::~VariablesViewNodeInfo()
+{
+       if (fCastedType != NULL)
+               fCastedType->ReleaseReference();
 }
 
 
@@ -34,6 +47,8 @@ VariablesViewNodeInfo&
 VariablesViewNodeInfo::operator=(const VariablesViewNodeInfo& other)
 {
        fNodeExpanded = other.fNodeExpanded;
+       SetCastedType(other.fCastedType);
+
        return *this;
 }
 
@@ -45,6 +60,18 @@ VariablesViewNodeInfo::SetNodeExpanded(bool expanded)
 }
 
 
+void
+VariablesViewNodeInfo::SetCastedType(Type* type)
+{
+       if (fCastedType != NULL)
+               fCastedType->ReleaseReference();
+
+       fCastedType = type;
+       if (fCastedType != NULL)
+               fCastedType->AcquireReference();
+}
+
+
 // #pragma mark - Key
 
 
diff --git a/src/apps/debugger/user_interface/gui/model/VariablesViewState.h 
b/src/apps/debugger/user_interface/gui/model/VariablesViewState.h
index 41e9271..5705d7f 100644
--- a/src/apps/debugger/user_interface/gui/model/VariablesViewState.h
+++ b/src/apps/debugger/user_interface/gui/model/VariablesViewState.h
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2013, Rene Gollent, rene@xxxxxxxxxxx.
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
  * Distributed under the terms of the MIT License.
  */
@@ -12,6 +13,7 @@
 
 class ObjectID;
 class StackFrameValues;
+class Type;
 class TypeComponentPath;
 
 
@@ -20,6 +22,7 @@ public:
                                                                
VariablesViewNodeInfo();
                                                                
VariablesViewNodeInfo(
                                                                        const 
VariablesViewNodeInfo& other);
+       virtual                                         
~VariablesViewNodeInfo();
 
                        VariablesViewNodeInfo& operator=(
                                                                        const 
VariablesViewNodeInfo& other);
@@ -28,8 +31,13 @@ public:
                                                                        { 
return fNodeExpanded; }
                        void                            SetNodeExpanded(bool 
expanded);
 
+                       Type*                           GetCastedType() const
+                                                                       { 
return fCastedType; }
+                       void                            SetCastedType(Type* 
type);
+
 private:
                        bool                            fNodeExpanded;
+                       Type*                           fCastedType;
 };
 
 
diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp 
b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
index 52ee01b..023be3b 100644
--- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
+++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp
@@ -1,6 +1,6 @@
 /*
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
- * Copyright 2011-2012, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2011-2013, Rene Gollent, rene@xxxxxxxxxxx.
  * Distributed under the terms of the MIT License.
  */
 
@@ -111,7 +111,8 @@ public:
                fTableCellRenderer(NULL),
                fComponentPath(NULL),
                fIsPresentationNode(isPresentationNode),
-               fHidden(false)
+               fHidden(false),
+               fCastedType(NULL)
        {
                fNodeChild->AcquireReference();
        }
@@ -129,6 +130,9 @@ public:
 
                if (fComponentPath != NULL)
                        fComponentPath->ReleaseReference();
+
+               if (fCastedType != NULL)
+                       fCastedType->ReleaseReference();
        }
 
        status_t Init()
@@ -195,6 +199,21 @@ public:
                        fValue->AcquireReference();
        }
 
+       Type* GetCastedType() const
+       {
+               return fCastedType;
+       }
+
+       void SetCastedType(Type* type)
+       {
+               if (fCastedType != NULL)
+                       fCastedType->ReleaseReference();
+
+               fCastedType = type;
+               if (type != NULL)
+                       fCastedType->AcquireReference();
+       }
+
        TypeComponentPath* GetPath() const
        {
                return fComponentPath;
@@ -309,6 +328,7 @@ private:
        TypeComponentPath*              fComponentPath;
        bool                                    fIsPresentationNode;
        bool                                    fHidden;
+       Type*                                   fCastedType;
 
 public:
        ModelNode*                      fNext;
@@ -1509,9 +1529,8 @@ VariablesView::MessageReceived(BMessage* message)
                                break;
                        }
 
-                       // TODO: we need to also persist/restore the casted 
state
-                       // in VariableViewState
                        node->NodeChild()->SetNode(valueNode);
+                       node->SetCastedType(type);
                        break;
                }
                case MSG_SHOW_WATCH_VARIABLE_PROMPT:
@@ -1967,6 +1986,7 @@ 
VariablesView::_AddViewStateDescendentNodeInfos(VariablesViewState* viewState,
                // add the node's info
                VariablesViewNodeInfo nodeInfo;
                nodeInfo.SetNodeExpanded(fVariableTable->IsNodeExpanded(path));
+               nodeInfo.SetCastedType(node->GetCastedType());
 
                status_t error = 
viewState->SetNodeInfo(node->GetVariable()->ID(),
                        node->GetPath(), nodeInfo);
@@ -1999,6 +2019,20 @@ 
VariablesView::_ApplyViewStateDescendentNodeInfos(VariablesViewState* viewState,
                const VariablesViewNodeInfo* nodeInfo = viewState->GetNodeInfo(
                        node->GetVariable()->ID(), node->GetPath());
                if (nodeInfo != NULL) {
+                       // NB: if the node info indicates that the node in 
question
+                       // was being cast to a different type, this *must* be 
applied
+                       // before any other view state restoration, since it 
potentially
+                       // changes the child hierarchy under that node.
+                       Type* type = nodeInfo->GetCastedType();
+                       if (type != NULL) {
+                               ValueNode* valueNode = NULL;
+                               if 
(TypeHandlerRoster::Default()->CreateValueNode(
+                                       node->NodeChild(), type, valueNode) == 
B_OK) {
+                                       node->NodeChild()->SetNode(valueNode);
+                                       node->SetCastedType(type);
+                               }
+                       }
+
                        fVariableTable->SetNodeExpanded(path, 
nodeInfo->IsNodeExpanded());
 
                        // recurse


Other related posts:

  • » [haiku-commits] haiku: hrev45511 - in src/apps/debugger/user_interface/gui: team_window model - anevilyak