Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Generate static callbacks #208

Merged
merged 24 commits into from
Dec 13, 2017
Merged

Conversation

Therzok
Copy link
Contributor

@Therzok Therzok commented Jun 17, 2017

No description provided.

@Therzok Therzok changed the title Generate static callbacks [DO NOT MERGE]Generate static callbacks Jun 17, 2017
@Therzok Therzok force-pushed the generate-static-callbacks branch 5 times, most recently from 0caa8fd to 367262d Compare June 17, 2017 16:57
@Therzok Therzok changed the title [DO NOT MERGE]Generate static callbacks Generate static callbacks Jun 17, 2017
@Therzok Therzok force-pushed the generate-static-callbacks branch 5 times, most recently from c34e822 to c61521b Compare June 17, 2017 20:15
@Therzok
Copy link
Contributor Author

Therzok commented Dec 9, 2017

@Therzok
Copy link
Contributor Author

Therzok commented Dec 9, 2017

@Therzok
Copy link
Contributor Author

Therzok commented Dec 9, 2017

@Therzok
Copy link
Contributor Author

Therzok commented Dec 9, 2017

@Therzok
Copy link
Contributor Author

Therzok commented Dec 9, 2017

The PR should be ready now.

@Therzok
Copy link
Contributor Author

Therzok commented Dec 9, 2017

Final diff:
https://gist.github.com/Therzok/b158ce4dd70ed3bd35120812dd80de3b
142 files changed, 670 insertions(+), 5743 deletions(-)

@Therzok
Copy link
Contributor Author

Therzok commented Dec 11, 2017

Last version:
https://gist.github.com/Therzok/92cf083b3e1157fa9f2a197e189648e7
144 files changed, 666 insertions(+), 5462 deletions(-)

func_list.Add (func_wrapper);
gdk_display_add_client_message_filter (Handle, message_type == null ? IntPtr.Zero : message_type.Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
var gch = GCHandle.Alloc (func);
gdk_display_add_client_message_filter (Handle, message_type == null ? IntPtr.Zero : message_type.Handle, GdkSharp.FilterFuncWrapper.NativeDelegate, (IntPtr)gch);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment that this leaks forever and that there is no gdk_display_remove_client_message_filter to allow cleanup to happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Therzok
Copy link
Contributor Author

Therzok commented Dec 12, 2017

https://gist.github.com/Therzok/7c79efe0f070277f35c19ef44b9cd770

Latest diff
144 files changed, 1001 insertions(+), 5650 deletions(-)

hash.Remove (function);
gdk_window_remove_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
gdk_window_remove_filter (Handle, GdkSharp.FilterFuncWrapper.NativeDelegate, (IntPtr)gch);
gch.Free();
}

#if MANLY_ENOUGH_TO_INCLUDE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, noticed it too

glade/XML.custom Outdated
}

gch = GCHandle.Alloc (value);
glade_set_custom_handler(GladeSharp.XMLCustomWidgetHandlerWrapper.NativeDelegate, (IntPtr)gch);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to set callback_wrapper? It'll always be null here, right? Should this be changed to:

- static Glade.XMLCustomWidgetHandler callback_wrapper = null;
...
...
if (gch.IsAllocated)
    gch.Free ();

Copy link
Contributor Author

@Therzok Therzok Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gch.IsAllocated only works after alloc/free, afaik, not with empty gchandle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -68,7 +68,7 @@
IntPtr[] native_types = new IntPtr [types.Length];
for (int i = 0; i < types.Length; i++)
native_types [i] = types [i].Val;
GCHandle gch = GCHandle.Alloc (func);
GCHandle gch = func != null ? GCHandle.Alloc (func) : (GCHandle)IntPtr.Zero;
gtk_tree_model_filter_set_modify_func (Handle, n_columns, native_types, GtkSharp.TreeModelFilterModifyFuncWrapper.NativeDelegate, (IntPtr) gch, GLib.DestroyHelper.NotifyHandler);
Copy link
Member

@alanmcgovern alanmcgovern Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to pass a null destroy callback when func is null? It'd be consistent with everything else if we passed a null destroy callback when the func is null, but not a big deal

Copy link
Member

@alanmcgovern alanmcgovern Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there a particular reason why we want to keep passing GtkSharp.TreeModelFilterModifyFuncWrapper.NativeDelegate to native when the func is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DestroyNotify handles null gchandle, so we're ok:

static void ReleaseGCHandle (IntPtr data)
		{
			if (data == IntPtr.Zero)
				return;
			GCHandle gch = (GCHandle) data;
			gch.Free ();
		}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, maybe not. I can send in null. This was custom bound, didn't verify integrity of it

@Therzok Therzok merged commit ada71f5 into gtk-sharp-2-12-branch Dec 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants