Currently many tests fail (at least on FreeBSD) with ASan turned on. This is what happening:
- test_toolviewtoolbar creates an action, a ToolDocument and a View in the init() function.
- ToolViewAction registers itself as event filter for the created View.
- When cleanup is called, the controller gets deleted. This causes removal of its children (QObject::deleteChildren()), included the mentioned View.
- Somewhere later during destruction, some QEvent arrives and gets passed to ToolViewAction::eventFilter(). This function accesses ->widget() method of m_dock->view(), but that View is already deleted, which causes ASan error.
Note that adding removeEventFilter() to ToolViewAction::~ToolViewAction() doesn't solve the problem - the event arrival happens before ToolViewAction destruction. I take it, there is some ownage confusion, but I wasn't able to figure it out.
So, I just flipped the condition in the if statement and it happens that it is also false, so the second condition doesn't get executed anymore.
I'd be happy to fix this proper way, but need some clues on where to dig.