Files
test2/source/blender/blenkernel/intern/wm_runtime.cc
Hans Goudey 178eca9427 Refactor: Move various window manager runtime pointers out of DNA
All of these pointers were cleared on file read. It's clearer to just
move them to the runtime struct.

Pull Request: https://projects.blender.org/blender/blender/pulls/144729
2025-08-18 20:44:44 +02:00

75 lines
1.8 KiB
C++

/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
*/
#include "BKE_report.hh"
#include "BKE_undo_system.hh"
#include "BKE_wm_runtime.hh"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "WM_api.hh"
#include "WM_message.hh"
namespace blender::bke {
WindowManagerRuntime::WindowManagerRuntime()
{
BKE_reports_init(&this->reports, RPT_STORE);
}
WindowManagerRuntime::~WindowManagerRuntime()
{
BKE_reports_free(&this->reports);
BLI_freelistN(&this->notifier_queue);
if (this->notifier_queue_set) {
BLI_gset_free(this->notifier_queue_set, nullptr);
}
while (wmOperator *op = static_cast<wmOperator *>(BLI_pophead(&this->operators))) {
WM_operator_free(op);
}
BLI_freelistN(&this->paintcursors);
/* NOTE(@ideasman42): typically timers are associated with windows and timers will have been
* freed when the windows are removed. However timers can be created which don't have windows
* and in this case it's necessary to free them on exit, see: #109953. */
while (wmTimer *timer = static_cast<wmTimer *>(BLI_pophead(&this->timers))) {
WM_event_timer_free_data(timer);
MEM_freeN(timer);
}
while (wmKeyConfig *keyconf = static_cast<wmKeyConfig *>(BLI_pophead(&this->keyconfigs))) {
WM_keyconfig_free(keyconf);
}
WM_drag_free_list(&this->drags);
if (this->undo_stack) {
BKE_undosys_stack_destroy(this->undo_stack);
}
if (this->message_bus != nullptr) {
WM_msgbus_destroy(this->message_bus);
}
}
WindowRuntime::~WindowRuntime()
{
#ifdef WITH_INPUT_IME
BLI_assert(this->ime_data == nullptr);
#endif
/** The event_queue should be freed when the window is freed. */
BLI_assert(BLI_listbase_is_empty(&this->event_queue));
}
} // namespace blender::bke