diff --git a/src/bindings/mono/efl_mono/GenericModel.cs b/src/bindings/mono/efl_mono/GenericModel.cs index 1f92b8cd3e..8bfa8ce2f7 100644 --- a/src/bindings/mono/efl_mono/GenericModel.cs +++ b/src/bindings/mono/efl_mono/GenericModel.cs @@ -18,7 +18,7 @@ namespace Efl { /// /// The type of the child model. It is the type used when adding/removing/getting items to this /// model. -public class GenericModel : Efl.Object, Efl.IModel, IDisposable +public class GenericModel : Efl.Object, Efl.IModel { private Efl.IModel model; diff --git a/src/bindings/mono/efl_mono/ItemFactory.cs b/src/bindings/mono/efl_mono/ItemFactory.cs index 34791e1213..a97401c9aa 100644 --- a/src/bindings/mono/efl_mono/ItemFactory.cs +++ b/src/bindings/mono/efl_mono/ItemFactory.cs @@ -16,7 +16,7 @@ namespace Efl.Ui /// factory.Style().Bind("Name"); // The factory Style property is bound to the Name property for the given model. /// /// -public class ItemFactory : Efl.Ui.LayoutFactory, IDisposable +public class ItemFactory : Efl.Ui.LayoutFactory { /// Creates a new factory. /// diff --git a/src/bindings/mono/efl_mono/UserModel.cs b/src/bindings/mono/efl_mono/UserModel.cs index 1116dfc561..a235a3a87f 100644 --- a/src/bindings/mono/efl_mono/UserModel.cs +++ b/src/bindings/mono/efl_mono/UserModel.cs @@ -67,7 +67,7 @@ internal class ModelHelper /// /// The enclosed C# model class with the properties to be added to the native model. [Efl.Eo.BindingEntity] -public class UserModel : Efl.MonoModelInternal, IDisposable +public class UserModel : Efl.MonoModelInternal { /// /// Creates a new root model. @@ -85,12 +85,6 @@ public class UserModel : Efl.MonoModelInternal, IDisposable } } - /// Disposes of this instance. - ~UserModel() - { - Dispose(false); - } - /// Adds a new child to the model wrapping the properties of o /// /// Reflection is used to instantiate a new -based class for this child and diff --git a/src/bindings/mono/eina_mono/eina_accessor.cs b/src/bindings/mono/eina_mono/eina_accessor.cs index 6c939bcb52..64b4216a15 100644 --- a/src/bindings/mono/eina_mono/eina_accessor.cs +++ b/src/bindings/mono/eina_mono/eina_accessor.cs @@ -95,6 +95,7 @@ public class Accessor : IEnumerable, IDisposable public void Dispose() { Dispose(true); + GC.SuppressFinalize(this); } /// Disposes of this wrapper, releasing the native accessor if diff --git a/src/bindings/mono/eo_mono/NativeModule.cs b/src/bindings/mono/eo_mono/NativeModule.cs index fd3b315561..ad9cc60214 100644 --- a/src/bindings/mono/eo_mono/NativeModule.cs +++ b/src/bindings/mono/eo_mono/NativeModule.cs @@ -22,6 +22,7 @@ namespace Efl.Eo public partial class NativeModule : IDisposable { private Lazy module; + private bool disposed = false; ///Lazily tries to load the module with the given name. ///The name of the module to load. @@ -43,12 +44,39 @@ public partial class NativeModule : IDisposable } } - ///Unload and released the handle to the wrapped module. + /// Finalizer to be called from the Garbage Collector. + ~NativeModule() + { + Dispose(false); + } + + /// Unload and released the handle to the wrapped module. public void Dispose() { - UnloadLibrary(module.Value); - module = null; + Dispose(true); + GC.SuppressFinalize(this); } + + /// Unload and released the handle to the wrapped module. + protected virtual void Dispose(bool disposing) + { + if (disposed) + { + return; + } + + if (disposing) + { + module = null; + } + + if (module.IsValueCreated) + { + UnloadLibrary(module.Value); + } + + disposed = true; + } } }