Re: Possible bug in gdk_window_get_device_position ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The device value was not NULL when the crash occured, I checked.

There are also similar crashes in gdk_device_warp(),
gdk_device_get_position(), and gdk_device_get_window_at_position().


I also tested with code like:

GdkDeviceManager *devman=gdk_display_get_device_manager(disp);
GList *devlist=gdk_device_manager_list_devices(devman,GDK_DEVICE_TYPE_MASTER);

...

	for (k=0;k<g_list_length(devlist);k++) {
	  GdkDevice *device=(GdkDevice *)g_list_nth_data(devlist,k);
	  if (gdk_device_get_display(device)==disp&&
	      gdk_device_get_source(device)==GDK_SOURCE_MOUSE)
	    mouse_device=device;
	}

If I use mouse_device then it also works.



Regards,
Salsaman.


http://lives.sourceforge.net
https://www.ohloh.net/accounts/salsaman


On Sat, Feb 16, 2013 at 2:53 AM, Lex Trotman <elextr@xxxxxxxxx> wrote:
> On 16 February 2013 16:07, salsaman <salsaman@xxxxxxxxx> wrote:
>> Hi,
>> with gtk 3.4.4 I get a crash with code like:
>>
>> gboolean button_callback (GtkWidget *widget, GdkEventButton *event,
>> gpointer user_data) {
>>   gint x,y;
>>   GdkWindow *xwin=gtk_widget_get_window(widget);
>>   GdkDevice *device=gdk_event_get_source_device((GdkEvent *)event);
>
> Which IIRC can return NULL, so you will crash in those situations,
> test your return values :)
>
>>   gdk_window_get_device_position (xwin,device,&x,&y,NULL);  // crash !!
>>
>> }
>>
>> There is not even a stack trace, it just instantly quits the app.
>>
>>
>> However, if I replace:
>>
>> GdkDevice *device=gdk_event_get_source_device((GdkEvent *)event);
>>
>> with:
>>
>> GdkDeviceManager *device_manager =
>> gdk_display_get_device_manager(gdk_window_get_display(xwin));
>> GdkDevice *device = gdk_device_manager_get_client_pointer (device_manager);
>
> This doesn't return NULL because it always can find a display.
>
>>
>> then there is no crash. Is this a bug ?
>>
>> In the documentation for gdk_device_manager_get_client_pointer(), it says:
>> "You should use this function sheldomly (sic), only in code that isn't
>> triggered by a GdkEvent..."
>
> Well, it works in the situation you happened to use it in, but that
> doesn't guarantee it works in all situations.  For the documentation
> to warn you not to use it, there only needs to be one situation in
> which it fails.
>
>>
>> http://developer.gnome.org/gdk3/stable/GdkDeviceManager.html#gdk-device-manager-get-client-pointer
>>
>>
>> If it is not a bug then the documentation is somewhat misleading.
>
>
> It would be a bug and the documentation misleading if it worked in all
> circumstances and was guaranteed by the developers that it would keep
> doing so.  Neither of those conditions is known to be true.
>
> Cheers
> Lex
>
>>
>>
>>
>> Regards,
>> Salsaman.
>>
>>
>> http://lives.sourceforge.net
>> https://www.ohloh.net/accounts/salsaman
>> _______________________________________________
>> gtk-list mailing list
>> gtk-list@xxxxxxxxx
>> https://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux