Skip to content

Commit 8a31eb8

Browse files
committed
fix: prevent empty dialog when using bundled distrobox
Two fixes: 1. Add guard in download_distrobox() to prevent duplicate download tasks when GSettings watcher synchronously re-triggers the download. 2. Harden TaskManagerDialog to handle already-parented selected_task_view by popping/unparenting before pushing a new NavigationPage.
1 parent e56bb5c commit 8a31eb8

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/dialogs/task_manager_dialog.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,18 @@ mod imp {
125125
>| {
126126
if let Some(task) = task {
127127
this.build_task_view(&task);
128+
// If selected_task_view already has a parent from a previous detail page,
129+
// pop the old page and unparent the view to avoid GTK assertion:
130+
// 'gtk_widget_get_parent (child) == NULL'
131+
let stv = &this.imp().selected_task_view;
132+
if stv.parent().is_some() {
133+
this.imp().navigation_view.pop();
134+
if stv.parent().is_some() {
135+
stv.unparent();
136+
}
137+
}
128138
this.imp().navigation_view.push(&adw::NavigationPage::new(
129-
&this.imp().selected_task_view,
139+
stv,
130140
"Task Details",
131141
));
132142
}

src/models/root_store.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ impl RootStore {
346346
}
347347

348348
pub fn download_distrobox(&self) -> DistroboxTask {
349+
// Guard: if a download task is already in progress, return it instead of creating a duplicate
350+
for task in self.tasks().iter() {
351+
if task.name() == "Downloading Distrobox" && !task.ended() {
352+
return task;
353+
}
354+
}
349355
let task = crate::distrobox_downloader::download_distrobox(self);
350356
self.tasks().append(&task);
351357
self.set_selected_task(Some(task.clone()));

0 commit comments

Comments
 (0)