Revoke created object urls for export.
This commit is contained in:
parent
0c394f9aa8
commit
90f8a07857
@ -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);
|
||||
|
||||
@ -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 = $('<div>').addClass ('ov_dialog_section').appendTo (contentDiv);
|
||||
let fileList = $('<div>').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 = $('<a>').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;
|
||||
};
|
||||
|
||||
@ -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 ();
|
||||
|
||||
@ -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 ();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user