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
This commit is contained in:
Christian Passlack
2015-03-20 11:21:07 +01:00
parent 7c095175ab
commit 43c0eda2be
+16
View File
@@ -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