Avoid possible reentrancy of ThemeChanged (see #3671)

The call to SelectNativeTheme from ChromeBrowserFrame::Initialized was
causing Widget::ThemeChanged reentrancy via OnColorProviderCacheResetMissed
when running with `--enable-chrome-runtime --use-native`. Make all calls to
ThemeChanged async to avoid this and possible future issues.
This commit is contained in:
Marshall Greenblatt
2024-04-14 21:34:45 -04:00
parent 1482ffe749
commit e461d8f247
4 changed files with 23 additions and 7 deletions

View File

@@ -4,6 +4,7 @@
#include "libcef/browser/views/widget_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/views/window_view.h"
#include "libcef/features/runtime.h"
@@ -226,7 +227,9 @@ void CefWidgetImpl::NotifyThemeColorsChanged(bool chrome_theme,
if (window_view_) {
window_view_->OnThemeColorsChanged(chrome_theme);
if (call_theme_changed) {
ThemeChanged();
// Call ThemeChanged() asynchronously to avoid possible reentrancy.
CEF_POST_TASK(TID_UI, base::BindOnce(&CefWidgetImpl::ThemeChanged,
weak_ptr_factory_.GetWeakPtr()));
}
}
}