From 64224d0937405117e3cf5ddc7fb6a08e48cbeea6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 2 Apr 2011 23:53:30 -0700 Subject: [PATCH] Fixed copyrect: although synchronization was properly established, draw jobs were not properly reserved in the destination layer, so draw operations would NOT block (synchronized on source only), resulting in draw race conditions. In a copy, the destination layer should block until the source layer is ready. --- .../src/main/resources/layer.js | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/guacamole-common-js/src/main/resources/layer.js b/guacamole-common-js/src/main/resources/layer.js index 7fcae1728..6921eb490 100644 --- a/guacamole-common-js/src/main/resources/layer.js +++ b/guacamole-common-js/src/main/resources/layer.js @@ -168,22 +168,30 @@ function Layer(width, height) { } display.copyRect = function(srcLayer, srcx, srcy, w, h, x, y) { - - function scheduleCopyRect() { - reserveJob(function() { - if (autosize != 0) fitRect(x, y, w, h); - displayContext.drawImage(srcLayer, srcx, srcy, w, h, x, y, w, h); - }); + + function doCopyRect() { + if (autosize != 0) fitRect(x, y, w, h); + displayContext.drawImage(srcLayer, srcx, srcy, w, h, x, y, w, h); } // If we ARE the source layer, no need to sync. // Syncing would result in deadlock. if (display === srcLayer) - scheduleCopyRect(); + reserveJob(doCopyRect); // Otherwise synchronize copy operation with source layer - else - srcLayer.sync(scheduleCopyRect); + else { + var update = reserveJob(null); + srcLayer.sync(function() { + + update.setHandler(doCopyRect); + + // As this update originally had no handler and may have blocked + // other updates, handle any blocked updates. + handlePendingUpdates(); + + }); + } };