Skip to content

Don't immediately close window on Gtk 2/3 #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025

Conversation

novahahn
Copy link
Contributor

@novahahn novahahn commented Jul 9, 2025

OpenCV does not implement WND_PROP_VISIBLE when compiled with Gtk 2 or 3. Instead it always returns -1, which extract_otp_secrets interprets as the window having been closed.

See opencv/opencv#25346, which is marked as closed but actually still present in OpenCV 4.11.

OpenCV does not implement WND_PROP_VISIBLE when compiled with Gtk 2 or 3.
Instead it always returns -1, which extract_otp_secrets interprets as the
window having been closed.

See opencv/opencv#25346, which is marked as closed
but actually still present in OpenCV 4.11.
@@ -503,9 +510,6 @@ def cv2_handle_pressed_keys(qr_mode: QRMode, otps: Otps) -> Tuple[bool, QRMode]:
elif key == 32:
qr_mode = next_valid_qr_mode(qr_mode, zbar_available)
if verbose >= LogLevel.MORE_VERBOSE: print(f"QR reading mode: {qr_mode}")
if cv2.getWindowProperty(WINDOW_NAME, cv2.WND_PROP_VISIBLE) < 1:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just changing < 1 to == 0 here also fixes the issue except that the script crashes when the window is closed on Gtk.

@scito scito merged commit d04902e into scito:master Jul 11, 2025
10 checks passed
@scito
Copy link
Owner

scito commented Jul 11, 2025

Thanks for your contribution. I've tested the PR on my machine and it still worked. Soon, I'll publish a new release.

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.

2 participants