RecordingTip hide race condition 수정
- showRecordingTip: 이전 측정 리스너 제거 후 새로 등록 - hideRecordingTip: _tipHidden 플래그 + pending 리스너 즉시 제거 - 측정 응답이 hide 이후에 도착해도 다시 show하지 않음
This commit is contained in:
parent
0c79af6b03
commit
788600b66b
1 changed files with 28 additions and 3 deletions
|
|
@ -126,18 +126,35 @@ export function getRecordingTipWindow(): BrowserWindow {
|
||||||
* Phase 1: prepare → 측정
|
* Phase 1: prepare → 측정
|
||||||
* Phase 2: resize → show
|
* Phase 2: resize → show
|
||||||
*/
|
*/
|
||||||
|
// RecordingTip 측정 리스너 관리 (race condition 방지)
|
||||||
|
let _tipMeasuredHandler: ((_event: Electron.IpcMainEvent, data: { width: number; height: number }) => void) | null = null
|
||||||
|
let _tipHidden = false
|
||||||
|
|
||||||
export function showRecordingTip(
|
export function showRecordingTip(
|
||||||
state: string,
|
state: string,
|
||||||
params?: { text?: string; errorMessage?: string }
|
params?: { text?: string; errorMessage?: string }
|
||||||
): void {
|
): void {
|
||||||
const win = getRecordingTipWindow()
|
const win = getRecordingTipWindow()
|
||||||
|
_tipHidden = false
|
||||||
|
|
||||||
|
// 이전 측정 리스너 제거 (중복 방지)
|
||||||
|
if (_tipMeasuredHandler) {
|
||||||
|
ipcMain.removeListener('window:tipMeasured', _tipMeasuredHandler)
|
||||||
|
_tipMeasuredHandler = null
|
||||||
|
}
|
||||||
|
|
||||||
// Phase 1: prepare (크기 측정)
|
// Phase 1: prepare (크기 측정)
|
||||||
win.webContents.send('window:tipPrepare', { state, ...params })
|
win.webContents.send('window:tipPrepare', { state, ...params })
|
||||||
|
|
||||||
// tipMeasured 이벤트를 한번만 처리
|
// tipMeasured 이벤트를 한번만 처리
|
||||||
const handler = (_event: Electron.IpcMainEvent, data: { width: number; height: number }) => {
|
_tipMeasuredHandler = (_event: Electron.IpcMainEvent, data: { width: number; height: number }) => {
|
||||||
ipcMain.removeListener('window:tipMeasured', handler)
|
if (_tipMeasuredHandler) {
|
||||||
|
ipcMain.removeListener('window:tipMeasured', _tipMeasuredHandler)
|
||||||
|
_tipMeasuredHandler = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// hide가 이미 호출되었으면 show하지 않음
|
||||||
|
if (_tipHidden) return
|
||||||
|
|
||||||
// 커서 위치에 표시
|
// 커서 위치에 표시
|
||||||
const cursorPos = screen.getCursorScreenPoint()
|
const cursorPos = screen.getCursorScreenPoint()
|
||||||
|
|
@ -162,10 +179,18 @@ export function showRecordingTip(
|
||||||
win.webContents.send('window:tipShow', { state })
|
win.webContents.send('window:tipShow', { state })
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on('window:tipMeasured', handler)
|
ipcMain.on('window:tipMeasured', _tipMeasuredHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hideRecordingTip(): void {
|
export function hideRecordingTip(): void {
|
||||||
|
_tipHidden = true
|
||||||
|
|
||||||
|
// pending 측정 리스너 제거 (늦게 도착하면 다시 show되는 버그 방지)
|
||||||
|
if (_tipMeasuredHandler) {
|
||||||
|
ipcMain.removeListener('window:tipMeasured', _tipMeasuredHandler)
|
||||||
|
_tipMeasuredHandler = null
|
||||||
|
}
|
||||||
|
|
||||||
if (recordingTipWindow && !recordingTipWindow.isDestroyed()) {
|
if (recordingTipWindow && !recordingTipWindow.isDestroyed()) {
|
||||||
recordingTipWindow.hide()
|
recordingTipWindow.hide()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue