FIX: Prevent TypeError: NoneType on model switching in token counter

This fixes the critical `TypeError: argument of type 'NoneType' is not iterable` that frequently occurs in the token counter when the main Stable Diffusion model is being unloaded or reloaded (e.g., during XYZ Plot or manual model switching).

The error happens because the `get_token_counter` function tries to access `sd_models.model_data.sd_model.cond_stage_model` when `sd_model` is momentarily `None`.

The fix adds a robust check for `sd_models.model_data.sd_model is None` at the start of the function, ensuring the token counter safely returns 0 instead of causing an ASGI application crash across all environments (A1111, Forge/reForge).
pull/366/head
ねおん 2025-11-10 02:49:34 +09:00 committed by GitHub
parent 0aa3c04de4
commit fea3070a40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions