* Check the soft limit of deletable (non vital, non sticky) windows. */
| 3035 | * Check the soft limit of deletable (non vital, non sticky) windows. |
| 3036 | */ |
| 3037 | static void CheckSoftLimit() |
| 3038 | { |
| 3039 | if (_settings_client.gui.window_soft_limit == 0) return; |
| 3040 | |
| 3041 | for (;;) { |
| 3042 | uint deletable_count = 0; |
| 3043 | Window *last_deletable = nullptr; |
| 3044 | for (Window *w : Window::IterateFromFront()) { |
| 3045 | if (w->window_class == WC_MAIN_WINDOW || IsVitalWindow(w) || w->flags.Test(WindowFlag::Sticky)) continue; |
| 3046 | |
| 3047 | last_deletable = w; |
| 3048 | deletable_count++; |
| 3049 | } |
| 3050 | |
| 3051 | /* We've not reached the soft limit yet. */ |
| 3052 | if (deletable_count <= _settings_client.gui.window_soft_limit) break; |
| 3053 | |
| 3054 | assert(last_deletable != nullptr); |
| 3055 | last_deletable->Close(); |
| 3056 | } |
| 3057 | } |
| 3058 | |
| 3059 | /** |
| 3060 | * Regular call from the global game loop |
no test coverage detected