Changeset 53:174b2929ba56 in finroc_core-java


Ignore:
Timestamp:
01.12.2010 02:13:28 (9 years ago)
Author:
Max Reichardt <reichardt@…>
Branch:
default
Phase:
public
Convert:
svn:fc394f53-5a1c-4f87-a64a-968f46d709a5/trunk@54
Message:

Removed Parameter memory leak when default value lies out of bounds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • org/finroc/core/parameter/NumericParameter.java

    r46 r53  
    3333import org.finroc.core.port.cc.CCPortListener; 
    3434import org.finroc.jc.annotation.Const; 
     35import org.finroc.jc.annotation.InCpp; 
    3536import org.finroc.jc.annotation.Ref; 
    3637import org.finroc.log.LogLevel; 
     
    6263        info = new ParameterInfo(); 
    6364        addAnnotation(info); 
    64         super.setDefault(new CoreNumber(defaultValue, u)); 
     65        @InCpp("T d = defaultValue;") 
     66        double d = defaultValue.doubleValue(); 
     67        if (b.inBounds(d)) { 
     68            super.setDefault(new CoreNumber(defaultValue, u)); 
     69        } else { 
     70            log(LogLevel.LL_DEBUG_WARNING, logDomain, "Default value is out of bounds"); 
     71            super.setDefault(new CoreNumber(b.toBounds(d), u)); 
     72        } 
    6573        currentValue = defaultValue; 
    6674        addPortListener(this); 
Note: See TracChangeset for help on using the changeset viewer.