Skip to content

Stop threads and repositories outliving their owners, and reach the code that could not be reached - #249

Merged
JE-Chen merged 3 commits into
mainfrom
dev
Jul 26, 2026
Merged

Stop threads and repositories outliving their owners, and reach the code that could not be reached#249
JE-Chen merged 3 commits into
mainfrom
dev

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jul 26, 2026

Copy link
Copy Markdown
Member

What this is

A review pass over what went in with #248, and the fixes it turned up. Three
commits, all of them things the review found rather than new features.

Threads that outlived what they hang off

Qt aborts the process outright when a running QThread is destroyed, and the
message it prints is swallowed by pytest, so these show up as an unexplained
crash far from the cause.

  • The jedi completion thread was never waited for. Closing an editor stopped
    its lint, baseline and blame workers but not this one -- the editor's only
    thread without a manager looking after it.
  • The toolbar's git-branch scan was never waited for at all. It hangs off the
    main window, and scanning branches on a large or network-mounted repository is
    not quick, so still running at closing time is not unusual.
  • The git panel's own workers were not waited for either, and a network
    operation such as fetch takes a while.

Every raw QThread now carries a name, so if this ever happens again Qt's
message says which one it was. That is how the toolbar thread was identified:
the message named it as soon as the names were in place.

This also corrects something said while fixing an earlier crash. The toolbar was
cleared of blame then, and the lint thread was indeed the dominant cause -- but
the toolbar does have the same defect, hidden behind the louder one.

Repositories that were never closed

GitService never closed its Repo, and every open one keeps long-lived
git cat-file child processes. It surfaced as an unrelated test timing out
waiting for a thread to start: dozens of stray child processes make even that
slow. The service closes its repository, closes the previous one when opening
another, and the panel closes both when it goes away.

Code that existed but could not be reached

  • Document symbols were requested from the language server and parsed, but
    nothing connected the reply. The outline panel only ever parsed Python with
    ast, leaving every other language blank; it asks the server when ast finds
    nothing and nests what comes back by the depth the server reports.
  • Stash and conflict resolution had tests but no way in: GitService had no
    UI consumer at all, since the git panel talks to GitPython directly. The panel
    reaches them through the service now rather than growing a third copy of the
    same logic.
  • GitWorker was never instantiated anywhere. It is gone rather than left as
    a class that looks available but is not.

Translations that were defined but unused

The git panel's buttons and prompts were hard-coded English while the language
files carried translations for exactly those strings. They read from the
dictionary now, which puts eighteen unused keys back to work.

Verification

ruff check . clean. 1712 tests pass on 3.11 and on 3.10.

JE-Chen added 3 commits July 26, 2026 17:09
…he server

Reviewing what went in turned up three gaps.

The editor waited for its lint, baseline and blame workers on close but not for
the jedi completion thread, and the toolbar''s git-branch scan was never waited
for at all -- both abort the process outright if they outlive what they hang
off, and scanning branches on a large or network-mounted repository is not
quick. Both are waited for now, and the remaining unnamed threads carry names so
Qt''s abort message says which one.

Document symbols were requested from the language server and parsed, but nothing
connected the reply. The outline panel only ever parsed Python with ast, leaving
every other language blank, so it now asks the server when ast finds nothing and
nests what comes back by the depth the server reports.
GitService had no UI consumer at all -- the git panel talks to GitPython
directly -- so the stash and conflict work landed in a module nothing called.
The panel now reaches those through the service rather than growing a third
copy of the same logic, with buttons for stashing, popping and resolving.

Wiring them up surfaced a leak: an open Repo keeps long-lived git child
processes, and GitService never closed one. It showed as an unrelated test
timing out waiting for a thread to start -- dozens of stray child processes
make even that slow. The service closes its repository, closes the previous one
when opening another, and the panel closes both when it goes away, along with
waiting for its own background threads.
Reviewing the new code again turned up two things.

GitWorker was never instantiated anywhere: the panel has a worker of its own and
the service layer is called directly. It is gone rather than left as a class
that looks available but is not.

The panel''s buttons and prompts were hard-coded English, while the language
files have carried translations for exactly those strings all along -- the new
stash and conflict buttons had followed the same pattern. They read from the
dictionary now, which puts eighteen unused keys back to work and adds the ones
the new buttons and dialogs need.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 88 complexity · 0 duplication

Metric Results
Complexity 88
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sonarqubecloud

Copy link
Copy Markdown

@JE-Chen
JE-Chen merged commit 8e52adc into main Jul 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant