[Etoys] ProjectLoading fix

Karl karl.ramberg at comhem.se
Thu May 10 09:51:08 EDT 2007

This is a fix to make old project load.
It should be reviewed by someone who understand this stuff  ;-)

-------------- next part --------------
'From OLPC2.0 of ''24 October 2006'' [latest update: #1340] on 10 May 2007 at 3:48:39 pm'!

!ProjectLoading class methodsFor: 'public' stamp: 'kfr 5/10/2007 15:47'!
openName: aFileName stream: preStream fromDirectory: aDirectoryOrNil
withProjectView: existingView
	"Reconstitute a Morph from the selected file, presumed to be
represent a Morph saved via the SmartRefStream mechanism, and open it
in an appropriate Morphic world."

   	| morphOrList archive mgr substituteFont numberOfFontSubstitutes resultArray anObject project manifests dict |
	(self checkStream: preStream) ifTrue: [^ self].
	ProgressNotification signal: '0.2'.
	archive _ preStream isZipArchive
		ifTrue:[ZipArchive new readFrom: preStream]
	archive ifNotNil:[
	manifests _ (archive membersMatching: '*manifest').
	(manifests size = 1 and: [((dict _ self parseManifest: manifests first contents) at: 'Project-Format' ifAbsent: []) = 'S-Expression'])
		ifTrue: [^ self openSexpProjectDict: dict stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView]].

	morphOrList _ self morphOrList: aFileName stream: preStream fromDirectory: aDirectoryOrNil archive: archive.
	morphOrList ifNil: [^ self].
	ProgressNotification  signal: '0.4'.
	resultArray _ self fileInName: aFileName archive: archive morphOrList: morphOrList.
	anObject _ resultArray first.
	numberOfFontSubstitutes _ resultArray second.
	substituteFont _ resultArray third.
	mgr _ resultArray fourth.
	preStream close.
	ProgressNotification  signal: '0.7'.
		"the hard part is over"
	(anObject isKindOf: ImageSegment) ifTrue: [
		project _ self loadImageSegment: anObject
			fromDirectory: aDirectoryOrNil
			withProjectView: existingView
			numberOfFontSubstitutes: numberOfFontSubstitutes
			substituteFont: substituteFont
			mgr: mgr.].
	(anObject isKindOf: ImageSegment) ifTrue: [
	ProgressNotification  signal: '0.8'.
		^ project
			ifNil: [self inform: 'No project found in this file' translated]
			ifNotNil: [ProjectEntryNotification signal: project]].
	self loadSqueakPage: anObject! !

More information about the etoys-dev mailing list