Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for PR 39087: Cache the MI answer once we know if the variable is writable

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.210
diff -u -r1.210 ChangeLog
--- ChangeLog 24 Jun 2003 05:30:40 -0000 1.210
+++ ChangeLog 30 Jun 2003 17:59:39 -0000
@@ -1,3 +1,7 @@
+2003-06-30 Mikhail Khodjaiants
+ Fix for PR 39087: Cache the MI answer once we know if the variable is writable.
+ * CVariable.java
+
 2003-06-24 Mikhail Khodjaiants
  All local var_objects are destroyed when a thread other than current is selected.
  CVariable has to be invalidated if a "destroyed" event has been received.
Index: src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java,v
retrieving revision 1.42
diff -u -r1.42 CVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 24 Jun 2003 05:30:41 -0000 1.42
+++ src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 30 Jun 2003 17:59:40 -0000
@@ -53,6 +53,10 @@
 
   private ICDIVariable fCDIVariable;
 
+  private Boolean fEditable = null;
+
+  private ICType fType = null;
+
   public InternalVariable( ICDIVariableObject varObject )
   {
    setCDIVariableObject( varObject );
@@ -76,6 +80,28 @@
    return fCDIVariableObject;
   }
 
+  protected ICType getType() throws CDIException
+  {
+   if ( fType == null )
+   {
+    ICDIVariable var = getCDIVariable();
+    if ( var != null )
+     fType = new CType( var.getType() );
+   }
+   return fType;
+  }
+
+  protected boolean isEditable() throws CDIException
+  {
+   if ( fEditable == null )
+   {
+    ICDIVariable var = getCDIVariable();
+    if ( var != null )
+     fEditable = new Boolean( var.isEditable() );
+   }
+   return ( fEditable != null ) ? fEditable.booleanValue() : false;
+  }
+
   private void setCDIVariable( ICDIVariable variable )
   {
    fCDIVariable = variable;
@@ -98,6 +124,10 @@
     logError( e.getMessage() );
    }
    setCDIVariable( null );
+   if ( fType != null )
+    fType.dispose();
+   fType = null;
+   fEditable = null;
   }
 
   protected void dispose()
@@ -142,19 +172,12 @@
   */
  private String fQualifiedName = null;
 
- private Boolean fEditable = null;
-
  /**
   * Change flag.
   */
  protected boolean fChanged = false;
 
  /**
-  * The type of this variable.
-  */
- private ICType fType = null;
-
- /**
   * The current format of this variable.
   */
  protected int fFormat = ICDIFormat.NATURAL;
@@ -674,20 +697,18 @@
  {
   if ( !isEnabled() )
    return false;
-  if ( fEditable == null )
+  boolean result = false;
+  try
   {
-   try
-   {
-    ICDIVariable var = getCDIVariable();
-    if ( var != null )
-     fEditable = new Boolean( var.isEditable() );
-   }
-   catch( CDIException e )
-   {
-    logError( e );
-   }
+   InternalVariable var = getInternalVariable();
+   if ( var != null )
+    result = var.isEditable();
   }
-  return ( fEditable != null ) ? fEditable.booleanValue() : false;
+  catch( CDIException e )
+  {
+   logError( e );
+  }
+  return result;
  }
 
  /* (non-Javadoc)
@@ -759,20 +780,21 @@
   */
  public ICType getType() throws DebugException
  {
-  if ( isEnabled() && fType == null )
+  ICType type = null;
+  if ( isEnabled() )
   {
    try
    {
-    ICDIVariable var = getCDIVariable();
-    if ( var != null )
-     fType = new CType( var.getType() );
+    InternalVariable iv = getInternalVariable();
+    if ( iv != null )
+     type = iv.getType();
    }
    catch( CDIException e )
    {
     requestFailed( "Type is not available.", e );
    }
   }
-  return fType;
+  return type;
  }
 
  /* (non-Javadoc)
@@ -809,10 +831,6 @@
    ((CValue)fValue).dispose();
    fValue = null;
   }
-  fEditable = null;
-  if ( fType != null )
-   fType.dispose();
-  fType = null;
  }
 
  protected boolean isArgument()
@@ -850,5 +868,10 @@
  {
   return ( ( getShadow() != null && getShadow().isSameVariable( cdiVar ) ) ||
      ( fOriginal != null && fOriginal.isSameVariable( cdiVar ) ) );
+ }
+
+ private InternalVariable getInternalVariable()
+ {
+  return ( getShadow() != null ) ? getShadow() : fOriginal;
  }
 }

Back to the top