Skip to content

Commit

Permalink
OPDS: debounce removal of widgets when going to prev/next item in dialog
Browse files Browse the repository at this point in the history
Fixes segfault in older environments (tested with Ubuntu 18.04)
  • Loading branch information
johnfactotum committed Jul 2, 2020
1 parent 4587e97 commit 9b51695
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

const { GObject, Gtk, Gio, Gdk, GdkPixbuf, cairo } = imports.gi
const {
setTimeout,
debounce,
scalePixbuf, makeLinksButton, getLanguageDisplayName, formatDate, markupEscape,
hslToRgb, colorFromString, isLight,
makeList
Expand Down Expand Up @@ -550,22 +550,27 @@ var PropertiesWindow = GObject.registerClass({
box.pack_start(this._stack, true, true, 0)

this.updateProperties(metadata, cover)

this._debouncedRemoveInvisible = debounce(
this._removeInvisible.bind(this),
this._stack.transition_duration + 100)
}
setVisible(name, isPrev) {
_removeInvisible() {
const stack = this._stack
const visible = stack.visible_child
const children = stack.get_children()
children
.filter(x => x !== visible)
.forEach(x => x.destroy())
}
setVisible(name, isPrev) {
const transition = isPrev
? Gtk.StackTransitionType.SLIDE_RIGHT
: Gtk.StackTransitionType.SLIDE_LEFT
this._stack.set_visible_child_full(name, transition)

// remove other children after the transition is completed
const duration = stack.transition_duration
setTimeout(() => {
const children = stack.get_children()
children
.filter(x => x !== stack.visible_child)
.forEach(x => stack.remove(x))
}, duration)
this._debouncedRemoveInvisible()
}
updateProperties(metadata, cover) {
this._scrolled = new Gtk.ScrolledWindow({
Expand Down

0 comments on commit 9b51695

Please sign in to comment.