From 1301ad9f92006bb8d720391b74cafdb51be1e038 Mon Sep 17 00:00:00 2001 From: Cezar Augusto Date: Sat, 23 Sep 2017 17:41:59 -0300 Subject: [PATCH] check for the active frame before updating tabPage Auditors: @bbondy fix #11028 --- app/renderer/reducers/frameReducer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/renderer/reducers/frameReducer.js b/app/renderer/reducers/frameReducer.js index b4a59ab283f..4cf4af8ee96 100644 --- a/app/renderer/reducers/frameReducer.js +++ b/app/renderer/reducers/frameReducer.js @@ -106,9 +106,13 @@ const frameReducer = (state, action, immutableAction) => { state = frameStateUtil.updateFramesInternalIndex(state, Math.min(sourceFrameIndex, index)) state = frameStateUtil.moveFrame(state, tabId, index) - // Update tab page index to the active tab in case the active tab changed const activeFrame = frameStateUtil.getActiveFrame(state) - state = frameStateUtil.updateTabPageIndex(state, activeFrame.get('tabId')) + // avoid the race-condition of updating the tabPage + // while active frame is not yet defined + if (activeFrame) { + // Update tab page index to the active tab in case the active tab changed + state = frameStateUtil.updateTabPageIndex(state, activeFrame.get('tabId')) + } state = frameStateUtil.setPreviewFrameKey(state, null) }