plasmadesk:fix startup freezes from QDbusInterface

--as it appears plasma applets were not the main faulter
to blame for startup freezes. The bug was that Latte
was trying to communicate with Plasma DBus interface
to inform it about docks/panels geometries. For some
reason during startup other applets could also were
trying the same and for that reason Qt provides a 25sec
forced delay in case there are too many such calls.
The new approach does not block the startup code at all
and it should work at all cases.

BUG:444739
FIXED-IN:0.10.4
work/m_layershell
Michail Vourlakos 3 years ago
parent 710def2081
commit 912f2f1cfa

@ -60,11 +60,17 @@ ScreenGeometries::~ScreenGeometries()
void ScreenGeometries::init()
{
QDBusInterface plasmaStrutsIface(PLASMASERVICE, "/StrutManager", PLASMASTRUTNAMESPACE, QDBusConnection::sessionBus());
qDebug() << " PLASMA STRUTS MANAGER :: checking availability....";
bool serviceavailable{false};
if (QDBusConnection::sessionBus().interface()) {
serviceavailable = QDBusConnection::sessionBus().interface()->isServiceRegistered(PLASMASERVICE).value();
qDebug() << "PLASMA STRUTS MANAGER :: interface availability :: " << QDBusConnection::sessionBus().interface()->isServiceRegistered(PLASMASERVICE).value();
}
connect(m_corona->universalSettings(), &Latte::UniversalSettings::isAvailableGeometryBroadcastedToPlasmaChanged, this, &ScreenGeometries::onBroadcastToPlasmaChanged);
if (plasmaStrutsIface.isValid()) {
if (serviceavailable) {
m_plasmaInterfaceAvailable = true;
qDebug() << " PLASMA STRUTS MANAGER :: is available...";
@ -109,15 +115,54 @@ void ScreenGeometries::onBroadcastToPlasmaChanged()
}
}
void ScreenGeometries::clearGeometries()
void ScreenGeometries::setPlasmaAvailableScreenRect(const QString &screenName, const QRect &rect)
{
if (!m_plasmaInterfaceAvailable) {
return;
QDBusMessage message = QDBusMessage::createMethodCall(PLASMASERVICE,
"/StrutManager",
PLASMASTRUTNAMESPACE,
"setAvailableScreenRect");
QVariantList args;
args << LATTESERVICE
<< screenName
<< rect;
message.setArguments(args);
QDBusConnection::sessionBus().call(message, QDBus::NoBlock);
}
void ScreenGeometries::setPlasmaAvailableScreenRegion(const QString &screenName, const QRegion &region)
{
QDBusMessage message = QDBusMessage::createMethodCall(PLASMASERVICE,
"/StrutManager",
PLASMASTRUTNAMESPACE,
"setAvailableScreenRegion");
QVariant regionvariant;
if (!region.isNull()) {
//! transorm QRegion to QList<QRect> in order to be sent through dbus
QList<QRect> rects;
foreach (const QRect &rect, region) {
rects << rect;
}
regionvariant = QVariant::fromValue(rects);
}
QDBusInterface plasmaStrutsIface(PLASMASERVICE, "/StrutManager", PLASMASTRUTNAMESPACE, QDBusConnection::sessionBus());
QVariantList args;
args << LATTESERVICE
<< screenName
<< regionvariant;
if (!plasmaStrutsIface.isValid()) {
message.setArguments(args);
QDBusConnection::sessionBus().call(message, QDBus::NoBlock);
}
void ScreenGeometries::clearGeometries()
{
if (!m_plasmaInterfaceAvailable) {
return;
}
@ -126,8 +171,8 @@ void ScreenGeometries::clearGeometries()
int scrId = m_corona->screenPool()->id(screen->name());
if (m_corona->screenPool()->hasScreenId(scrId)) {
plasmaStrutsIface.call("setAvailableScreenRect", LATTESERVICE, scrName, QRect());
plasmaStrutsIface.call("setAvailableScreenRegion", LATTESERVICE, scrName, QVariant());
setPlasmaAvailableScreenRect(scrName, QRect());
setPlasmaAvailableScreenRegion(scrName, QRegion());
}
}
@ -141,12 +186,6 @@ void ScreenGeometries::updateGeometries()
return;
}
QDBusInterface plasmaStrutsIface(PLASMASERVICE, "/StrutManager", PLASMASTRUTNAMESPACE, QDBusConnection::sessionBus());
if (!plasmaStrutsIface.isValid()) {
return;
}
QStringList availableScreenNames;
qDebug() << " PLASMA SCREEN GEOMETRIES, LAST AVAILABLE SCREEN RECTS :: " << m_lastAvailableRect;
@ -178,13 +217,13 @@ void ScreenGeometries::updateGeometries()
//! is using a different layout. When the user from Unity is switching to
//! Music and afterwards to Canvas the desktop elements are not positioned properly
if (m_forceGeometryBroadcast) {
plasmaStrutsIface.call("setAvailableScreenRect", LATTESERVICE, scrName, QRect());
setPlasmaAvailableScreenRect(scrName, QRect());
}
//! Disable checks because of the workaround concerning plasma desktop behavior
if (m_forceGeometryBroadcast || (!m_lastAvailableRect.contains(scrName) || m_lastAvailableRect[scrName] != availableRect)) {
m_lastAvailableRect[scrName] = availableRect;
plasmaStrutsIface.call("setAvailableScreenRect", LATTESERVICE, scrName, availableRect);
setPlasmaAvailableScreenRect(scrName, availableRect);
qDebug() << " PLASMA SCREEN GEOMETRIES, AVAILABLE RECT :: " << screen->name() << " : " << availableRect;
}
@ -194,14 +233,7 @@ void ScreenGeometries::updateGeometries()
if (!m_lastAvailableRegion.contains(scrName) || m_lastAvailableRegion[scrName] != availableRegion) {
m_lastAvailableRegion[scrName] = availableRegion;
//! transorm QRegion to QList<QRect> in order to be sent through dbus
QList<QRect> rects;
foreach (const QRect &rect, availableRegion) {
rects << rect;
}
plasmaStrutsIface.call("setAvailableScreenRegion", LATTESERVICE, scrName, QVariant::fromValue(rects));
setPlasmaAvailableScreenRegion(scrName, availableRegion);
qDebug() << " PLASMA SCREEN GEOMETRIES, AVAILABLE REGION :: " << screen->name() << " : " << availableRegion;
}
}
@ -213,8 +245,8 @@ void ScreenGeometries::updateGeometries()
for (QString &lastScrName : m_lastScreenNames) {
if (!screenIsActive(lastScrName)) {
//! screen became inactive and its geometries could be unpublished
plasmaStrutsIface.call("setAvailableScreenRect", LATTESERVICE, lastScrName, QRect());
plasmaStrutsIface.call("setAvailableScreenRegion", LATTESERVICE, lastScrName, QVariant::fromValue(QList<QRect>()));
setPlasmaAvailableScreenRect(lastScrName, QRect());
setPlasmaAvailableScreenRegion(lastScrName, QRegion());
m_lastAvailableRect.remove(lastScrName);
m_lastAvailableRegion.remove(lastScrName);

@ -43,6 +43,8 @@ private slots:
private slots:
bool screenIsActive(const QString &screenName) const;
void setPlasmaAvailableScreenRect(const QString &screenName, const QRect &rect);
void setPlasmaAvailableScreenRegion(const QString &screenName, const QRegion &region);
private:
bool m_plasmaInterfaceAvailable{false};

Loading…
Cancel
Save