@@ -17,6 +17,7 @@ use log::info;
1717use parking_lot:: Mutex ;
1818use semver:: Version ;
1919
20+ use crate :: egui:: ViewportCommand ;
2021use crate :: background_work:: BackgroundThreadMessage ;
2122use crate :: error:: { ModLoaderError , ModLoaderWarning } ;
2223use crate :: game_mod:: { GameMod , SelectedVersion } ;
@@ -234,6 +235,16 @@ impl App for ModLoaderApp {
234235 }
235236 }
236237
238+ if ctx. input ( |i| i. viewport ( ) . close_requested ( ) ) {
239+ let _ = self . background_tx . send ( BackgroundThreadMessage :: Exit ) ;
240+
241+ if self . ready_exit . load ( Ordering :: Acquire ) {
242+ info ! ( "Exiting..." ) ;
243+ }
244+
245+ self . ready_exit . load ( Ordering :: Acquire ) ;
246+ }
247+
237248 if darken_background {
238249 self . darken_background ( ctx) ;
239250 }
@@ -253,18 +264,8 @@ impl App for ModLoaderApp {
253264
254265 // when background thread is ready to exit kill app by ending main thread
255266 if self . ready_exit . load ( Ordering :: Acquire ) {
256- frame. close ( ) ;
257- }
258- }
259-
260- fn on_close_event ( & mut self ) -> bool {
261- let _ = self . background_tx . send ( BackgroundThreadMessage :: Exit ) ;
262-
263- if self . ready_exit . load ( Ordering :: Acquire ) {
264- info ! ( "Exiting..." ) ;
267+ ctx. send_viewport_cmd ( ViewportCommand :: Close ) ;
265268 }
266-
267- self . ready_exit . load ( Ordering :: Acquire )
268269 }
269270}
270271
@@ -685,7 +686,8 @@ impl ModLoaderApp {
685686
686687 strip. cell ( |ui| {
687688 ui. heading ( "Changelog" ) ;
688- CommonMarkViewer :: new ( "update_viewer" ) . show_scrollable (
689+ CommonMarkViewer :: new ( ) . show_scrollable (
690+ "update_viewer" ,
689691 ui,
690692 & mut self . markdown_cache ,
691693 & newer_update. changelog ,
@@ -754,7 +756,7 @@ impl ModLoaderApp {
754756 ui. with_layout ( egui:: Layout :: right_to_left ( egui:: Align :: Min ) , |ui| {
755757 ui. style_mut ( ) . spacing . button_padding = egui:: vec2 ( 6.0 , 6.0 ) ;
756758 if ui. button ( "Quit" ) . clicked ( ) {
757- frame . close ( ) ;
759+ ctx . send_viewport_cmd ( ViewportCommand :: Close ) ;
758760 }
759761 } ) ;
760762 } ) ;
@@ -1019,7 +1021,8 @@ impl ModLoaderApp {
10191021 } ) ;
10201022
10211023 egui:: CentralPanel :: default ( ) . show_inside ( ui, |ui| {
1022- CommonMarkViewer :: new ( "viewer" ) . show_scrollable (
1024+ CommonMarkViewer :: new ( ) . show_scrollable (
1025+ "viewer" ,
10231026 ui,
10241027 & mut self . markdown_cache ,
10251028 & self . about_text ,
0 commit comments