Anki/qt/aqt/browser
Aristotelis e9dfb7a13d Fix AnkiWebPage not being initialized for default web view kinds (e.g. in add-ons) (#3933)
* add AnkiWebView subclasses for stats, empty cards and find dupes ui

* update ui files to use subclassed webviews instead

* remove superfluous calls to AnkiWebView.set_kind

* Avoid set_kind() race condition in legacy stats webview

Replacing the web view is a hacky workaround, but likely a reasonable compromise for a legacy view that we do not want to maintain a separate Qt form for.

* Slightly refactor AnkiWebView subclass creation and tweak inline comment

+ Extend create_ankiwebview_subclass() with the ability to set any
  init time AnkiWebView argument
+ Introduce some nice-to-haves in terms of static type checking support
  and IDE autocompletion
+ Mark helper function as private to discourage add-on use

* Drop `AnkiWebView.set_kind` completely

There no longer is an Anki-internal use case for changing the web view kind after initializing a web view, and add-ons almost certainly do not have any use for it either.

Given that setting the kind after web view construction can lead  to known race conditions with `domDone` signals, we should remove this method to discourage uses like this in both Anki code and add-on consumers.

There currenty only seems to be one add-on calling `set_kind()`, so this seem like a justifiable API change.

---------

Co-authored-by: llama <100429699+iamllama@users.noreply.github.com>
(cherry picked from commit 5b0f371791)
2025-04-23 16:23:02 +10:00
..
sidebar Enable strict_optional in aqt/. and aqt/browser (#3486) 2024-10-11 23:12:48 +10:00
table Enable strict_optional in aqt/. and aqt/browser (#3486) 2024-10-11 23:12:48 +10:00
__init__.py new change notetype implementation for the frontend 2021-06-10 22:19:24 +10:00
browser.py Enable strict_optional in aqt/. and aqt/browser (#3486) 2024-10-11 23:12:48 +10:00
card_info.py Replace use of window.postMessage in card info (#3646) 2024-12-18 11:32:07 +03:00
find_and_replace.py Enable strict_optional in aqt/. and aqt/browser (#3486) 2024-10-11 23:12:48 +10:00
find_duplicates.py Fix AnkiWebPage not being initialized for default web view kinds (e.g. in add-ons) (#3933) 2025-04-23 16:23:02 +10:00
layout.py Enable strict_optional in aqt/. and aqt/browser (#3486) 2024-10-11 23:12:48 +10:00
previewer.py Enable strict_optional in aqt/. and aqt/browser (#3486) 2024-10-11 23:12:48 +10:00