From 43c0eda2be403d24c83049356a1333efb0620ab2 Mon Sep 17 00:00:00 2001 From: Christian Passlack Date: Fri, 20 Mar 2015 11:21:07 +0100 Subject: [PATCH] Fixed: Encoding a [CPDecimalNumber zero] causes a corrupt CPDecimalNumber after decoding Previously, CPNumber and CPDecimalNumber shared the same method UID and CPNumberUIDs-Dictionary. This leads to some unexpected errors for example a [CPDecimalNumber zero] which refers to itself after decoding. CPDecimalNumber now overwrites the method UID and has its own UID-Dictionary. Fixes #2332 --- Foundation/CPDecimalNumber.j | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Foundation/CPDecimalNumber.j b/Foundation/CPDecimalNumber.j index 7221cd2e5..39c221d53 100644 --- a/Foundation/CPDecimalNumber.j +++ b/Foundation/CPDecimalNumber.j @@ -28,6 +28,8 @@ // The default global behavior class, created lazily var CPDefaultDcmHandler = nil; +var CPDecimalNumberUIDs = new CFMutableDictionary(); + /*! @class CPDecimalNumberHandler @ingroup foundation @@ -531,6 +533,20 @@ var CPDecimalNumberHandlerRoundingModeKey = @"CPDecimalNumberHandlerRoundi } // instance methods + +- (CPString)UID +{ + var UID = CPDecimalNumberUIDs.valueForKey(self); + + if (!UID) + { + UID = objj_generateObjectUID(); + CPDecimalNumberUIDs.setValueForKey(self, UID); + } + + return UID + ""; +} + /*! Returns a new CPDecimalNumber object with the result of the summation of the receiver object and \c decimalNumber. If overflow occurs then the