Skip to content

Commit

Permalink
Assert only once we know URL has changed (#247)
Browse files Browse the repository at this point in the history
We need this in case someone is setting the URL to nil before setting
the image directly. I.e. they have a node which has been used as a network
node or an image node but now they want it to be an image node.

They should then set the URL to nil and then set the image.
*if* it was used as a network node previously, this would work.
If it was previously used as an image node it would historically assert.
This addresses that.
  • Loading branch information
garrettmoon committed May 5, 2017
1 parent 80357b1 commit 850aeb4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/ASNetworkImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ - (void)setURL:(NSURL *)URL resetToDefault:(BOOL)reset
{
ASDN::MutexLocker l(__instanceLock__);

ASDisplayNodeAssert(_imageWasSetExternally == NO, @"Setting a URL to an ASNetworkImageNode after setting an image changes its behavior from an ASImageNode to an ASNetworkImageNode. If this is what you want, set the image to nil first.");

_imageWasSetExternally = NO;

if (ASObjectIsEqual(URL, _URL)) {
return;
}

ASDisplayNodeAssert(_imageWasSetExternally == NO, @"Setting a URL to an ASNetworkImageNode after setting an image changes its behavior from an ASImageNode to an ASNetworkImageNode. If this is what you want, set the image to nil first.");

_imageWasSetExternally = NO;

[self _locked_cancelImageDownloadWithResumePossibility:NO];

_imageLoaded = NO;
Expand Down

0 comments on commit 850aeb4

Please sign in to comment.