This can be demonstrated by the following simplified example:
Code: Select all
#target photoshop
s2t = stringIDToTypeID;
(A = new ActionDescriptor).putInteger(s2t('test'), 0);
(B = new ActionDescriptor).putInteger(s2t('test'), 0);
//(C = new ActionDescriptor).putObject(s2t('test'), s2t('object'), A);
//(D = new ActionDescriptor).putObject(s2t('test'), s2t('object'), B);
alert ('A equal B ? ' + A.isEqual(B) + '\nA toStream B ? ' + (A.toStream ()== B.toStream())+ '\nproperty value from A == property value from B ? ' + (A.getInteger(s2t('test')) == B.getInteger(s2t('test'))) )
If you remove the second comment (line (D = new ActionDescriptor) .putObject (s2t ('test'), s2t ('object'), B)), the script will report that the objects are the same again.
For a long time I could not understand what was the matter. I tried to parse the .toStream () byte array and saw that when placing ActionDescriptor A in another ActionDescriptor, several characters are appended to its beginning. By exception method, I realized that this is the classID specified when A was placed in C.
I.e:
a) the newly created ActionDescpriptor does not contain a classID
b) if you place this ActionDescpriptor as an object in another ActionDescpriptor, then the original ActionDescpriptor will also be changed - the classID specified in the process of writing to the object will be added to it.
I don’t know why I am writing all this, but maybe this information will be useful to someone. I have previously encountered this problem and I had to parse ActionDescpriptor
on properties to correctly compare, now I understand that it is enough to assign the same classID to two ActionDescpriptor