The connection flowgraph element previously kept a reference to the
cairo context passed to the draw function in order to be able to use
cairo's `in_stroke` function to determine if the mouse cursor was on the
path of the curved connection line. As it turns out, this is dangerous
because GTK is constantly destroying and creating new cairo contexts
and surfaces.
This avoids keeping a reference to the cairo context by initializing a
local cairo context with the connection class for the sole purpose of
storing the curved path and calculating `in_stroke`. The local context
and surface can be very basic because not much is needed for
`in_stroke`, and the context can persist and just have its path replaced
when it needs to be updated.
On Windows, resizing the GRC window (and particularly the flowgraph
canvas) to a larger size than its initial size would cause the
underlying cairo surface to be destroyed and a new one created. The
cairo context stored for the curved connection line had a reference to
that destroyed surface, and closing that context (upon replacing it with
a new one) would attempt decrement the reference count on the surface.
This would produce an assertion failure that crashed GRC stating
`Assertion failed: CAIRO_REFERENCE_COUNT_HAS_REFERENCE
(&surface->ref_count)`.
On macOS with the Quartz backend, a related crash and assertion error
would manifest when connecting blocks.
Signed-off-by: Ryan Volz <ryan.volz@gmail.com>
All of the removed `from __future__ import` were needed in older
versions of Python (mostly 2.5.x and below) but later became mandatory
in most versions of Python 3 hence are not necessary anymore.
More specifically, according to __future__.py[1]:
- unicode_literals is part of Python since versions 2.6.0 and 3.0.0;
- print_function is part of Python since versions 2.6.0 and 3.0.0;
- absolute_import is part of Python since versions 2.5.0 and 3.0.0;
- division is part of Python since versions 2.2.0 and 3.0.0;
Get rid of those unnecessary imports to slightly clean up the codebase.
[1] https://github.com/python/cpython/blob/master/Lib/__future__.py
Bus ports had not been added back in since the refactor of grc
Hopefully this fully enables busports though there are still some
issues with the gr-fec flowgraphs
Fixes#2277