#BUGFIX by stefan
class: Behavior
changed: #readFrom:onError:
https://expeccoalm.exept.de/D262670
Allow to restore ProtoObjects (especially BridgeObjects)
--- a/Behavior.st Mon Jun 04 09:59:09 2018 +0200
+++ b/Behavior.st Tue Jun 05 12:36:12 2018 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
@@ -3012,16 +3010,17 @@
This is the reverse operation to 'storeOn:'.
WARNING: storeOn: does not handle circular references and multiple
- references to the same object.
- Use #storeBinary:/readBinaryFrom: for this."
+ references to the same object.
+ Use #storeBinary:/readBinaryFrom: for this."
^ [
- |newObject|
-
- newObject := self evaluatorClass evaluateFrom:aStream ifFail:[^ exceptionBlock value].
- ((newObject class == self) or:[newObject isKindOf:self])
- ifTrue:[newObject]
- ifFalse:[exceptionBlock value].
+ |newObject|
+
+ newObject := self evaluatorClass evaluateFrom:aStream ifFail:[^ exceptionBlock value].
+ "ProtoObjects do not inherit from Obejct. Take care when restoring them"
+ ((newObject class == self) or:[(newObject isKindOf:self) or:[self == Object and:[newObject isProtoObject]]])
+ ifTrue:[newObject]
+ ifFalse:[exceptionBlock value].
] on:Error do:exceptionBlock.
"
@@ -3029,7 +3028,7 @@
s := WriteStream on:String new.
#(1 2 3 4) storeOn:s.
Transcript showCR:(
- Array readFrom:(ReadStream on:s contents) onError:'not an Array'
+ Array readFrom:(ReadStream on:s contents) onError:'not an Array'
)
"
"
@@ -3037,7 +3036,7 @@
s := WriteStream on:String new.
#[1 2 3 4] storeOn:s.
Transcript showCR:(
- Array readFrom:(ReadStream on:s contents) onError:'not an Array'
+ Array readFrom:(ReadStream on:s contents) onError:'not an Array'
)
"
"
@@ -3047,6 +3046,7 @@
"Modified: / 16-02-2017 / 21:26:38 / stefan"
"Modified: / 28-07-2017 / 18:58:13 / cg"
+ "Modified: / 05-06-2018 / 12:11:48 / Stefan Vogel"
!
readFromString:aString