Guard against empty source history slice output

incremental_update_paths
Tyler Goodlet 2022-06-01 12:14:15 -04:00
parent 064d185395
commit b71e8c5e6d
1 changed files with 13 additions and 3 deletions

View File

@ -256,7 +256,8 @@ def render_baritems(
reset: bool, reset: bool,
) -> None: ) -> None:
lasts = src_data[-2:] lasts = src_data[-2:]
x, y = lasts['index'], lasts['close'] x = lasts['index']
y = lasts['close']
# draw the "current" step graphic segment so it # draw the "current" step graphic segment so it
# lines up with the "middle" of the current # lines up with the "middle" of the current
@ -717,7 +718,7 @@ class Flow(msgspec.Struct): # , frozen=True):
# - determine downsampling ops if needed # - determine downsampling ops if needed
# - (incrementally) update ``QPainterPath`` # - (incrementally) update ``QPainterPath``
path, data, reset = r.render( out = r.render(
read, read,
array_key, array_key,
profiler, profiler,
@ -738,6 +739,12 @@ class Flow(msgspec.Struct): # , frozen=True):
**rkwargs, **rkwargs,
) )
if not out:
log.warning(f'{self.name} failed to render!?')
return graphics
path, data, reset = out
# XXX: SUPER UGGGHHH... without this we get stale cache # XXX: SUPER UGGGHHH... without this we get stale cache
# graphics that don't update until you downsampler again.. # graphics that don't update until you downsampler again..
if reset: if reset:
@ -974,7 +981,7 @@ class Renderer(msgspec.Struct):
# the target display(s) on the sys. # the target display(s) on the sys.
# if no_path_yet: # if no_path_yet:
# graphics.path.reserve(int(500e3)) # graphics.path.reserve(int(500e3))
path=path, # path re-use / reserving # path=path, # path re-use / reserving
) )
# avoid mem allocs if possible # avoid mem allocs if possible
@ -1113,6 +1120,9 @@ class Renderer(msgspec.Struct):
# xy-path data transform: convert source data to a format # xy-path data transform: convert source data to a format
# able to be passed to a `QPainterPath` rendering routine. # able to be passed to a `QPainterPath` rendering routine.
if not len(hist):
return
x_out, y_out, connect = self.format_xy( x_out, y_out, connect = self.format_xy(
self, self,
# TODO: hist here should be the pre-sliced # TODO: hist here should be the pre-sliced