Skip to content

Commit

Permalink
fix race condition by waiting for the image before drawing on it
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Mar 31, 2021
1 parent 65d5083 commit a0bce56
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ function calculateImageScale() {
currentImage.attr('id', '');
newImage.attr('id', 'image');
gImageId = imageId;
let loadImages = preloadImages();

currentImage.replaceWith(newImage);
globals.image = newImage;
Expand All @@ -488,7 +487,6 @@ function calculateImageScale() {
// add previous image to cache
gImageCache[currentImage.data('imageid')] = currentImage;
}
await loadImages;
}

/**
Expand Down Expand Up @@ -798,7 +796,6 @@ function calculateImageScale() {
loading.removeClass('hidden');
$('#annotation_type_id').val(gAnnotationType);

let loadImage = displayImage(imageId);

$('.annotate_image_link').removeClass('active');
let link = $('#annotate_image_link_' + imageId);
Expand All @@ -812,6 +809,10 @@ function calculateImageScale() {
$('#delete-image-form').attr('action', DELETE_IMAGE_URL.replace('%s', imageId));

tool.clear();

await displayImage(imageId);
let loadImages = preloadImages();

if ($('#keep_selection').prop('checked') && restoreAnnotation) {
if (restoreAnnotation.vector === null) {
// not in image
Expand Down Expand Up @@ -843,7 +844,7 @@ function calculateImageScale() {
} catch {
console.log("Unable to load annotations for image" + imageId);
}
await loadImage;
await loadImages;
}

/**
Expand Down

0 comments on commit a0bce56

Please sign in to comment.