From 25fd42afead495d5b065486b8f92d62f41ed9b60 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 15 Feb 2011 18:46:02 -0800 Subject: [PATCH] Fixed deadlock in layer --- guacamole-common-js/src/main/resources/layer.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/guacamole-common-js/src/main/resources/layer.js b/guacamole-common-js/src/main/resources/layer.js index 4c29726a2..b4f3203e2 100644 --- a/guacamole-common-js/src/main/resources/layer.js +++ b/guacamole-common-js/src/main/resources/layer.js @@ -150,14 +150,22 @@ function Layer(width, height) { display.copyRect = function(srcLayer, srcx, srcy, w, h, x, y) { var updateId = currentUpdate++; - - // Synchronize copy operation with source layer - srcLayer.sync(function() { + + function scheduleCopyRect() { setUpdate(updateId, function() { 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(); + + // Otherwise synchronize copy operation with source layer + else + srcLayer.sync(scheduleCopyRect); };