This commit is contained in:
Christian Schulz 2025-08-13 16:27:13 -04:00 committed by GitHub
commit dd3c28a6eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -610,6 +610,7 @@ EndSelection:<<<<<<<4
} }
var fileFormatHandlers = SimpleServiceProvider.Current.GetAllInstances<IFileFormatHandler>(); var fileFormatHandlers = SimpleServiceProvider.Current.GetAllInstances<IFileFormatHandler>();
var supportedExtensions = fileFormatHandlers.ExtensionsFor(FileFormatHandlerActions.LoadDrawableFromStream).ToList(); var supportedExtensions = fileFormatHandlers.ExtensionsFor(FileFormatHandlerActions.LoadDrawableFromStream).ToList();
var foundContainer = false;
foreach (var (stream, filename) in IterateClipboardContent(dataObject)) foreach (var (stream, filename) in IterateClipboardContent(dataObject))
{ {
@ -622,7 +623,8 @@ EndSelection:<<<<<<<4
IEnumerable<IDrawableContainer> drawableContainers; IEnumerable<IDrawableContainer> drawableContainers;
try try
{ {
drawableContainers = fileFormatHandlers.LoadDrawablesFromStream(stream, extension); // without toList() here, LoadDrawablesFromStream() are called after the stream has been disposed
drawableContainers = fileFormatHandlers.LoadDrawablesFromStream(stream, extension).ToList();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -636,10 +638,14 @@ EndSelection:<<<<<<<4
// If we get here, there is an image // If we get here, there is an image
foreach (var container in drawableContainers) foreach (var container in drawableContainers)
{ {
foundContainer = true;
yield return container; yield return container;
} }
} }
// we found sth., prevent multiple imports of the same content
if (foundContainer) yield break;
// check if files are supplied // check if files are supplied
foreach (string imageFile in GetImageFilenames(dataObject)) foreach (string imageFile in GetImageFilenames(dataObject))
{ {