Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Crash: Properly dispose ResourceFontLoader #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions Desktop/DirectWrite/CustomFont/CustomFont.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Desktop/DirectWrite/CustomFont/CustomFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,22 @@ private void comboBoxFonts_SelectedIndexChanged(object sender, EventArgs e)

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}

CurrentResourceFontLoader.Dispose();
}
base.Dispose(disposing);
}
}
}
15 changes: 15 additions & 0 deletions Desktop/DirectWrite/CustomFont/ResourceFontLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,20 @@ FontFileStream FontFileLoader.CreateStreamFromKey(DataPointer fontFileReferenceK
var index = Utilities.Read<int>(fontFileReferenceKey.Pointer);
return _fontStreams[index];
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing)
{
_factory.UnregisterFontFileLoader(this);
_factory.UnregisterFontCollectionLoader(this);
}

base.Dispose(disposing);
}
}
}