mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -05:00
Do not setIcon if icon cannot be drawn. Fix #715.
This commit is contained in:
parent
964155ed36
commit
e0d400cc8f
@ -33,19 +33,22 @@ drawIcon = (resultColor, profileColor) ->
|
||||
cacheKey = "omega+#{resultColor ? ''}+#{profileColor}"
|
||||
icon = iconCache[cacheKey]
|
||||
return icon if icon
|
||||
if not drawContext?
|
||||
drawContext = document.getElementById('canvas-icon').getContext('2d')
|
||||
try
|
||||
if not drawContext?
|
||||
drawContext = document.getElementById('canvas-icon').getContext('2d')
|
||||
|
||||
icon = {}
|
||||
for size in [16, 24, 32]
|
||||
drawContext.scale(size, size)
|
||||
drawContext.clearRect(0, 0, 1, 1)
|
||||
if resultColor?
|
||||
drawOmega drawContext, resultColor, profileColor
|
||||
else
|
||||
drawOmega drawContext, profileColor
|
||||
drawContext.setTransform(1, 0, 0, 1, 0, 0)
|
||||
icon[size] = drawContext.getImageData(0, 0, size, size)
|
||||
icon = {}
|
||||
for size in [16, 24, 32]
|
||||
drawContext.scale(size, size)
|
||||
drawContext.clearRect(0, 0, 1, 1)
|
||||
if resultColor?
|
||||
drawOmega drawContext, resultColor, profileColor
|
||||
else
|
||||
drawOmega drawContext, profileColor
|
||||
drawContext.setTransform(1, 0, 0, 1, 0, 0)
|
||||
icon[size] = drawContext.getImageData(0, 0, size, size)
|
||||
catch
|
||||
icon = null
|
||||
|
||||
return iconCache[cacheKey] = icon
|
||||
|
||||
|
@ -63,6 +63,7 @@ class ChromeTabs
|
||||
)
|
||||
|
||||
setIcon: (icon, tabId) ->
|
||||
return unless icon?
|
||||
if tabId?
|
||||
chrome.browserAction.setIcon({
|
||||
imageData: icon
|
||||
@ -72,6 +73,7 @@ class ChromeTabs
|
||||
chrome.browserAction.setIcon({imageData: icon}, @ignoreError)
|
||||
|
||||
clearIcon: (tabId) ->
|
||||
return unless @_defaultAction?.icon?
|
||||
chrome.browserAction.setIcon({
|
||||
imageData: @_defaultAction.icon
|
||||
tabId: tabId
|
||||
|
Loading…
Reference in New Issue
Block a user