[vlc-commits] [Git][videolan/vlc][master] qt: do not unnecessarily keep the component for `MainInterface.qml` around
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Apr 27 16:20:58 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
455c91cf by Fatih Uzunoglu at 2026-04-27T16:07:51+00:00
qt: do not unnecessarily keep the component for `MainInterface.qml` around
We do not create `MainInterface.qml` multiple times, keeping the component
around is not necessary and consumes memory unnecessarily.
- - - - -
2 changed files:
- modules/gui/qt/maininterface/mainui.cpp
- modules/gui/qt/maininterface/mainui.hpp
Changes:
=====================================
modules/gui/qt/maininterface/mainui.cpp
=====================================
@@ -177,27 +177,34 @@ bool MainUI::setup(QQmlEngine* engine)
QQuickItem* MainUI::createRootItem()
{
+ if (m_rootItem)
+ return m_rootItem;
+
+ assert(m_component);
+
QObject* rootObject = m_component->create();
if (m_component->isError())
{
for(auto& error: m_component->errors())
msg_Err(m_intf, "qml loading %s %s:%u", qtu(error.description()), qtu(error.url().toString()), error.line());
- return nullptr;
+ goto end;
}
if (rootObject == nullptr)
{
msg_Err(m_intf, "unable to create main interface, no root item");
- return nullptr;
+ goto end;
}
m_rootItem = qobject_cast<QQuickItem*>(rootObject);
if (!m_rootItem)
{
msg_Err(m_intf, "unexpected type of qml root item");
- return nullptr;
+ goto end;
}
+end:
+ delete m_component; // No need to have the component around anymore.
return m_rootItem;
}
=====================================
modules/gui/qt/maininterface/mainui.hpp
=====================================
@@ -37,7 +37,7 @@ private:
MainCtx* m_mainCtx = nullptr;
QWindow* m_interfaceWindow = nullptr;
- QQmlComponent* m_component = nullptr;
+ QPointer<QQmlComponent> m_component;
QQuickItem* m_rootItem = nullptr;
QPointer<QQmlEngine> m_engineBound;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/455c91cf004a2a6367e1a1b931654d4b264c07dd
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/455c91cf004a2a6367e1a1b931654d4b264c07dd
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list