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

UI::Image#source= method causes crash if image does not exist #76

Open
brucemontegani opened this issue May 11, 2017 · 0 comments
Open

Comments

@brucemontegani
Copy link

If you pass a string as parameter to the source= method and the image does not exist then application will crash later in the method because the proxy(UIImageView).image is nil and sending the size message to nil causes the crash. Suggest there needs to be a default 'image not found' image provided for all images that cannot be found.

def source=(source)
      if @source != source
        @source = source

        image = case source
          when String
            UIImage.imageNamed(source)
          when NSData
            UIImage.imageWithData(source)
          else
            raise "Expected `String' or `NSData' object, got `#{source.class}'"
        end
        @original_image = proxy.image = image

        if width.nan? and height.nan?
          self.width = proxy.image.size.width
          self.height = proxy.image.size.height
        end
      end
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant