cr.$dispose on painting error

Put repaint process in a "try catch" so cr.$dispose is always called.
This commit is contained in:
abakkk 2020-06-26 20:08:36 +02:00
parent 119c6725ef
commit e341b36d65
1 changed files with 13 additions and 4 deletions

17
draw.js
View File

@ -191,6 +191,18 @@ var DrawingArea = new Lang.Class({
this._stopElementGrabber();
},
vfunc_repaint: function() {
let cr = this.get_context();
try {
this._repaint(cr);
} catch(e) {
logError(e, "An error occured while painting");
}
cr.$dispose();
},
_redisplay: function() {
// force area to emit 'repaint'
this.queue_repaint();
@ -247,8 +259,7 @@ var DrawingArea = new Lang.Class({
this.gridColor = this.gridColor && this.gridColor.alpha ? this.gridColor : Clutter.Color.new(127, 127, 127, 255);
},
vfunc_repaint: function() {
let cr = this.get_context();
_repaint: function(cr) {
if (CAIRO_DEBUG_EXTENDS) {
cr.scale(0.5, 0.5);
cr.translate(this.monitor.width, this.monitor.height);
@ -304,8 +315,6 @@ var DrawingArea = new Lang.Class({
}
cr.restore();
}
cr.$dispose();
},
_onButtonPressed: function(actor, event) {