gpt4 book ai didi

electron - ElectronJs : app.退出使应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 12:22:00 24 4
gpt4 key购买 nike

任务
关闭所有窗口或关闭主窗口时,终止应用程序。

问题
调用app.quit()时应用程序崩溃。

代码

app.on('window-all-closed', function () {
// if (process.platform !== 'darwin') {
// app.quit();
// }

app.quit();
});



mainWindow.on('closed', function () {
mainWindow = null;
app.quit();

});

日志
[901:0531/114426:FATAL:resource_dispatcher_host_impl.cc(658)] Check failed: ContainsKey(active_resource_contexts_, context). 
0 Electron Framework 0x000000010bfa3903 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 389891
1 Electron Framework 0x000000010bfb9ec9 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 481481
2 Electron Framework 0x000000010c83b765 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 9400677
3 Electron Framework 0x000000010c8ff0cc _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 10201804
4 Electron Framework 0x000000010bf15009 _ZN9brightray14BrowserContext15ResourceContextD2Ev + 9
5 Electron Framework 0x000000010bf14f79 _ZN9brightray14BrowserContext15ResourceContextD1Ev + 9
6 Electron Framework 0x000000010bf14f8e _ZN9brightray14BrowserContext15ResourceContextD1Ev + 30
7 Electron Framework 0x000000010bf158cf _ZN4base12DeleteHelperIN9brightray14BrowserContext15ResourceContextEE8DoDeleteEPKv + 15
8 Electron Framework 0x000000010bfa3e0b _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 391179
9 Electron Framework 0x000000010bfc2973 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 516979
10 Electron Framework 0x000000010bfc2c4c _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 517708
11 Electron Framework 0x000000010bfc2e3b _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 518203
12 Electron Framework 0x000000010bf98a31 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 345137
13 Electron Framework 0x000000010bfd57e3 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 594403
14 Electron Framework 0x000000010bfc216d _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 514925
15 Electron Framework 0x000000010c6e7b38 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 8009016
16 Electron Framework 0x000000010c6e7d0e _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 8009486
17 Electron Framework 0x000000010bff4758 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 721240
18 Electron Framework 0x000000010bff0937 _ZN4base8internal30DstRangeRelationToSrcRangeImplIilLNS0_21IntegerRepresentationE1ELS2_1ELNS0_26NumericRangeRepresentationE0EE5CheckEl + 705335
19 libsystem_pthread.dylib 0x00007fff8780405a _pthread_body + 131
20 libsystem_pthread.dylib 0x00007fff87803fd7 _pthread_body + 0
21 libsystem_pthread.dylib 0x00007fff878013ed thread_start + 13

enter image description here

最佳答案

您两次调用app.quit()导致崩溃。只能在all-windows-closed上的closed事件处理程序或mainWindow事件处理程序中调用一次。

关于electron - ElectronJs : app.退出使应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37538122/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com