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 =
|
OV.ImportErrorCode =
|
||||||
{
|
{
|
||||||
NoImportableFile : 1,
|
NoImportableFile : 1,
|
||||||
@ -280,21 +295,6 @@ OV.Importer = class
|
|||||||
callbacks.success (result);
|
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)
|
LoadFiles (fileList, fileSource, onReady)
|
||||||
{
|
{
|
||||||
let newFileList = new OV.FileList (this.importers);
|
let newFileList = new OV.FileList (this.importers);
|
||||||
|
|||||||
@ -65,6 +65,11 @@ OV.ButtonDialog = class
|
|||||||
return dialogContentDiv;
|
return dialogContentDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCloseHandler (closeHandler)
|
||||||
|
{
|
||||||
|
this.modal.SetCloseHandler (closeHandler);
|
||||||
|
}
|
||||||
|
|
||||||
Show ()
|
Show ()
|
||||||
{
|
{
|
||||||
this.modal.Open ();
|
this.modal.Open ();
|
||||||
@ -241,6 +246,7 @@ OV.ShowExportDialog = function (model)
|
|||||||
let fileListSection = $('<div>').addClass ('ov_dialog_section').appendTo (contentDiv);
|
let fileListSection = $('<div>').addClass ('ov_dialog_section').appendTo (contentDiv);
|
||||||
let fileList = $('<div>').addClass ('ov_dialog_file_list').addClass ('ov_thin_scrollbar').appendTo (fileListSection);
|
let fileList = $('<div>').addClass ('ov_dialog_file_list').addClass ('ov_thin_scrollbar').appendTo (fileListSection);
|
||||||
|
|
||||||
|
let createdUrls = [];
|
||||||
formatSelect.change (function () {
|
formatSelect.change (function () {
|
||||||
fileList.empty ();
|
fileList.empty ();
|
||||||
let selectedIndex = formatSelect.prop ('selectedIndex');
|
let selectedIndex = formatSelect.prop ('selectedIndex');
|
||||||
@ -260,8 +266,8 @@ OV.ShowExportDialog = function (model)
|
|||||||
let file = files[i];
|
let file = files[i];
|
||||||
let url = file.GetUrl ();
|
let url = file.GetUrl ();
|
||||||
if (url === null) {
|
if (url === null) {
|
||||||
// TODO: revoke on close
|
|
||||||
url = OV.CreateObjectUrl (file.GetContent ());
|
url = OV.CreateObjectUrl (file.GetContent ());
|
||||||
|
createdUrls.push (url);
|
||||||
}
|
}
|
||||||
let fileLink = $('<a>').addClass ('ov_dialog_file_link').appendTo (fileList);
|
let fileLink = $('<a>').addClass ('ov_dialog_file_link').appendTo (fileList);
|
||||||
fileLink.attr ('href', url);
|
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 ();
|
dialog.Show ();
|
||||||
return dialog;
|
return dialog;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,6 +6,7 @@ OV.Modal = class
|
|||||||
this.overlayDiv = null;
|
this.overlayDiv = null;
|
||||||
this.resizeHandler = null;
|
this.resizeHandler = null;
|
||||||
this.customResizeHandler = null;
|
this.customResizeHandler = null;
|
||||||
|
this.closeHandler = null;
|
||||||
this.isOpen = false;
|
this.isOpen = false;
|
||||||
this.closeable = true;
|
this.closeable = true;
|
||||||
}
|
}
|
||||||
@ -25,6 +26,11 @@ OV.Modal = class
|
|||||||
this.customResizeHandler = customResizeHandler;
|
this.customResizeHandler = customResizeHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetCloseHandler (closeHandler)
|
||||||
|
{
|
||||||
|
this.closeHandler = closeHandler;
|
||||||
|
}
|
||||||
|
|
||||||
Open ()
|
Open ()
|
||||||
{
|
{
|
||||||
let windowObj = $(window);
|
let windowObj = $(window);
|
||||||
@ -54,6 +60,9 @@ OV.Modal = class
|
|||||||
|
|
||||||
let windowObj = $(window);
|
let windowObj = $(window);
|
||||||
windowObj.unbind ('resize', this.resizeHandler);
|
windowObj.unbind ('resize', this.resizeHandler);
|
||||||
|
if (this.closeHandler !== null) {
|
||||||
|
this.closeHandler ();
|
||||||
|
}
|
||||||
|
|
||||||
this.modalDiv.remove ();
|
this.modalDiv.remove ();
|
||||||
this.overlayDiv.remove ();
|
this.overlayDiv.remove ();
|
||||||
|
|||||||
@ -72,8 +72,7 @@ OV.Website = class
|
|||||||
this.dialog = null;
|
this.dialog = null;
|
||||||
}
|
}
|
||||||
if (this.model !== null) {
|
if (this.model !== null) {
|
||||||
let importer = this.modelLoader.GetImporter ();
|
OV.RevokeModelUrls (this.model);
|
||||||
importer.RevokeReferences (this.model);
|
|
||||||
}
|
}
|
||||||
this.model = null;
|
this.model = null;
|
||||||
this.parameters.introDiv.hide ();
|
this.parameters.introDiv.hide ();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user