diff options
| author | Jez Ng | 2012-11-03 14:36:40 -0400 |
|---|---|---|
| committer | Jez Ng | 2012-11-03 14:36:40 -0400 |
| commit | 06863a5fba5ed3c1456ce393753513b642bc1f74 (patch) | |
| tree | b0ae7344a182d145eda381213c6fd0837f48c3f2 /background_scripts | |
| parent | 0de3404a19779f33d19790488403dbf1335389c6 (diff) | |
| download | vimium-06863a5fba5ed3c1456ce393753513b642bc1f74.tar.bz2 | |
Fix race condition in tabInfo deletion.
Also initialize tabInfo fields at once, so as to avoid unnecessary
hidden class transitions.
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 6ff3fa60..e2bfeb6d 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -278,7 +278,16 @@ selectTab = (callback, direction) -> chrome.tabs.update(toSelect.id, { selected: true }))) updateOpenTabs = (tab) -> - tabInfoMap[tab.id] = { url: tab.url, positionIndex: tab.index, windowId: tab.windowId } + # Chrome might reuse the tab ID of a recently removed tab. + if tabInfoMap[tab.id]?.deletor + clearTimeout tabInfoMap[tab.id].deletor + tabInfoMap[tab.id] = + url: tab.url + positionIndex: tab.index + windowId: tab.windowId + scrollX: null + scrollY: null + deletor: null # Frames are recreated on refresh delete framesForTab[tab.id] @@ -354,7 +363,8 @@ chrome.tabs.onRemoved.addListener (tabId) -> # keep the reference around for a while to wait for the last messages from the closed tab (e.g. for updating # scroll position) - setTimeout (-> delete tabInfoMap[tabId]), 1000 + tabInfoMap.deletor = -> delete tabInfoMap[tabId] + setTimeout tabInfoMap.deletor, 1000 delete framesForTab[tabId] chrome.tabs.onActiveChanged.addListener (tabId, selectInfo) -> updateActiveState(tabId) |
