2014-10-23 09:38:14 UTC
The reason was because I used a dangling pointer. It did not occur to
me that the pointer could be dangling. I just assumed it would not be
(I've learned my lesson). The reason why it becomes dangling is
because I add code after a dispatch and thus the buffer view might
have been destroyed (e.g. from closing a buffer or closing a view).
My solution is to simply refresh the pointer (I can get it from
currentBufferView()). However, this got me thinking: shouldn't we set
the pointer to null every time we know that it was destroyed? What if
we don't use that pointer again (as was the case before my commit)?
Looking back, it is pretty obvious that the pointer could have become
dangling and I should have realized this potential problem.
I guess I have two questions:
(1) Are there any comments on my patch?
(2) Even if I did not want to add code to GuiView::dispatch, would it
have been a reasonable patch to _only_ refresh the pointer after the
dispatch, just in case someone wanted to add code to it eventually?