From a675e1a766046a12c8ed1b94f23e03b6e4526ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BA=A2=E5=B2=A9?= Date: Sun, 14 Apr 2024 12:06:50 +0800 Subject: [PATCH] U: Logic when using RunOnMainThread to determine IsMessage Loop --- cef/application.go | 4 +++- cef/application_config.go | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cef/application.go b/cef/application.go index 875f2697..b6df24fd 100644 --- a/cef/application.go +++ b/cef/application.go @@ -34,6 +34,8 @@ type TCEFApplication struct { onWebKitInitialized GlobalCEFAppEventOnWebKitInitialized onRegCustomSchemes GlobalCEFAppEventOnRegCustomSchemes onRenderLoadStart GlobalCEFAppEventOnRenderLoadStart + externalMessagePump bool + multiThreadedMessageLoop bool } // NewApplication 创建CEF应用 @@ -54,7 +56,7 @@ func NewApplication(disableRegisDefaultEvent ...bool) *TCEFApplication { // SetApplication // -// 设置全局 Application +// 设置全局 Application func SetApplication(app *TCEFApplication) { if application == nil { application = app diff --git a/cef/application_config.go b/cef/application_config.go index 2a1f5732..d9080ff8 100644 --- a/cef/application_config.go +++ b/cef/application_config.go @@ -191,15 +191,16 @@ func (m *TCEFApplication) MultiThreadedMessageLoop() bool { // IsMessageLoop // -// 消息轮询方式使用不同的窗口组件 -// return true: 使用VF(views framework)窗口组件, false: 使用LCL窗口组件 +// 不同的窗口组件使用不同的消息轮询 +// return +// true : VF(views framework)窗口组件 +// false: LCL窗口组件 func (m *TCEFApplication) IsMessageLoop() bool { - emp := m.ExternalMessagePump() - mtml := m.MultiThreadedMessageLoop() - return !emp && !mtml + return !m.externalMessagePump && !m.multiThreadedMessageLoop } func (m *TCEFApplication) SetMultiThreadedMessageLoop(value bool) { + m.multiThreadedMessageLoop = value imports.Proc(def.CEFAppConfig_SetMultiThreadedMessageLoop).Call(api.PascalBool(value)) } @@ -223,6 +224,7 @@ func (m *TCEFApplication) ExternalMessagePump() bool { func (m *TCEFApplication) SetExternalMessagePump(value bool) { if !m.IsSpecVer49() { + m.externalMessagePump = value imports.Proc(def.CEFAppConfig_SetExternalMessagePump).Call(api.PascalBool(value)) } }