Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made ImageLoader.zip_loader skip loaders that raised an error or returned None. #985

Merged
merged 1 commit into from Mar 6, 2013

Conversation

meric
Copy link
Contributor

@meric meric commented Feb 26, 2013

For some reason one of the image loaders was failing on Mac OS X. Running the widgets/sequence_images example:

[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_001.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_001.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_002.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_002.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_003.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_003.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_004.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_004.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_005.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_005.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_006.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_006.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_007.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_007.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_008.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_008.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_009.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_009.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_010.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_010.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_011.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_011.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_012.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_012.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_013.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_013.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_014.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_014.png> in zip <data/images/button_white_animated.zip> trying to continue...
[DEBUG  ] [ImageImageIO] Load <buttonoverlay_dn_015.png> from <data/images/button_white_animated.zip>
[WARNING] [Image       ] Unable to load image<buttonoverlay_dn_015.png> in zip <data/images/button_white_animated.zip> trying to continue...
 Traceback (most recent call last):
   File "main.py", line 147, in <module>
     mainApp().run()
   File "/Library/Python/2.7/site-packages/kivy/app.py", line 527, in run
     root = self.build()
   File "main.py", line 140, in build
     upl = mainclass()
   File "main.py", line 76, in __init__
     background_normal = 'data/images/button_white_animated.zip')
   File "/Users/Eric/Projects/kivy/examples/widgets/sequenced_images/uix/custom_button.py", line 42, in __init__
     keep_ratio = self.keep_ratio, mipmap = True)
   File "/Library/Python/2.7/site-packages/kivy/uix/image.py", line 219, in __init__
     self.texture_update()
   File "/Library/Python/2.7/site-packages/kivy/uix/image.py", line 234, in texture_update
     nocache=self.nocache)
   File "/Library/Python/2.7/site-packages/kivy/core/image/__init__.py", line 418, in __init__
     self.filename = arg
   File "/Library/Python/2.7/site-packages/kivy/core/image/__init__.py", line 606, in _set_filename
     mipmap=self._mipmap, nocache=self._nocache)
   File "/Library/Python/2.7/site-packages/kivy/core/image/__init__.py", line 339, in load
     return ImageLoader.zip_loader(filename)
   File "/Library/Python/2.7/site-packages/kivy/core/image/__init__.py", line 276, in zip_loader
     raise Exception('no images in zip <%s>' % filename)
 Exception: no images in zip <data/images/button_white_animated.zip>

However, wrapping the:

im = loader(tmpfile, **kwargs)

in try...except was not enough.

Sometimes there was an image not recognized by any loader. (e.g. an artefact from the zip program while performing the zipping), and if that artefact turns out to be the last file attempted to be loaded, im in:

im._data = image_data

would be None, causing an AttributeError.

So I've had to change it to use another variable image to keep track of the last image successfully loaded. It is only assigned when im returned from the loader is not None.

@tito
Copy link
Member

tito commented Mar 6, 2013

Seems ok, thanks!

tito added a commit that referenced this pull request Mar 6, 2013
Made ImageLoader.zip_loader skip loaders that raised an error or returned None.
@tito tito merged commit af3949b into kivy:master Mar 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: graphics kivy/graphics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants