Merge pull request #889 from glacambre/fix_commandline_on_svgs

Fix infinite recursion on SVG
This commit is contained in:
Oliver Blanthorn 2018-08-02 08:02:26 +01:00 committed by GitHub
commit 9597f2facb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,7 +61,10 @@ export function show() {
cmdline_iframe.contentWindow.document.body.offsetHeight + "px" cmdline_iframe.contentWindow.document.body.offsetHeight + "px"
cmdline_iframe.setAttribute("style", `height: ${height} !important;`) cmdline_iframe.setAttribute("style", `height: ${height} !important;`)
} catch (e) { } catch (e) {
cmdline_logger.error(e) // Note: We can't use cmdline_logger.error because it will try to log
// the error in the commandline, which we can't show!
// cmdline_logger.error(e)
console.error(e)
} }
} }
@ -70,6 +73,9 @@ export function hide() {
cmdline_iframe.classList.add("hidden") cmdline_iframe.classList.add("hidden")
cmdline_iframe.setAttribute("style", "height: 0px !important;") cmdline_iframe.setAttribute("style", "height: 0px !important;")
} catch (e) { } catch (e) {
// Using cmdline_logger here is OK because cmdline_logger won't try to
// call hide(), thus we avoid the recursion that happens for show() and
// focus()
cmdline_logger.error(e) cmdline_logger.error(e)
} }
} }
@ -78,7 +84,11 @@ export function focus() {
try { try {
cmdline_iframe.focus() cmdline_iframe.focus()
} catch (e) { } catch (e) {
cmdline_logger.error(e) // Note: We can't use cmdline_logger.error because it will try to log
// the error in the commandline, which will need to focus() it again,
// which will throw again...
// cmdline_logger.error(e)
console.error(e)
} }
} }
@ -86,6 +96,7 @@ export function blur() {
try { try {
cmdline_iframe.blur() cmdline_iframe.blur()
} catch (e) { } catch (e) {
// Same as with hide(), it's ok to use cmdline_logger here
cmdline_logger.error(e) cmdline_logger.error(e)
} }
} }