diff --git a/src/app/mod.rs b/src/app/mod.rs index f01d19c68..35264aa75 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -2150,22 +2150,9 @@ impl OpenCADStudio { #[cfg(not(target_arch = "wasm32"))] fn boot() -> (Self, Task) { use helpers::build_window_icon; - // Silently (re)register this binary as a .dwg/.dxf handler so it appears - // in the OS "Open with" list. Best-effort and idempotent; covers the - // portable .exe / AppImage that no installer has registered. Detached so - // it never delays startup. - std::thread::spawn(|| { - // Honour the FILEASSOC toggle: skip (re)registration when the user - // has turned file association off. - let enabled = settings::UserSettings::load() - .map(|s| s.file_assoc_enabled) - .unwrap_or(true); - if enabled { - if let Err(e) = crate::io::file_association::register_as_handler() { - eprintln!("file association: handler registration failed: {e}"); - } - } - }); + // File association is no longer re-registered on every launch. It is set + // up once via the first-launch prompt below (when the user hasn't been + // asked yet) and afterwards managed entirely by the FILEASSOC command. let state = Self::new(); let (id, open_task) = window::open(window::Settings { maximized: true, diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs index 8f67c69ba..a8b2554e3 100644 --- a/src/app/update/mod.rs +++ b/src/app/update/mod.rs @@ -2590,14 +2590,18 @@ impl OpenCADStudio { Task::none() } Message::AssocPromptYes => { + self.file_assoc_enabled = true; self.mark_assoc_prompted(); self.active_modal = None; + // set_default_app registers the handler first, then makes us the + // default — boot no longer does this automatically. Task::perform( crate::io::file_association::set_default_app(), Message::AssocResult, ) } Message::AssocPromptNo => { + self.file_assoc_enabled = false; self.mark_assoc_prompted(); self.active_modal = None; Task::none() diff --git a/src/io/file_association.rs b/src/io/file_association.rs index 60880f54e..300769ccf 100644 --- a/src/io/file_association.rs +++ b/src/io/file_association.rs @@ -96,6 +96,10 @@ pub async fn set_default_app() -> Result { } fn set_default_app_blocking() -> Result { + // Boot no longer auto-registers, so make sure the handler entries (the + // .desktop / mime package / ProgIDs) exist before asking the OS to default + // to us — otherwise the default would point at nothing. + register_as_handler()?; #[cfg(target_os = "windows")] { windows_impl::set_default()