Github user mike-jumper commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/143#discussion_r111638795
--- Diff: guacamole-common-js/src/main/webapp/modules/Client.js ---
@@ -151,39 +153,53 @@ Guacamole.Client = function(tunnel) {
'layers' : {}
};
- // Export each defined layer/buffer
+ var layersSnapshot = {};
+
+ // Make a copy of all current layers (protocol state)
for (var key in layers) {
+ layersSnapshot[key] = layers[key];
+ }
- var index = parseInt(key);
- var layer = layers[key];
- var canvas = layer.toCanvas();
+ // Populate layers once data is available (display state, requires
flush)
+ display.flush(function populateLayers() {
+
+ // Export each defined layer/buffer
+ for (var key in layersSnapshot) {
+
+ var index = parseInt(key);
+ var layer = layersSnapshot[key];
+ var canvas = layer.toCanvas();
+
+ // Store layer/buffer dimensions
+ var exportLayer = {
+ 'width' : layer.width,
+ 'height' : layer.height
+ };
+
+ // Store layer/buffer image data, if it can be generated
+ if (layer.width && layer.height)
+ exportLayer.url = canvas.toDataURL('image/png');
+
+ // Add layer properties if not a buffer nor the default
layer
+ if (index > 0) {
+ exportLayer.x = layer.x;
+ exportLayer.y = layer.y;
+ exportLayer.z = layer.z;
+ exportLayer.alpha = layer.alpha;
+ exportLayer.matrix = layer.matrix;
+ exportLayer.parent = getLayerIndex(layer.parent);
+ }
- // Store layer/buffer dimensions
- var exportLayer = {
- 'width' : layer.width,
- 'height' : layer.height
- };
+ // Store exported layer
+ state.layers[key] = exportLayer;
- // Store layer/buffer image data, if it can be generated
- if (layer.width && layer.height)
- exportLayer.url = canvas.toDataURL('image/png');
-
- // Add layer properties if not a buffer nor the default layer
- if (index > 0) {
- exportLayer.x = layer.x;
- exportLayer.y = layer.y;
- exportLayer.z = layer.z;
- exportLayer.alpha = layer.alpha;
- exportLayer.matrix = layer.matrix;
- exportLayer.parent = getLayerIndex(layer.parent);
}
- // Store exported layer
- state.layers[key] = exportLayer;
-
- }
+ // Invoke callback now that the state is ready
+ if (callback)
--- End diff --
Check removed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---