Skip to content

Commit f0f8a27

Browse files
fuddlesworthruvnet
andcommitted
fix: regenerate UUIDs on layout import when colliding with existing layout
Imported layouts preserved their original UUID, which could collide with an already-loaded layout. Now checks for collision and re-creates via copy constructor (new layout UUID + new zone UUIDs) when a match exists. Co-Authored-By: claude-flow <ruv@ruv.net>
1 parent 3a93ba8 commit f0f8a27

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/core/layoutmanager.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,14 +1009,23 @@ void LayoutManager::importLayout(const QString& filePath)
10091009
return;
10101010
}
10111011

1012-
auto layout = Layout::fromJson(doc.object(), this);
1013-
if (!layout) {
1012+
auto* parsed = Layout::fromJson(doc.object(), this);
1013+
if (!parsed) {
10141014
qCWarning(lcLayout) << "Failed to create layout from imported JSON:" << filePath;
10151015
return;
10161016
}
10171017

1018+
// If a layout with the same UUID already exists, regenerate all IDs via copy
1019+
// constructor (new layout UUID + new zone UUIDs) to avoid collisions
1020+
Layout* layout = parsed;
1021+
if (layoutById(parsed->id())) {
1022+
qCInfo(lcLayout) << "Imported layout UUID collides with existing layout — regenerating IDs";
1023+
layout = new Layout(*parsed);
1024+
delete parsed;
1025+
}
1026+
10181027
// Imported layouts have no source path - they'll be saved to user directory
1019-
// (sourcePath is already empty from fromJson)
1028+
// (sourcePath is already empty from fromJson / copy constructor)
10201029

10211030
// Reset visibility restrictions since screen/desktop/activity names are machine-specific
10221031
layout->setHiddenFromSelector(false);

0 commit comments

Comments
 (0)