@@ -128,23 +128,26 @@ impl<R: Runtime> PendingWindow<R> {
128128 window_builder : <R :: Dispatcher as Dispatch >:: WindowBuilder ,
129129 webview_attributes : WebviewAttributes ,
130130 label : impl Into < String > ,
131- ) -> Self {
131+ ) -> crate :: Result < Self > {
132132 let mut menu_ids = HashMap :: new ( ) ;
133133 if let Some ( menu) = window_builder. get_menu ( ) {
134134 get_menu_ids ( & mut menu_ids, menu) ;
135135 }
136136 let label = label. into ( ) ;
137- assert_label_is_valid ( & label) ;
138- Self {
139- window_builder,
140- webview_attributes,
141- uri_scheme_protocols : Default :: default ( ) ,
142- label,
143- ipc_handler : None ,
144- file_drop_handler : None ,
145- url : "tauri://localhost" . to_string ( ) ,
146- menu_ids : Arc :: new ( Mutex :: new ( menu_ids) ) ,
147- js_event_listeners : Default :: default ( ) ,
137+ if !is_label_valid ( & label) {
138+ Err ( crate :: Error :: InvalidWindowLabel )
139+ } else {
140+ Ok ( Self {
141+ window_builder,
142+ webview_attributes,
143+ uri_scheme_protocols : Default :: default ( ) ,
144+ label,
145+ ipc_handler : None ,
146+ file_drop_handler : None ,
147+ url : "tauri://localhost" . to_string ( ) ,
148+ menu_ids : Arc :: new ( Mutex :: new ( menu_ids) ) ,
149+ js_event_listeners : Default :: default ( ) ,
150+ } )
148151 }
149152 }
150153
@@ -153,24 +156,27 @@ impl<R: Runtime> PendingWindow<R> {
153156 window_config : WindowConfig ,
154157 webview_attributes : WebviewAttributes ,
155158 label : impl Into < String > ,
156- ) -> Self {
159+ ) -> crate :: Result < Self > {
157160 let window_builder = <<R :: Dispatcher as Dispatch >:: WindowBuilder >:: with_config ( window_config) ;
158161 let mut menu_ids = HashMap :: new ( ) ;
159162 if let Some ( menu) = window_builder. get_menu ( ) {
160163 get_menu_ids ( & mut menu_ids, menu) ;
161164 }
162165 let label = label. into ( ) ;
163- assert_label_is_valid ( & label) ;
164- Self {
165- window_builder,
166- webview_attributes,
167- uri_scheme_protocols : Default :: default ( ) ,
168- label,
169- ipc_handler : None ,
170- file_drop_handler : None ,
171- url : "tauri://localhost" . to_string ( ) ,
172- menu_ids : Arc :: new ( Mutex :: new ( menu_ids) ) ,
173- js_event_listeners : Default :: default ( ) ,
166+ if !is_label_valid ( & label) {
167+ Err ( crate :: Error :: InvalidWindowLabel )
168+ } else {
169+ Ok ( Self {
170+ window_builder,
171+ webview_attributes,
172+ uri_scheme_protocols : Default :: default ( ) ,
173+ label,
174+ ipc_handler : None ,
175+ file_drop_handler : None ,
176+ url : "tauri://localhost" . to_string ( ) ,
177+ menu_ids : Arc :: new ( Mutex :: new ( menu_ids) ) ,
178+ js_event_listeners : Default :: default ( ) ,
179+ } )
174180 }
175181 }
176182
0 commit comments