Fix #116680: Invalidate file import operators when unregister #116681

Closed
Guillermo Venegas wants to merge 1 commits from guishe:fix-op-fileselect into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 17 additions and 0 deletions

View File

@ -394,6 +394,23 @@ void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
/* don't run op->cancel because it needs the context,
* assume whoever unregisters the operator will cleanup */
handler->head.flag |= WM_HANDLER_DO_FREE;
/**
* Check if the operator has invoked the filesec window, and invalidate the pointer to
* the operator.
*/
if (handler->is_fileselect) {
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
ED_screen_areas_iter (win, screen, area) {
if (area->spacetype == SPACE_FILE) {
SpaceFile *sfile = static_cast<SpaceFile *>(area->spacedata.first);
if (sfile->op == handler->op) {
sfile->op = nullptr;
}
}
}
}
}
WM_operator_free(handler->op);
handler->op = nullptr;
}