Created
April 23, 2013 16:44
-
-
Save robertknight/5445289 to your computer and use it in GitHub Desktop.
Workaround for https://bugs.webkit.org/show_bug.cgi?id=75984 - adds a wrapper around QtObject.method.connect() which registers the method in an array and disconnects the method when the document is unloaded.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
// wrappers around QtObject.methodName.connect() | |
// workaround for https://bugs.webkit.org/show_bug.cgi?id=75984 | |
window.qtSignals = []; | |
// connect a Qt signal to a JS function and register it for disconnection | |
// when the document is unloaded | |
function connectQtSignal(signal, func) { | |
var conn = {signal : signal, receiver : func}; | |
window.qtSignals.push(conn); | |
signal.connect(func); | |
} | |
window.addEventListener('unload', function() { | |
window.qtSignals.forEach(function(connection) { | |
connection.signal.disconnect(connection.receiver); | |
}); | |
window.qtSignals = []; | |
}); | |
window.addEventListener('load', function() { | |
connectQtSignal(myObject.aSignal, function() { | |
console.log('signal emitted'); | |
}); | |
}); | |
</script> | |
<div style="width:300px;height:300px;">Test Content</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment