Bug 6418 - IconView GetPathAtPos GetItemAtPos Cause Access Violations on Windows
Summary: IconView GetPathAtPos GetItemAtPos Cause Access Violations on Windows
Status: NEW
Alias: None
Product: Gtk#
Classification: Mono
Component: gtk-sharp ()
Version: 2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-08-06 09:49 UTC by Gary____
Modified: 2012-08-07 12:43 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 6418 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Gary____ 2012-08-06 09:49:23 UTC
I have implemented the QueryTooltip handler on an IconView for my MD addin. The handler calls GetItemAtPos to check if the mouse is hovering over an entry. This works fine on Linux Mint, but on running the addin on my windows 7 64bit (GtkSharp 2.12, MD machine a stream of TargetInvocationException errors is produced on moving the mouse over the iconview. The error is only shown if no entry is below the mouse, in the condition where the method should simply return false. 

I set entriesIV.QueryTooltip += tooltipHandler; in the constructor of my widget, then later in the class I have:

void tooltipHandler (object o, QueryTooltipArgs args)
	CellRenderer cell = null;
	TreePath path = null;
	bool found = entriesIV.GetItemAtPos (args.X, args.Y, out path, out cell);

	if (!found) {
		args.RetVal = false;

	TreeIter iter = TreeIter.Zero;
	store.GetIter (out iter, path);

	ResourceEntry entry = (ResourceEntry) store.GetValue (iter, 0);

	args.Tooltip.Text = entry.Name;
	args.RetVal = true;

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at GLib.GType.GetQualifiedName(String cname)
   at GLib.GType.LookupType(IntPtr typeid)
   at GLib.ObjectManager.GetTypeOrParent(IntPtr obj)
   at GLib.ObjectManager.CreateObject(IntPtr raw)
   at GLib.Object.GetObject(IntPtr o, Boolean owned_ref)
   at GLib.Object.GetObject(IntPtr o)
   at Gtk.IconView.GetItemAtPos(Int32 x, Int32 y, TreePath& path, CellRenderer& cell)
   at MonoDevelop.NETResources.ResXObjectIconWidget.tooltipHandler(Object o, QueryTooltipArgs args) in c:\Program Files (x86)\MonoDevelop\NETResources\NETResources\ResXObjectIconWidget.cs:line 146
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.Invoke(ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)

Alternative Method
Changing to use GetPathAtPos instead of GetItemAtPos results in the tooltips working fine for 30+ seconds and then MD crashes with the following error in output (the error is not displayed by MD in a popup this time):

Alternative Error
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at MonoDevelop.Ide.IdeApp.Run()
   at MonoDevelop.Ide.IdeStartup.Run(MonoDevelopOptions options)
   at MonoDevelop.Ide.IdeStartup.Main(String[] args)
   at MonoDevelop.Startup.MonoDevelopMain.Main(String[] args)
The application exited with code: -1073741819

Additional Info
I cannot catch either error. The reason im using QueryTooltip handler is to be able to set the tooltip text with only having the model object stored in the ListStore (ie cant set a column number to grab the text from). I supplied pixbuf and text CellRenderers with associated datafuncs for the icon and label. If there's a better way id be glad to hear it.