From 4ec3bf7e9e8dc3231675e613ae824482fd0fe00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juho=20H=C3=A4m=C3=A4l=C3=A4inen?= Date: Mon, 20 May 2019 09:49:39 +0300 Subject: [PATCH] [resourcepolicy] Add option to disable internal resource handling. JB#45899 --- .../resourcepolicy/resourcepolicyint.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/plugins/resourcepolicy/resourcepolicyint.cpp b/src/plugins/resourcepolicy/resourcepolicyint.cpp index efc34278..1fd4b450 100644 --- a/src/plugins/resourcepolicy/resourcepolicyint.cpp +++ b/src/plugins/resourcepolicy/resourcepolicyint.cpp @@ -56,7 +56,18 @@ ResourcePolicyInt::ResourcePolicyInt(QObject *parent) { const char *resourceClass = "player"; - QByteArray envVar = qgetenv("NEMO_RESOURCE_CLASS_OVERRIDE"); + QByteArray envVar = qgetenv("NEMO_RESOURCE_DISABLE"); + + if (!envVar.isEmpty()) { +#ifdef RESOURCE_DEBUG + qDebug() << "##### Disable internal resource handling."; +#endif + m_status = GrantedResource; + m_available = true; + return; + } + + envVar = qgetenv("NEMO_RESOURCE_CLASS_OVERRIDE"); if (!envVar.isEmpty()) { QString data(envVar); // Only allow few resource classes @@ -132,7 +143,7 @@ void ResourcePolicyInt::removeClient(ResourcePolicyImpl *client) if (i.value().videoEnabled) { --m_video; - if (m_video == 0) { + if (m_video == 0 && m_resourceSet) { m_resourceSet->deleteResource(ResourcePolicy::VideoPlaybackType); m_resourceSet->update(); } @@ -161,6 +172,9 @@ bool ResourcePolicyInt::isVideoEnabled(const ResourcePolicyImpl *client) const void ResourcePolicyInt::setVideoEnabled(const ResourcePolicyImpl *client, bool videoEnabled) { + if (!m_resourceSet) + return; + bool update = false; QMap::iterator i = m_clients.find(client); @@ -284,8 +298,10 @@ void ResourcePolicyInt::release(const ResourcePolicyImpl *client) #ifdef RESOURCE_DEBUG qDebug() << "##### " << i.value().id << ": RELEASE call resourceSet->release()"; #endif - m_resourceSet->release(); - m_status = Initial; + if (m_resourceSet) { + m_resourceSet->release(); + m_status = Initial; + } } } }