Make the check for an existing icon more robust.
(cherry picked from commit 8b1d8159331e85569d78f5637df49366e5198f40)