On Thu, Apr 10, 2014 at 11:25 AM, Eric89GXL <notifications@github.com>wrote:

> In vispy/app/backends/_qt.py:
>
> >          self._vispy_canvas.events.paint(region=None)
> >
> >      def closeEvent(self, ev):
> >          if self._vispy_canvas is None:
> >              return
> >          self._vispy_canvas.events.close()
> > +        # Destroy if this is a toplevel widget
>
> @almarklein <https://github.com/almarklein> and I spent a long time
> trying to get qt to work in testing, and this was the only thing that
> really fixed it. It seems like having the old windows from previous tests
> not be destroyed, somehow they end up breaking later tests somehow. Not
> sure if it's because they get destroyed later and that affects Qt, or if
> they set their contexts as current briefly and that breaks something, but
> we could not find another reliable solution. If you're really curious, you
> can view the (quite long) Github and gitter conversations we had about it.
> It was a real pain to make go away...
>
Ah! What a mess. It sounds like the Canvas is not being deleted when the
test scope ends, probably because there is a reference cycle. Later on
(during some other test), the gc wakes up and deletes the Canvas, causing
the current test to fail. So if that's correct, then the proposed solution
actually fixes the problem _only_ for the tests, while leaving the real bug
in the wild. (The real problem is that the gc should never be permitted to
delete a context)

I suggest we merge this PR and I'll start a new one to dig in a bit more.
How can I reproduce the bug? The tests seem to run just fine on my machine
when I remove the call to destroy().