You've already forked linux-packaging-mono
Imported Upstream version 6.12.0.122
Former-commit-id: d3ff4118f95cc6907059c6001e5157df8832a115
This commit is contained in:
parent
bb7877ea56
commit
a0d6f2d6ec
@ -41,7 +41,7 @@ static partial class Consts
|
||||
// Use these assembly version constants to make code more maintainable.
|
||||
//
|
||||
|
||||
public const string MonoVersion = "6.12.0.114";
|
||||
public const string MonoVersion = "6.12.0.122";
|
||||
public const string MonoCompany = "Mono development team";
|
||||
public const string MonoProduct = "Mono Common Language Infrastructure";
|
||||
public const string MonoCopyright = "(c) Various Mono authors";
|
||||
|
@ -41,6 +41,93 @@ namespace System.Drawing.Imaging {
|
||||
[Editor ("System.Drawing.Design.MetafileEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
|
||||
public sealed class Metafile : Image {
|
||||
|
||||
// Non-null if a graphics instance was created using
|
||||
// Graphics.FromImage(this) The metadata holder is responsible for
|
||||
// freeing the nativeImage if the Metadata instance is disposed before
|
||||
// the Graphics instance.
|
||||
private MetafileHolder _metafileHolder;
|
||||
|
||||
// A class responsible for disposing of the native Metafile instance
|
||||
// if it needs to outlive the managed Metafile instance.
|
||||
//
|
||||
// The following are both legal with win32 GDI+:
|
||||
// Metafile mf = ...; // get a metafile instance
|
||||
// Graphics g = Graphics.FromImage(mf); // get a graphics instance
|
||||
// g.Dispose(); mf.Dispose(); // dispose of the graphics instance first
|
||||
// OR
|
||||
// mf.Dispose(); g.Dispose(); // dispose of the metafile instance first
|
||||
//
|
||||
// ligbgdiplus has a bug where disposing of the metafile instance first will
|
||||
// trigger a use of freed memory when the graphics instance is disposed, which
|
||||
// could lead to crashes when the native memory is reused.
|
||||
//
|
||||
// The metafile holder is designed to take ownership of the native metafile image
|
||||
// when the managed Metafile instance is disposed while a Graphics instance is still
|
||||
// not disposed (ie the second code pattern above) and to keep the native image alive until the graphics
|
||||
// instance is disposed.
|
||||
//
|
||||
// Note that the following throws, so we only ever need to keep track of one Graphics
|
||||
// instance at a time:
|
||||
// Metafile mf = ...; // get a metafile instance
|
||||
// Graphics g = Graphics.FromImage(mf);
|
||||
// Graphics g2 = Graphics.FromImage(mf); // throws OutOfMemoryException on GDI+ on Win32
|
||||
internal sealed class MetafileHolder : IDisposable
|
||||
{
|
||||
private bool _disposed;
|
||||
private IntPtr _nativeImage;
|
||||
|
||||
|
||||
internal bool Disposed { get => _disposed; }
|
||||
internal MetafileHolder()
|
||||
{
|
||||
_disposed = false;
|
||||
_nativeImage = IntPtr.Zero;
|
||||
}
|
||||
|
||||
~MetafileHolder() => Dispose(false);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
internal void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
IntPtr nativeImage = _nativeImage;
|
||||
_nativeImage = IntPtr.Zero;
|
||||
_disposed = true;
|
||||
if (nativeImage != IntPtr.Zero)
|
||||
{
|
||||
Status status = GDIPlus.GdipDisposeImage(nativeImage);
|
||||
GDIPlus.CheckStatus(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void MetafileDisposed(IntPtr nativeImage)
|
||||
{
|
||||
_nativeImage = nativeImage;
|
||||
}
|
||||
|
||||
internal void GraphicsDisposed()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
internal MetafileHolder AddMetafileHolder()
|
||||
{
|
||||
// If _metafileHolder is not null and hasn't been disposed yet, there's already a graphics instance associated with
|
||||
// this metafile, the native code will return an error status.
|
||||
if (_metafileHolder != null && !_metafileHolder.Disposed)
|
||||
return null;
|
||||
_metafileHolder = new MetafileHolder();
|
||||
return _metafileHolder;
|
||||
}
|
||||
|
||||
// constructors
|
||||
|
||||
internal Metafile (IntPtr ptr)
|
||||
@ -324,6 +411,21 @@ namespace System.Drawing.Imaging {
|
||||
GDIPlus.CheckStatus (status);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_metafileHolder != null && !_metafileHolder.Disposed)
|
||||
{
|
||||
// There's a graphics instance created from this Metafile,
|
||||
// transfer responsibility for disposing the nativeImage to the
|
||||
// MetafileHolder
|
||||
_metafileHolder.MetafileDisposed(nativeObject);
|
||||
_metafileHolder = null;
|
||||
nativeObject = IntPtr.Zero;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
public IntPtr GetHenhmetafile ()
|
||||
|
@ -48,6 +48,7 @@ namespace System.Drawing
|
||||
private static float defDpiX = 0;
|
||||
private static float defDpiY = 0;
|
||||
private IntPtr deviceContextHdc;
|
||||
private Metafile.MetafileHolder _metafileHolder;
|
||||
|
||||
public delegate bool EnumerateMetafileProc (EmfPlusRecordType recordType,
|
||||
int flags,
|
||||
@ -62,6 +63,13 @@ namespace System.Drawing
|
||||
nativeObject = nativeGraphics;
|
||||
}
|
||||
|
||||
internal Graphics(IntPtr nativeGraphics, Image image) : this(nativeGraphics)
|
||||
{
|
||||
if (image is Metafile mf) {
|
||||
_metafileHolder = mf.AddMetafileHolder();
|
||||
}
|
||||
}
|
||||
|
||||
~Graphics ()
|
||||
{
|
||||
Dispose ();
|
||||
@ -297,6 +305,14 @@ namespace System.Drawing
|
||||
status = GDIPlus.GdipDeleteGraphics (nativeObject);
|
||||
nativeObject = IntPtr.Zero;
|
||||
GDIPlus.CheckStatus (status);
|
||||
|
||||
if (_metafileHolder != null)
|
||||
{
|
||||
var mh = _metafileHolder;
|
||||
_metafileHolder = null;
|
||||
mh.GraphicsDisposed();
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
@ -1773,8 +1789,7 @@ namespace System.Drawing
|
||||
|
||||
Status status = GDIPlus.GdipGetImageGraphicsContext (image.nativeObject, out graphics);
|
||||
GDIPlus.CheckStatus (status);
|
||||
Graphics result = new Graphics (graphics);
|
||||
|
||||
Graphics result = new Graphics (graphics, image);
|
||||
if (GDIPlus.RunningOnUnix ()) {
|
||||
Rectangle rect = new Rectangle (0,0, image.Width, image.Height);
|
||||
GDIPlus.GdipSetVisibleClip_linux (result.NativeObject, ref rect);
|
||||
|
@ -1 +1 @@
|
||||
f7c90ecb7039b50c849d8fc69a3fb9c667d25dc2
|
||||
b6ae1a389abf8522eb2af7c466bcdeabe7d07afe
|
@ -1 +1 @@
|
||||
157a5eea0abf5e481b743673ee36f6be52867eaa
|
||||
3ee05f5b1da596ed5b5bf621b39a71a9136d47db
|
@ -1 +1 @@
|
||||
1cb2387450c7e89fd61edd24512b842176e9781b
|
||||
4a32b1562eb1c560259c3fd6f9b69f58a75079dc
|
@ -1 +1 @@
|
||||
2f467d3215b80c901624dec1d5e46b396a58314b
|
||||
1bf60cd84b6fba28d0d547dd1fea857957452f52
|
@ -1 +1 @@
|
||||
accaedfebd11e960ce98e110d23a3271cce0b160
|
||||
6cf153d1bd08986c8c4d67bc30530b4811d1fba6
|
@ -1 +1 @@
|
||||
7059a34ac29e613ec9ff517294b1c2cffd697e9e
|
||||
222ff52486c984e80ea2a48d3c49ca9c6a141641
|
@ -1 +1 @@
|
||||
1c73a2b7cffb8469ffed03314fcbe40c75008d92
|
||||
f64114fae057d01ee7d022d2942373e87d2af6b3
|
@ -1 +1 @@
|
||||
664bff1b1661527fd1304459d1d4ee41de65ce46
|
||||
9532d1f7cdffce58fda438c8b17f33cdbe2e70b6
|
@ -1 +1 @@
|
||||
f7c90ecb7039b50c849d8fc69a3fb9c667d25dc2
|
||||
b6ae1a389abf8522eb2af7c466bcdeabe7d07afe
|
@ -1 +1 @@
|
||||
157a5eea0abf5e481b743673ee36f6be52867eaa
|
||||
3ee05f5b1da596ed5b5bf621b39a71a9136d47db
|
@ -1 +1 @@
|
||||
1cb2387450c7e89fd61edd24512b842176e9781b
|
||||
4a32b1562eb1c560259c3fd6f9b69f58a75079dc
|
@ -1 +1 @@
|
||||
2f467d3215b80c901624dec1d5e46b396a58314b
|
||||
1bf60cd84b6fba28d0d547dd1fea857957452f52
|
@ -1 +1 @@
|
||||
accaedfebd11e960ce98e110d23a3271cce0b160
|
||||
6cf153d1bd08986c8c4d67bc30530b4811d1fba6
|
@ -1 +1 @@
|
||||
7059a34ac29e613ec9ff517294b1c2cffd697e9e
|
||||
222ff52486c984e80ea2a48d3c49ca9c6a141641
|
@ -1 +1 @@
|
||||
1c73a2b7cffb8469ffed03314fcbe40c75008d92
|
||||
f64114fae057d01ee7d022d2942373e87d2af6b3
|
@ -1 +1 @@
|
||||
664bff1b1661527fd1304459d1d4ee41de65ce46
|
||||
9532d1f7cdffce58fda438c8b17f33cdbe2e70b6
|
@ -1 +1 @@
|
||||
f7c90ecb7039b50c849d8fc69a3fb9c667d25dc2
|
||||
b6ae1a389abf8522eb2af7c466bcdeabe7d07afe
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user