tiles: Avoid log warning about non-existing tiles configuration

In some cases, there may not (yet) be any configuration data for tiles. This is a valid scenario and should not trigger a log entry at warning level.
This commit is contained in:
Stefan Hoffmeister 2023-12-18 21:55:46 +01:00 committed by Xaver Hugl
parent b43052af83
commit c21dea61c0

View file

@ -224,9 +224,6 @@ void TileManager::readSettings()
qreal padding = cg.readEntry("padding", 4);
cg = KConfigGroup(&cg, m_output->uuid().toString(QUuid::WithoutBraces));
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(cg.readEntry("tiles", QByteArray()), &error);
auto createDefaultSetup = [this]() {
Q_ASSERT(m_rootTile->childCount() == 0);
// If empty create an horizontal 3 columns layout
@ -238,6 +235,16 @@ void TileManager::readSettings()
m_rootTile->childTile(1)->setRelativeGeometry({0.25, 0.0, 0.5, 1.0});
};
QJsonParseError error;
const auto tiles = cg.readEntry("tiles", QByteArray());
if (tiles.isEmpty()) {
qCDebug(KWIN_CORE) << "Empty tiles configuration for monitor" << m_output->uuid().toString(QUuid::WithoutBraces) << ":"
<< "Creating default setup";
createDefaultSetup();
return;
}
QJsonDocument doc = QJsonDocument::fromJson(tiles, &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(KWIN_CORE) << "Parse error in tiles configuration for monitor" << m_output->uuid().toString(QUuid::WithoutBraces) << ":" << error.errorString() << "Creating default setup";
createDefaultSetup();