mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 21:35:04 +02:00
Make QML based tool-windows close properly
This commit is contained in:
parent
5adf9adb0e
commit
2c26b32341
1 changed files with 11 additions and 18 deletions
|
@ -220,18 +220,7 @@ QmlWindowClass::QmlWindowClass(QObject* qmlWindow)
|
|||
}
|
||||
|
||||
QmlWindowClass::~QmlWindowClass() {
|
||||
if (_qmlWindow) {
|
||||
if (_toolWindow) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto toolWindow = offscreenUi->getToolWindow();
|
||||
auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection,
|
||||
Q_ARG(QVariant, _source));
|
||||
Q_ASSERT(invokeResult);
|
||||
} else {
|
||||
_qmlWindow->deleteLater();
|
||||
}
|
||||
_qmlWindow = nullptr;
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
void QmlWindowClass::registerObject(const QString& name, QObject* object) {
|
||||
|
@ -331,14 +320,18 @@ void QmlWindowClass::setTitle(const QString& title) {
|
|||
}
|
||||
|
||||
void QmlWindowClass::close() {
|
||||
DependencyManager::get<OffscreenUi>()->executeOnUiThread([this] {
|
||||
if (_qmlWindow) {
|
||||
_qmlWindow->setProperty("destroyOnInvisible", true);
|
||||
_qmlWindow->setProperty("visible", false);
|
||||
if (_toolWindow) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto toolWindow = offscreenUi->getToolWindow();
|
||||
auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection,
|
||||
Q_ARG(QVariant, _source));
|
||||
Q_ASSERT(invokeResult);
|
||||
} else {
|
||||
_qmlWindow->deleteLater();
|
||||
}
|
||||
_qmlWindow = nullptr;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void QmlWindowClass::hasClosed() {
|
||||
|
|
Loading…
Reference in a new issue