From 23f3399facef07d4651d26ccb3c6494ce0cf0978 Mon Sep 17 00:00:00 2001 From: JavaZeroo <71128095+JavaZeroo@users.noreply.github.com> Date: Fri, 30 Oct 2026 07:58:24 +0800 Subject: [PATCH] test(shell): clear the last error before clipboard owner cleanup calls refs #85 DestroyWindow does not reliably set the last error, so a failure record could inherit the previous call code; both cleanup calls now clear it first. --- experiments/shell/clipboard_scenario_state.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/experiments/shell/clipboard_scenario_state.hpp b/experiments/shell/clipboard_scenario_state.hpp index c1fc2e20..daf6bc64 100644 --- a/experiments/shell/clipboard_scenario_state.hpp +++ b/experiments/shell/clipboard_scenario_state.hpp @@ -217,10 +217,14 @@ class ClipboardScenarioOwner { if(!error_) record_failure(step_.load(),GetLastError()); if(opened) { step("CloseClipboard-cleanup"); + SetLastError(0); if(!CloseClipboard()) record_failure("CloseClipboard-cleanup",GetLastError()); } if(window_ && IsWindow(window_)) { step("DestroyWindow-cleanup"); + // DestroyWindow does not reliably set the last error; clear it + // so a failure here cannot inherit the previous call's code. + SetLastError(0); if(!DestroyWindow(window_)) record_failure("DestroyWindow-cleanup",GetLastError()); } SetEvent(ready_.get()); SetEvent(released_.get());