Ryujinx-GtkSharp/Source/Libs/GLibSharp
Sebastian Dröge 89cfd16c10 Ensure to sink floating references passed unowned to GetObject() and to not increase their reference count
The API contract between GObject-Introspection and bindings is that
functions returning transfer-none floating references pass a reference
to the bindings that should be taken ownership of by sinking it. Not
doing so is wrong and will lead to memory leaks or double frees.

Previously we would not distinguish this case and simply increment the
reference count. In addition we would then sink the floating reference
when the Object.Raw field is set later for InitiallyUnowned subclasses.

Remove that last part and instead check directly in Object.Raw.set if we
get a floating reference and if so simply sink it here and take
ownership of it. The general assumption of Object.Raw.set is that it
gets passed a reference that it should take ownership of.

So in summary:
1) GetObject() would only increase the reference count of unowned,
   non-floating references so that we own it. For unowned, floating
   references it assumes ownership of the reference.
2) Raw.set assumes ownership of the reference passed to it and if it
   happens to be a floating reference then it will first sink it.

Also warn if we get a floating, owned reference passed to GetObject() as
that case is not allowed by GObject-Introspection and would cause the
reference to be leaked.

This fixes a memory leak with functions returning unowned, floating
references and with functions returning owned, non-floating references
of InitiallyUnowned subclasses. And at the same time keeps constructors
for InitiallyUnowned subclasses working correctly without leaks.

See https://gitlab.freedesktop.org/gstreamer/gstreamer-sharp/issues/31
2021-01-24 19:55:17 +01:00
..
AbiField.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
AbiStruct.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
AbiStructExtensions.cs AbiStructExtension.BaseOverride: introduce an Extension to find the first overriden method in a base-class, even if a overriden class doesn't override the base class & change to GapiCodegen to use this extension 2020-04-06 22:31:10 +02:00
Argv.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Bytes.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Cond.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
ConnectBeforeAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Date.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
DateTime.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
DefaultSignalHandlerAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
DestroyNotify.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
ExceptionManager.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
FileUtils.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
GException.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
GInterfaceAdapter.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
GInterfaceAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
GLibSharp-api.xml Improve library loading code 2019-11-04 21:02:36 +01:00
GLibSharp.csproj Revert "Sign the DLL files" 2020-08-07 13:30:09 +02:00
GLibSharp.SourceDummyMarshalNative.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
GLibSharp.SourceFuncNative.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
GLibSynchronizationContext.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Global.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
GString.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
GType.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
GTypeAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
HookList.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Idle.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
InitiallyUnowned.cs Ensure to sink floating references passed unowned to GetObject() and to not increase their reference count 2021-01-24 19:55:17 +01:00
IOChannel.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
IWrapper.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
KeyFile.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
List.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
ListBase.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Log.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
MainContext.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
MainLoop.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
ManagedValue.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Markup.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
MarkupParser.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Marshaller.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
MissingIntPtrCtorException.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Mutex.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
NotifyHandler.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Object.cs Ensure to sink floating references passed unowned to GetObject() and to not increase their reference count 2021-01-24 19:55:17 +01:00
ObjectManager.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Opaque.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
ParamSpec.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
PollFD.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Priority.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
PropertyAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
PtrArray.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
RecMutex.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Signal.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
SignalArgs.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
SignalAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
SignalClosure.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
SList.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Source.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
SourceCallbackFuncs.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
SourceDummyMarshal.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
SourceFunc.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
SourceFuncs.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Spawn.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
Thread.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Timeout.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
TimeVal.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
TimeZone.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
ToggleRef.cs Revert "Attempt minimal changes to obtain proper disposing." 2021-01-24 19:55:17 +01:00
TypeFundamentals.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
TypeInitializerAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
TypeNameAttribute.cs Fix file permissions, how did this happen? 2018-02-26 23:03:31 +01:00
Value.cs Use correct GType for GLib.InitiallyUnowned 2021-01-24 19:55:17 +01:00
ValueArray.cs ValueArray: Create copy when receiving pointer 2021-01-24 19:55:17 +01:00
Variant.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00
VariantType.cs Fixtures: added UnmanagedFunctionPointer to whole delegate calls collection to prevent stack incosistence exception for x86 apllications on windows. 2019-11-04 20:12:50 +01:00