Skip to content

Replaced hide() with destroy()#68

Merged
ericbsd merged 1 commit intomasterfrom
fix-window-memory-leak
Jan 14, 2026
Merged

Replaced hide() with destroy()#68
ericbsd merged 1 commit intomasterfrom
fix-window-memory-leak

Conversation

@ericbsd
Copy link
Member

@ericbsd ericbsd commented Jan 14, 2026

Updated conditionals for readability and bumped a version to 6.8 in setup.py.

Summary by Sourcery

Replace window hiding with destruction and update supporting code and metadata accordingly.

Bug Fixes:

  • Ensure update station windows and notifications are fully destroyed instead of merely hidden when closing or completing actions.

Enhancements:

  • Simplify boolean conditionals for readability in the frontend logic.
  • Refine setup data file collection using list extension with a generator expression and remove an extraneous blank line in frontend code.

Build:

  • Bump application version from 6.3 to 6.8 in setup.py.

Updated conditionals for readability and bumped a version to 6.8 in setup.py.
@ericbsd ericbsd requested review from a team as code owners January 14, 2026 01:18
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Refactors window lifecycle handling by replacing widget hiding with destruction in update-related flows, simplifies boolean conditionals, slightly cleans up helper logic, and bumps the application version and a small setup utility loop.

Sequence diagram for updated window lifecycle during update start

sequenceDiagram
    actor User
    participant FrontendWindow
    participant GtkWindow as GtkWindowInstance
    participant Data
    participant UpdateProcess

    User ->> FrontendWindow: click_start_update(widget)
    FrontendWindow ->> Data: set update_started = True
    FrontendWindow ->> UpdateProcess: InstallUpdate()
    Note over UpdateProcess: Update process runs
    FrontendWindow ->> GtkWindow: destroy()
    Note over GtkWindow: Window is destroyed instead of hidden
Loading

Sequence diagram for updated delete event behavior

sequenceDiagram
    actor User
    participant FrontendWindow
    participant GtkWindow as GtkWindowInstance
    participant Data
    participant UpdateCore

    User ->> FrontendWindow: delete_event(widget)
    FrontendWindow ->> Data: check close_session
    alt close_session is True
        FrontendWindow ->> UpdateCore: updating()
        alt updating is True
            FrontendWindow ->> UpdateCore: unlock_update_station()
        end
        FrontendWindow ->> GtkWindow: Gtk.main_quit()
    else close_session is False
        FrontendWindow ->> GtkWindow: destroy()
        FrontendWindow ->> Data: check update_started
        alt update_started is False
            FrontendWindow ->> Data: set stop_pkg_refreshing = False
            FrontendWindow ->> UpdateCore: updating()
            alt updating is True
                FrontendWindow ->> UpdateCore: unlock_update_station()
            end
        end
    end
Loading

Sequence diagram for updated notification click behavior

sequenceDiagram
    actor User
    participant Notification
    participant Data

    User ->> Notification: on_clicked(widget)
    Notification ->> Data: read major_upgrade_state
    alt major_upgrade
        Notification ->> Data: set major_upgrade = False
        Notification ->> Data: set do_not_upgrade = False
    else not major_upgrade
        Notification ->> Data: set major_upgrade = False
        Notification ->> Data: set do_not_upgrade = True
    end
    Notification ->> Notification: destroy()
    Note over Notification: Notification is destroyed instead of hidden
Loading

Class diagram for updated frontend and notification lifecycle methods

classDiagram
    class Data {
        <<static>> bool close_session
        <<static>> bool update_started
        <<static>> bool stop_pkg_refreshing
        <<static>> bool major_upgrade
        <<static>> bool do_not_upgrade
    }

    class FrontendWindow {
        GtkWindow window
        delete_event(widget: GtkWidget) void
        start_update(widget: GtkWidget) void
        if_backup(widget: GtkWidget) void
        read_output(progress: object) void
        stop_tread(start_window: object) void
    }

    class Notification {
        on_clicked(widget: GtkWidget) void
    }

    class UpdateCore {
        updating() bool
        unlock_update_station() void
        InstallUpdate() void
    }

    FrontendWindow --> Data : uses
    FrontendWindow --> UpdateCore : uses
    Notification --> Data : uses
    Notification --> FrontendWindow : lifecycle_related

    FrontendWindow ..> GtkWindow : destroys
    Notification ..> Notification : destroys_self
Loading

File-Level Changes

Change Details Files
Adjust window close and update-completion behavior to destroy windows instead of hiding them and simplify boolean checks.
  • Change delete_event logic to use direct boolean evaluation for Data.close_session and Data.update_started
  • On window close when not closing the whole session, destroy the window instead of hiding it and preserve unlock/unlock logic
  • In stop_tread, destroy the main window instead of hiding it after restarting the start window
update_station/frontend.py
Bump package version and slightly optimize data file collection in setup.
  • Update VERSION constant from 6.3 to 6.8
  • Replace manual file_list append loop with list.extend and a generator expression in data_file_list
setup.py
Adjust notification window behavior after click handling.
  • Keep click handler logic but (per diff intent) rely on destruction instead of hiding the notification widget at the end of on_clicked (verify actual call in final diff).
update_station/notification.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • After replacing hide() with destroy() on self.window, self.win, and the notification widget, double-check that no later code assumes these widgets still exist or reuses them; if they are accessed again you may want to add guards or recreate them instead of destroying.
  • In delete_event, both branches call unlock_update_station() when updating() is true; consider centralizing this into a single, post-branch call to avoid duplicated logic and keep the cleanup behavior consistent.
  • In data_file_list, root.replace(source_base, install_base) can behave unexpectedly if source_base appears multiple times in the path; using os.path.join(install_base, os.path.relpath(root, source_base)) would make the path transformation more robust.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- After replacing `hide()` with `destroy()` on `self.window`, `self.win`, and the notification widget, double-check that no later code assumes these widgets still exist or reuses them; if they are accessed again you may want to add guards or recreate them instead of destroying.
- In `delete_event`, both branches call `unlock_update_station()` when `updating()` is true; consider centralizing this into a single, post-branch call to avoid duplicated logic and keep the cleanup behavior consistent.
- In `data_file_list`, `root.replace(source_base, install_base)` can behave unexpectedly if `source_base` appears multiple times in the path; using `os.path.join(install_base, os.path.relpath(root, source_base))` would make the path transformation more robust.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ericbsd ericbsd merged commit 40e2979 into master Jan 14, 2026
2 checks passed
@ericbsd ericbsd deleted the fix-window-memory-leak branch January 14, 2026 01:20
@ericbsd ericbsd moved this from In Review to Done in Development Tracker Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant