diff --git a/source/import/importer.js b/source/import/importer.js
index b6647a7..0906e2f 100644
--- a/source/import/importer.js
+++ b/source/import/importer.js
@@ -179,6 +179,21 @@ OV.FileList = class
}
};
+OV.RevokeModelUrls = function (model)
+{
+ if (model === null) {
+ return;
+ }
+ for (let i = 0; i < model.MaterialCount (); i++) {
+ let material = model.GetMaterial (i);
+ material.EnumerateTextureMaps (function (texture) {
+ if (texture.url !== null) {
+ OV.RevokeObjectUrl (texture.url);
+ }
+ });
+ }
+}
+
OV.ImportErrorCode =
{
NoImportableFile : 1,
@@ -280,21 +295,6 @@ OV.Importer = class
callbacks.success (result);
}
- RevokeReferences (model)
- {
- if (model === null) {
- return;
- }
- for (let i = 0; i < model.MaterialCount (); i++) {
- let material = model.GetMaterial (i);
- material.EnumerateTextureMaps (function (texture) {
- if (texture.url !== null) {
- OV.RevokeObjectUrl (texture.url);
- }
- });
- }
- }
-
LoadFiles (fileList, fileSource, onReady)
{
let newFileList = new OV.FileList (this.importers);
diff --git a/website/o3dv/dialogs.js b/website/o3dv/dialogs.js
index 935d8fd..336b05f 100644
--- a/website/o3dv/dialogs.js
+++ b/website/o3dv/dialogs.js
@@ -65,6 +65,11 @@ OV.ButtonDialog = class
return dialogContentDiv;
}
+ SetCloseHandler (closeHandler)
+ {
+ this.modal.SetCloseHandler (closeHandler);
+ }
+
Show ()
{
this.modal.Open ();
@@ -241,6 +246,7 @@ OV.ShowExportDialog = function (model)
let fileListSection = $('
').addClass ('ov_dialog_section').appendTo (contentDiv);
let fileList = $('
').addClass ('ov_dialog_file_list').addClass ('ov_thin_scrollbar').appendTo (fileListSection);
+ let createdUrls = [];
formatSelect.change (function () {
fileList.empty ();
let selectedIndex = formatSelect.prop ('selectedIndex');
@@ -260,8 +266,8 @@ OV.ShowExportDialog = function (model)
let file = files[i];
let url = file.GetUrl ();
if (url === null) {
- // TODO: revoke on close
url = OV.CreateObjectUrl (file.GetContent ());
+ createdUrls.push (url);
}
let fileLink = $('
').addClass ('ov_dialog_file_link').appendTo (fileList);
fileLink.attr ('href', url);
@@ -274,6 +280,11 @@ OV.ShowExportDialog = function (model)
});
});
+ dialog.SetCloseHandler (function () {
+ for (let i = 0; i < createdUrls.length; i++) {
+ OV.RevokeObjectUrl (createdUrls[i]);
+ }
+ });
dialog.Show ();
return dialog;
};
diff --git a/website/o3dv/modal.js b/website/o3dv/modal.js
index 048232b..f1b53e1 100644
--- a/website/o3dv/modal.js
+++ b/website/o3dv/modal.js
@@ -6,6 +6,7 @@ OV.Modal = class
this.overlayDiv = null;
this.resizeHandler = null;
this.customResizeHandler = null;
+ this.closeHandler = null;
this.isOpen = false;
this.closeable = true;
}
@@ -25,6 +26,11 @@ OV.Modal = class
this.customResizeHandler = customResizeHandler;
}
+ SetCloseHandler (closeHandler)
+ {
+ this.closeHandler = closeHandler;
+ }
+
Open ()
{
let windowObj = $(window);
@@ -54,6 +60,9 @@ OV.Modal = class
let windowObj = $(window);
windowObj.unbind ('resize', this.resizeHandler);
+ if (this.closeHandler !== null) {
+ this.closeHandler ();
+ }
this.modalDiv.remove ();
this.overlayDiv.remove ();
diff --git a/website/o3dv/website.js b/website/o3dv/website.js
index 74afeac..38f8462 100644
--- a/website/o3dv/website.js
+++ b/website/o3dv/website.js
@@ -72,8 +72,7 @@ OV.Website = class
this.dialog = null;
}
if (this.model !== null) {
- let importer = this.modelLoader.GetImporter ();
- importer.RevokeReferences (this.model);
+ OV.RevokeModelUrls (this.model);
}
this.model = null;
this.parameters.introDiv.hide ();