Fix crash when setting custom VM icon (#2387) #2742
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It turns out there were two unrelated problems.
First, and caused the crash (Line 199):
The first time you set a custom icon, the
self.configuration.icon
isnil
, which crashesNSURL
's- (nullable NSURL *)URLByAppendingPathComponent:(NSString *)pathComponent
. I changed the code to check forself.configuration.icon
beingnil
so it would skip over the deleting the previous icon.Second, fix custom icon not being set creating a new VM (Line 143):
The setting
self.configuration
with theconfiguration
parameter wasn't setting theselectedCustomIconPath
. I added an extra line to also set just theselectedCustomIconPath
.