Page MenuHomePhabricator

WeakPointer: Exception on OnDeleteEvent when closing MITK workbench
Open, HighPublic


OS: Windows (none other OS tested yet)

When using the mitk::WeakPointer in the QmitkNodeSelectionButton (part of the org.mitk.gui.qt.common plugin). I get a an exception when I am closing the application as soon as I have called mitk::WeakPointer::Lock().

The exception is raised in WeakPointer::OnDeleteEvent()

if (m_DeleteEventCallback)

When it tries to call m_DeleteEventCallback.

If I switch the implementation to use a SmartPointer in QmitkNodeSelectionButton everything works fine. But I would like to just use a weak pointer. And maybe this problem also points to more fundamental flaw.

Event Timeline

floca created this task.May 11 2018, 4:23 PM

What is the function you set as DeleteEventCallback?

floca added a comment.May 14 2018, 2:23 PM

What is the function you set as DeleteEventCallback?

None. I haven't set one explicitly.

Okay, strange. std::function implements the bool() operator for the check. The only thing I could imagine is that the implementation your toolchain is using, doesn't provide the operator and evaluates to something else. What compiler are you using?

floca added a comment.EditedMay 14 2018, 3:41 PM

I use VS2017 (windows 10).

One can provoke the violation when

  1. selecting a node
  2. clearing the workspace
  3. closing the view (e.g. Data Storage Viewer Test)


  1. selecting a node
  2. closing the view (e.g. Data Storage Viewer Test)
  3. closing the application

The violation is sometimes not provoked if I do the following

  1. selecting a node
  2. closing the view
  3. clearing the workspace
  4. closing the application

(but I had one try, where it crashes at 3).

I think it is some kind of "racing condition" may due to the timing when Qt relay destructs the widgets that has a weak pointer as member.

kislinsk triaged this task as Normal priority.Nov 22 2018, 11:46 AM

Threading issue? Making WeakPointer thread-safe?

floca added a comment.Nov 22 2018, 1:35 PM

Threading issue? Making WeakPointer thread-safe?

That wouldn't contradict the racing condition assumption. Isn't the WeakPointer thread-safe already?

I interpret the section about application-level multithreading as "do it yourself in terms of event mechanisms and stuff". So this is still my first guess. We should at least update the WeakPointer documentation or think about if and how we could get it to work anyways.

floca raised the priority of this task from Normal to High.Feb 15 2020, 10:19 AM
floca added a project: Request for Discussion.

@kislinsk mentioned that he noticed some crashes lately when closing the workbench. We should see if they may orgininate from the problem documented in this tasks. And should discuss what the reasons for the problem could be and who to solve it.