Skip to content

Instantly share code, notes, and snippets.

@poptosic
Last active October 27, 2015 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poptosic/5ef2621aa06c1bee62ef to your computer and use it in GitHub Desktop.
Save poptosic/5ef2621aa06c1bee62ef to your computer and use it in GitHub Desktop.
This gist demonstrates a bug in PyQt 5.5.1 (possibly 5.5.0 too) on Windows where explicitly destroying a dynamically created WebEngineView leads to a stack overflow crash on shutdown.
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtQuick import QQuickView
from PyQt5.QtWidgets import QApplication
from PyQt5 import QtWebEngineWidgets
if __name__ == "__main__":
application = QApplication(sys.argv)
view = QQuickView()
view.setSource(QUrl.fromLocalFile('WebEngineTest.qml'))
view.show()
application.exec_()
import QtQuick 2.5
Rectangle {
width: 800
height: 600
color: "#eee"
property var obj
Text {
text: "Load"
anchors.left: parent.left
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
height: 100
width: 100
MouseArea {
anchors.fill: parent
onClicked: {
console.log('Creating webengine')
var component = Qt.createComponent('WebView.qml')
if (component.status === Component.Ready) {
obj = component.createObject(root);
console.log(obj);
}
}
}
}
Text {
text: "Unload"
anchors.top: parent.top
anchors.right: parent.right
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
height: 100
width: 100
MouseArea {
anchors.fill: parent
onClicked: {
if (obj) {
console.log('destroying')
obj.destroy()
}
}
}
}
Rectangle {
id: root
anchors.fill: parent
anchors.topMargin: 100
}
}
import QtWebEngine 1.1
WebEngineView {
anchors.fill: parent
url: "https://www.google.com"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment