fix(mining): disable the thread stepper while a benchmark runs
The thread grid is inert during a benchmark, but the -/+ buttons and the count field still took input: a click changed the shown and saved count while the benchmark owned the miner's (before the previous commit it also restarted xmrig at that count and spoiled the measurement). The buttons and the field are now disabled until the benchmark ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -143,6 +143,7 @@ void RenderMiningControls(App* app, const WalletState& state, const MiningInfo&
|
||||
auto applyThreads = [&](int tc) {
|
||||
tc = std::clamp(tc, 1, max_threads);
|
||||
if (tc == s_selected_threads) return;
|
||||
if (s_benchmark.active()) return; // the benchmark owns the thread count while it runs (as the grid)
|
||||
s_selected_threads = tc; // shown at once; the App applies it ~0.5 s after the last change
|
||||
app->selectMiningThreads(tc);
|
||||
};
|
||||
@@ -189,7 +190,7 @@ void RenderMiningControls(App* app, const WalletState& state, const MiningInfo&
|
||||
|
||||
// "-" button (disabled at 1 thread)
|
||||
if (rectStepBtn("##ThreadMinus", ICON_MD_REMOVE, sx, TR("mining_threads_minus_tooltip"),
|
||||
s_selected_threads <= 1))
|
||||
s_selected_threads <= 1 || s_benchmark.active()))
|
||||
applyThreads(s_selected_threads - 1);
|
||||
sx += sideW + g;
|
||||
|
||||
@@ -202,15 +203,18 @@ void RenderMiningControls(App* app, const WalletState& state, const MiningInfo&
|
||||
ImGui::SetCursorScreenPos(ImVec2(sx, sy));
|
||||
ImGui::SetNextItemWidth(fieldW);
|
||||
int tc = s_selected_threads;
|
||||
const bool benchLocked = s_benchmark.active(); // read-only while the benchmark runs (as -/+)
|
||||
ImGui::BeginDisabled(benchLocked);
|
||||
if (ImGui::InputInt("##ThreadCountInput", &tc, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue))
|
||||
applyThreads(tc);
|
||||
if (ImGui::IsItemHovered()) material::Tooltip("%s", TR("mining_threads_input_tooltip"));
|
||||
ImGui::EndDisabled();
|
||||
ImGui::PopStyleVar();
|
||||
sx += fieldW + g;
|
||||
|
||||
// "+" button (disabled at max_threads)
|
||||
if (rectStepBtn("##ThreadPlus", ICON_MD_ADD, sx, TR("mining_threads_plus_tooltip"),
|
||||
s_selected_threads >= max_threads))
|
||||
s_selected_threads >= max_threads || s_benchmark.active()))
|
||||
applyThreads(s_selected_threads + 1);
|
||||
|
||||
ImGui::SetCursorScreenPos(savedCur);
|
||||
|
||||
Reference in New Issue
Block a user