diff --git a/app/layout/centrallayout.cpp b/app/layout/centrallayout.cpp index 01a53fa62..e962ed56d 100644 --- a/app/layout/centrallayout.cpp +++ b/app/layout/centrallayout.cpp @@ -199,7 +199,7 @@ QString CentralLayout::sharedLayoutName() const void CentralLayout::setSharedLayoutName(QString name) { - if (m_sharedLayoutName == name || !Importer::layoutExists(name)) { + if (m_sharedLayoutName == name || (!Importer::layoutExists(name) && !name.isEmpty())) { return; } diff --git a/app/settings/settingsdialog.cpp b/app/settings/settingsdialog.cpp index a4ab33463..557c12f06 100644 --- a/app/settings/settingsdialog.cpp +++ b/app/settings/settingsdialog.cpp @@ -1599,7 +1599,7 @@ bool SettingsDialog::saveAllChanges() for (const auto &newLayoutName : activeLayoutsToRename.keys()) { Layout::GenericLayout *layout = activeLayoutsToRename[newLayoutName]; qDebug() << " Active Layout of Type: " << layout->type() << " Is Renamed From : " << activeLayoutsToRename[newLayoutName]->name() << " TO :: " << newLayoutName; - layout->renameLayout(newLayoutName); + layout->renameLayout(newLayoutName); if (layout->type() == Layout::Type::Central) { CentralLayout *central = qobject_cast(layout); @@ -1681,21 +1681,26 @@ void SettingsDialog::updateActiveShares() for (QHash::iterator i=currentSharesMap.begin(); i!=currentSharesMap.end(); ++i) { SharedLayout *shared = m_corona->layoutManager()->sharedLayout(nameForId(i.key())); - if (shared) { - qDebug() << " SHARED :: " << shared->name(); - for (const auto ¢ralId : i.value()) { - CentralLayout *central = m_corona->layoutManager()->centralLayout(nameForId(centralId)); - qDebug() << " CENTRAL NAME :: " << nameForId(centralId); - if (central) { - //! Assign this Central Layout at a different Shared Layout - SharedLayout *oldShared = central->sharedLayout(); - if (shared != oldShared) { - shared->addCentralLayout(central); - central->setSharedLayout(shared); - if (oldShared) { - //! CENTRAL layout that changed from one ACTIVESHARED layout to another - unassign[central] = shared; - } + qDebug() << " SHARED :: " << nameForId(i.key()); + for (const auto ¢ralId : i.value()) { + CentralLayout *central = m_corona->layoutManager()->centralLayout(nameForId(centralId)); + qDebug() << " CENTRAL NAME :: " << nameForId(centralId); + if (central) { + //! Assign this Central Layout at a different Shared Layout + SharedLayout *oldShared = central->sharedLayout(); + + if (!shared) { + //Shared not loaded and it must be loaded before proceed + m_corona->layoutManager()->registerAtSharedLayout(central, nameForId(i.key())); + shared = m_corona->layoutManager()->sharedLayout(nameForId(i.key())); + } + + if (shared != oldShared) { + shared->addCentralLayout(central); + central->setSharedLayout(shared); + if (oldShared) { + //! CENTRAL layout that changed from one ACTIVESHARED layout to another + unassign[central] = shared; } } }