Fix group creation parenting (#455)

* WIP fix of folder crash / indent

* Fixed most crashes

* Known cases of crash / incorrect behavior resolved

* Removed todo & readability tweak

* Removed left over test

* Resolved clippy issue resulting from merging master

* Replace recursive tree traversal with prefix matching

* Reverted changes for #453 and added undo functionality to Paste

* Make uuid generator thread local for tests

* Maintain layer order, test still failing 50% of the time

* Reverting back to known working with the knowledge we can optimize later.

This reverts commit 1aaf5c0d7d.

* Revert "Make uuid generator thread local for tests"

This reverts commit d68e3b9c4e.

* Revert "Reverted changes for #453 and added undo functionality to Paste"

This reverts commit d66992ac94.

* Revert "Replace recursive tree traversal with prefix matching"

This reverts commit 6bcbb9f82f.

* Reverted to working state and added comment back to optimized commit hash

* Re-removed the changes involving #453

Co-authored-by: Dennis <dennis@kobert.dev>
This commit is contained in:
Oliver Davies
2022-01-04 19:18:28 -08:00
committed by Keavon Chambers
parent 26f0f70023
commit 70d3283196
5 changed files with 77 additions and 30 deletions

View File

@@ -352,15 +352,18 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
responses.push_back(DocumentsMessage::SelectDocument(prev_id).into());
}
Copy(clipboard) => {
let paths = self.active_document().selected_layers_sorted();
self.copy_buffer[clipboard as usize].clear();
for path in paths {
let document = self.active_document();
match (document.graphene_document.layer(&path).map(|t| t.clone()), *document.layer_metadata(&path)) {
// We can't use `self.active_document()` because it counts as an immutable borrow of the entirety of `self`
let active_document = self.documents.get(&self.active_document_id).unwrap();
let copy_buffer = &mut self.copy_buffer;
copy_buffer[clipboard as usize].clear();
for layer_path in active_document.selected_layers_without_children() {
match (active_document.graphene_document.layer(&layer_path).map(|t| t.clone()), *active_document.layer_metadata(&layer_path)) {
(Ok(layer), layer_metadata) => {
self.copy_buffer[clipboard as usize].push(CopyBufferEntry { layer, layer_metadata });
copy_buffer[clipboard as usize].push(CopyBufferEntry { layer, layer_metadata });
}
(Err(e), _) => warn!("Could not access selected layer {:?}: {:?}", path, e),
(Err(e), _) => warn!("Could not access selected layer {:?}: {:?}", layer_path, e),
}
}
}
@@ -372,9 +375,9 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
let document = self.active_document();
let shallowest_common_folder = document
.graphene_document
.deepest_common_folder(document.selected_layers())
.shallowest_common_folder(document.selected_layers())
.expect("While pasting, the selected layers did not exist while attempting to find the appropriate folder path for insertion");
responses.push_back(StartTransaction.into());
responses.push_back(
PasteIntoFolder {
clipboard,
@@ -383,6 +386,7 @@ impl MessageHandler<DocumentsMessage, &InputPreprocessor> for DocumentsMessageHa
}
.into(),
);
responses.push_back(CommitTransaction.into());
}
PasteIntoFolder { clipboard, path, insert_index } => {
let paste = |entry: &CopyBufferEntry, responses: &mut VecDeque<_>| {