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() {
|
QmlWindowClass::~QmlWindowClass() {
|
||||||
if (_qmlWindow) {
|
close();
|
||||||
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::registerObject(const QString& name, QObject* object) {
|
void QmlWindowClass::registerObject(const QString& name, QObject* object) {
|
||||||
|
@ -331,14 +320,18 @@ void QmlWindowClass::setTitle(const QString& title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlWindowClass::close() {
|
void QmlWindowClass::close() {
|
||||||
DependencyManager::get<OffscreenUi>()->executeOnUiThread([this] {
|
if (_qmlWindow) {
|
||||||
if (_qmlWindow) {
|
if (_toolWindow) {
|
||||||
_qmlWindow->setProperty("destroyOnInvisible", true);
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
_qmlWindow->setProperty("visible", false);
|
auto toolWindow = offscreenUi->getToolWindow();
|
||||||
|
auto invokeResult = QMetaObject::invokeMethod(toolWindow, "removeTabForUrl", Qt::QueuedConnection,
|
||||||
|
Q_ARG(QVariant, _source));
|
||||||
|
Q_ASSERT(invokeResult);
|
||||||
|
} else {
|
||||||
_qmlWindow->deleteLater();
|
_qmlWindow->deleteLater();
|
||||||
_qmlWindow = nullptr;
|
|
||||||
}
|
}
|
||||||
});
|
_qmlWindow = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlWindowClass::hasClosed() {
|
void QmlWindowClass::hasClosed() {
|
||||||
|
|
Loading…
Reference in a new issue