1- use super :: { CefTexture , backend } ;
1+ use super :: CefTexture ;
22use crate :: browser:: LifecycleState ;
3+ use crate :: cef_texture:: backend;
34use crate :: error:: CefError ;
45use godot:: prelude:: * ;
56
67impl CefTexture {
78 fn log_cleanup_state_violations ( & self ) {
8- if self . app . state . is_some ( ) {
9+ if self . with_app ( | app| app . state . is_some ( ) ) {
910 godot:: global:: godot_warn!(
1011 "[CefTexture] Cleanup invariant violation: runtime state not fully cleared"
1112 ) ;
1213 }
14+ let lifecycle_state = self . with_app ( |app| app. lifecycle_state ( ) ) ;
1315 if !matches ! (
14- self . app . lifecycle_state( ) ,
16+ lifecycle_state,
1517 LifecycleState :: Closed | LifecycleState :: Retained
1618 ) {
1719 godot:: global:: godot_warn!(
1820 "[CefTexture] Cleanup invariant violation: unexpected lifecycle state {:?}" ,
19- self . app . lifecycle_state( )
21+ lifecycle_state
2022 ) ;
2123 }
2224 }
2325
2426 pub ( super ) fn cleanup_instance ( & mut self ) {
2527 self . base_mut ( ) . set_visible ( false ) ;
26- backend:: cleanup_runtime ( & mut self . app , self . popup_texture_2d_rd . as_mut ( ) ) ;
28+ let mut popup_texture_2d_rd = self . popup_texture_2d_rd . take ( ) ;
29+ self . with_app_mut ( |app| backend:: cleanup_runtime ( app, popup_texture_2d_rd. as_mut ( ) ) ) ;
30+ self . popup_texture_2d_rd = popup_texture_2d_rd;
2731
2832 self . ime_active = false ;
2933 self . ime_proxy = None ;
30- self . last_find_query = GString :: new ( ) ;
31- self . last_find_match_case = false ;
3234
3335 if let Some ( mut overlay) = self . popup_overlay . take ( ) {
3436 overlay. queue_free ( ) ;
@@ -50,33 +52,35 @@ impl CefTexture {
5052 }
5153
5254 pub ( super ) fn try_create_browser ( & mut self ) -> Result < ( ) , CefError > {
53- if self . app . state . is_some ( ) {
55+ if self . with_app ( | app| app . state . is_some ( ) ) {
5456 return Ok ( ( ) ) ;
5557 }
56- if !self . app . begin_browser_create ( ) {
58+ if !self . with_app_mut ( | app| app . begin_browser_create ( ) ) {
5759 return Ok ( ( ) ) ;
5860 }
5961
6062 let logical_size = self . base ( ) . get_size ( ) ;
6163 let dpi = self . get_pixel_scale_factor ( ) ;
64+ let max_fps = self . get_max_fps ( ) ;
6265 let params = backend:: BackendCreateParams {
6366 logical_size,
6467 dpi,
65- max_fps : self . get_max_fps ( ) ,
68+ max_fps,
6669 url : self . url . to_string ( ) ,
6770 enable_accelerated_osr : self . enable_accelerated_osr ,
6871 background_color : self . background_color ,
6972 popup_policy : self . popup_policy ,
7073 software_target_texture : None ,
7174 log_prefix : "CefTexture" ,
7275 } ;
73- if let Err ( err) = backend:: try_create_browser ( & mut self . app , & params) {
74- self . app . mark_browser_closed ( ) ;
76+ if let Err ( err) = self . with_app_mut ( |app| backend:: try_create_browser ( app, & params) ) {
77+ self . with_app_mut ( | app| app . mark_browser_closed ( ) ) ;
7578 return Err ( err) ;
7679 }
77- self . app . mark_browser_running ( ) ;
78- if let Some ( state) = self . app . state . as_ref ( ) {
79- let texture = state. render_mode . texture_2d ( ) ;
80+ self . with_app_mut ( |app| app. mark_browser_running ( ) ) ;
81+ if let Some ( texture) =
82+ self . with_app ( |app| app. state . as_ref ( ) . map ( |s| s. render_mode . texture_2d ( ) ) )
83+ {
8084 self . base_mut ( ) . set_texture ( & texture) ;
8185 }
8286
0 commit comments