ResourcePack.st
changeset 5826 c4ed474970c1
parent 5781 fc35ed4fd223
child 5951 61a41352ce81
--- a/ResourcePack.st	Tue Sep 27 18:25:51 2011 +0200
+++ b/ResourcePack.st	Wed Sep 28 15:55:53 2011 +0200
@@ -13,7 +13,7 @@
 
 Dictionary subclass:#ResourcePack
 	instanceVariableNames:'packsClassName fileReadFailed superPack projectPack'
-	classVariableNames:'Packs DebugModifications'
+	classVariableNames:'Packs FailedToLoadPacks DebugModifications'
 	poolDictionaries:''
 	category:'Interface-Internationalization'
 !
@@ -204,14 +204,15 @@
 
 initialize
     Packs isNil ifTrue:[
-        Packs := WeakArray new:100
+        Packs := WeakArray new:100.
+        FailedToLoadPacks := Set new.
     ].
 
     "
      ResourcePack initialize
     "
 
-    "Modified: / 18-09-2006 / 20:37:38 / cg"
+    "Modified: / 28-09-2011 / 15:53:21 / cg"
 ! !
 
 !ResourcePack class methodsFor:'instance creation'!
@@ -320,7 +321,8 @@
 
 forPackage:package resourceFileName:resourceFileName cached:cached
     "get the full resource definitions given a package id (such as stx:libbasic').
-     Also optionally leave the resulting pack in the cache for faster access next time."
+     Also optionally leave the resulting pack in the cache for faster access next time.
+     Remember failed packs, to avoid retrying reading the file again and again"
 
     |fullName pack rsrcDir file|
 
@@ -329,16 +331,23 @@
     cached ifTrue:[
         pack := self searchCacheFor:fullName.
         pack notNil ifTrue:[^ pack].
+        (FailedToLoadPacks includes:fullName) ifTrue:[^ nil].
     ].
 
     rsrcDir := Smalltalk projectDirectoryForPackage:package.
     rsrcDir isNil ifTrue:[
         file := Smalltalk getResourceFileName:resourceFileName forPackage:package.
-        file isNil ifTrue:[^ nil].
+        file isNil ifTrue:[
+            FailedToLoadPacks add:fullName.
+            ^ nil
+        ].
         rsrcDir := file asFilename directory.
     ] ifFalse:[
         rsrcDir := rsrcDir asFilename construct:'resources'.
-        rsrcDir exists ifFalse:[^ nil].
+        rsrcDir exists ifFalse:[
+            FailedToLoadPacks add:fullName.
+            ^ nil
+        ].
     ].
 
     pack := self fromFile:resourceFileName directory:rsrcDir cached:cached.
@@ -349,7 +358,7 @@
      ResourcePack forPackage:'stx:libbasic' resourceFileName:'resources.rs' cached:false     
     "
 
-    "Modified: / 19-10-2006 / 23:18:28 / cg"
+    "Modified: / 28-09-2011 / 15:55:30 / cg"
 !
 
 fromFile:aFileName
@@ -1398,11 +1407,11 @@
 !ResourcePack class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.149 2011-08-20 15:13:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.150 2011-09-28 13:55:53 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.149 2011-08-20 15:13:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.150 2011-09-28 13:55:53 cg Exp $'
 ! !
 
 ResourcePack initialize!