Skip to content

Commit f9de83c

Browse files
committed
Merge branch 'rubberduck-vba/next' into 5191_I_thru_Z
2 parents ecdd638 + 175de28 commit f9de83c

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

Rubberduck.Core/UI/Converters/ImageSourceConverter.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ public abstract class ImageSourceConverter : IValueConverter
1212
{
1313
protected static ImageSource ToImageSource(Image source)
1414
{
15-
var ms = new MemoryStream();
15+
using (var ms = new MemoryStream())
16+
{
17+
((Bitmap) source).Save(ms, System.Drawing.Imaging.ImageFormat.Png);
18+
var image = new BitmapImage();
19+
image.BeginInit();
20+
image.CacheOption = BitmapCacheOption.OnLoad;
21+
ms.Seek(0, SeekOrigin.Begin);
22+
image.StreamSource = ms;
23+
image.EndInit();
24+
image.Freeze();
1625

17-
((Bitmap)source).Save(ms, System.Drawing.Imaging.ImageFormat.Png);
18-
var image = new BitmapImage();
19-
image.BeginInit();
20-
ms.Seek(0, SeekOrigin.Begin);
21-
image.StreamSource = ms;
22-
image.EndInit();
23-
image.Freeze();
24-
25-
return image;
26+
return image;
27+
}
2628
}
2729

2830
public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,7 @@ private void ExecuteCommonParseActivities(IReadOnlyCollection<QualifiedModuleNam
239239
_parserStateManager.SetStatusAndFireStateChanged(this, ParserState.LoadingReference, token);
240240
token.ThrowIfCancellationRequested();
241241

242-
RefreshUserComProjects(toParse, newProjectIds);
243-
token.ThrowIfCancellationRequested();
244-
245-
SyncDeclarationsFromUserComProjects(toParse, token, toReresolveReferences);
242+
ProcessUserComProjects(ref token, ref toParse, ref toReresolveReferences, ref newProjectIds);
246243

247244
SyncComReferences(toParse, token, toReresolveReferences);
248245
token.ThrowIfCancellationRequested();
@@ -337,6 +334,17 @@ private void ExecuteCommonParseActivities(IReadOnlyCollection<QualifiedModuleNam
337334
token.ThrowIfCancellationRequested();
338335
}
339336

337+
//TODO: Remove the conditional compilation after loading from typelibs actually works.
338+
//TODO: Improve the handling to avoid host crashing. See https://github.com/rubberduck-vba/Rubberduck/issues/5217
339+
[Conditional("LOAD_USER_COM_PROJECTS")]
340+
private void ProcessUserComProjects(ref CancellationToken token, ref IReadOnlyCollection<QualifiedModuleName> toParse, ref HashSet<QualifiedModuleName> toReresolveReferences, ref IReadOnlyCollection<string> newProjectIds)
341+
{
342+
RefreshUserComProjects(toParse, newProjectIds);
343+
token.ThrowIfCancellationRequested();
344+
345+
SyncDeclarationsFromUserComProjects(toParse, token, toReresolveReferences);
346+
}
347+
340348
private void SyncComReferences(IReadOnlyCollection<QualifiedModuleName> toParse, CancellationToken token, HashSet<QualifiedModuleName> toReresolveReferences)
341349
{
342350
_parsingStageService.SyncComReferences(token);

0 commit comments

Comments
 (0)