-
Notifications
You must be signed in to change notification settings - Fork 32
fix: normal termination for Treeland #731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2fd327
e96b376
ae14034
a00d2e0
f6b8846
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| [Shortcut] | ||
| Shortcut=Meta+F12 | ||
| Shortcut=Meta+Shift+Q | ||
| Type="Action" | ||
|
|
||
| [Type.Action] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,17 @@ WBufferRenderer::WBufferRenderer(QQuickItem *parent) | |
| , m_cacheBuffer(true) | ||
| , m_hideSource(false) | ||
| { | ||
|
|
||
| // ensure graphical resources are released before scene graph is invalidated | ||
| // since WBufferRenderer's ItemHasContent bit is unset | ||
| // the invalidateSceneGraph slot will not be called through QQuickWindowPrivate::cleanupNodesOnShutdown | ||
| QMetaObject::Connection windowConn; | ||
| if (window()) | ||
| windowConn = connect(window(), &QQuickWindow::sceneGraphInvalidated, this, &WBufferRenderer::invalidateSceneGraph); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 应该不需要,这个slot会在QQuickWindowPrivate::cleanupNodesOnShutdown种被主动调用。
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 需要的,它那个自动调用并不稳定
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 那应该解决不稳定的问题,不稳定时指什么? |
||
| connect(this, &QQuickItem::windowChanged, this, [this, windowConn](auto *window) mutable { | ||
| disconnect(windowConn); | ||
| if (window) | ||
| windowConn = connect(window, &QQuickWindow::sceneGraphInvalidated, this, &WBufferRenderer::invalidateSceneGraph); | ||
| }); | ||
| } | ||
|
|
||
| WBufferRenderer::~WBufferRenderer() | ||
|
|
@@ -142,7 +152,6 @@ void WBufferRenderer::setSourceList(QList<QQuickItem*> sources, bool hideSource) | |
| return; | ||
|
|
||
| resetSources(); | ||
| m_sourceList.clear(); | ||
| m_hideSource = hideSource; | ||
|
|
||
| for (auto s : std::as_const(sources)) { | ||
|
|
@@ -154,7 +163,7 @@ void WBufferRenderer::setSourceList(QList<QQuickItem*> sources, bool hideSource) | |
| connect(s, &QQuickItem::destroyed, this, [this] { | ||
| const int index = indexOfSource(static_cast<QQuickItem*>(sender())); | ||
| Q_ASSERT(index >= 0); | ||
| removeSource(index); | ||
| destroySource(index); | ||
| m_sourceList.removeAt(index); | ||
| }); | ||
|
|
||
|
|
@@ -687,11 +696,13 @@ void WBufferRenderer::invalidateSceneGraph() | |
| { | ||
| if (m_textureProvider) | ||
| m_textureProvider.reset(); | ||
| resetSources(); | ||
| } | ||
|
|
||
| void WBufferRenderer::releaseResources() | ||
| { | ||
| cleanTextureProvider(); | ||
| resetSources(); | ||
| } | ||
|
|
||
| void WBufferRenderer::cleanTextureProvider() | ||
|
|
@@ -723,19 +734,23 @@ void WBufferRenderer::cleanTextureProvider() | |
| void WBufferRenderer::resetSources() | ||
| { | ||
| for (int i = 0; i < m_sourceList.size(); ++i) { | ||
| removeSource(i); | ||
| destroySource(i); | ||
| } | ||
| m_sourceList.clear(); | ||
| } | ||
|
|
||
| void WBufferRenderer::removeSource(int index) | ||
| void WBufferRenderer::destroySource(int index) | ||
| { | ||
| auto s = m_sourceList.at(index); | ||
| auto &s = m_sourceList[index]; | ||
| if (isRootItem(s.source)) | ||
| return; | ||
|
|
||
| // Renderer of source is delay initialized in ensureRenderer. It might be null here. | ||
| if (s.renderer) | ||
| s.renderer->deleteLater(); | ||
| if (s.renderer) { | ||
| delete s.renderer; | ||
misaka18931 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| s.renderer = nullptr; | ||
| } | ||
|
|
||
| auto d = QQuickItemPrivate::get(s.source); | ||
| if (d->inDestructor) | ||
| return; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.