Skip to content

fix(kad): refresh status bar after StopKad() - #133

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/stopkad-refresh-status
Jun 12, 2026
Merged

fix(kad): refresh status bar after StopKad()#133
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/stopkad-refresh-status

Conversation

@got3nks

@got3nks got3nks commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Closes #131. The "Disconnect Kad" button in KadDlg stopped Kademlia but left the status-bar Kad indicator stuck on "Connected to Kad" until the next periodic refresh, as reported with screenshots.

Root cause

CamuleApp::StopKad() at amule.cpp:2299 called Kademlia::CKademlia::Stop() but never ShowConnectionState(). The symmetric BootstrapKad() path at amule.cpp:2312 already calls ShowConnectionState() after Start() — the asymmetry was the bug.

Fix

Add the matching ShowConnectionState() call after Stop() so the status-bar indicator refreshes immediately (ShowConnectionState is a local UI-side refresh — it computes the connection bitmask and calls Notify_ShowConnState to update the main window; no EC traffic).

Scope

Visible to users via KadDlg.cpp:206 (the "Disconnect Kad" button) — that path calls theApp->StopKad() directly with no follow-up refresh.

The EC handlers in ExternalConn.cpp (cases around lines 2267, 2274, 2294, 2328, 2345) already call ShowConnectionState() themselves after stopping Kad, so they were not affected. The internal amule.cpp:1442 (lost-connection in the main timer loop) and amule.cpp:1696 (shutdown) paths are also unaffected — the surrounding code in those frames already refreshes.

Putting the call inside StopKad() means future callers don't have to remember to refresh.

Test plan

  • macOS arm64 build clean.
  • CI build matrix.
  • Manual: launch amule, ensure Kad shows "Connected", click "Disconnect Kad" in the Kad dialog, status bar should immediately flip to "Disconnected".

CamuleApp::StopKad() stopped Kademlia but never called
ShowConnectionState() afterwards, so the status-bar Kad indicator
kept showing "Connected to Kad" until the next periodic refresh in
the main timer loop.

The symmetric BootstrapKad() path at amule.cpp:2312 already calls
ShowConnectionState() after Start(); add the matching call after
Stop() so the indicator updates immediately.

Most visible impact is the "Disconnect Kad" button in KadDlg —
KadDlg::OnBnClickedDisconnectKad calls theApp->StopKad() directly,
so the user clicks the button and sees no UI change.

Closes amule-project#131.
@got3nks
got3nks merged commit 9134867 into amule-org:master Jun 12, 2026
10 checks passed
@got3nks
got3nks deleted the fix/stopkad-refresh-status branch June 12, 2026 18:44
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.

The button "Disconnect Kad" doesn't change the State of the Kad network in the status bar

1 participant