Anki/qt/aqt/browser
Aristotelis 5b0f371791
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>
2025-04-22 21:22:40 +10:00
..
sidebar Use default flag name when flag is renamed to empty string (#3826) 2025-02-21 16:38:04 +07: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 Feat/grade now (#3840) 2025-03-15 17:30:40 +07:00
card_info.py Copy card debug info (#3801) 2025-02-16 16:06:12 +07: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-22 21:22:40 +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