~ubuntu-branches/ubuntu/trusty/gtk+2.0/trusty-updates

« back to all changes in this revision

Viewing changes to gdk/quartz/gdkevents-quartz.c

  • Committer: Package Import Robot
  • Author(s): Vlad Orlov
  • Date: 2015-07-28 10:17:14 UTC
  • Revision ID: package-import@ubuntu.com-20150728101714-rd9msqcb0etcfpsr
Tags: 2.24.23-0ubuntu1.3
* fix_gdk_event_apply_filters.patch: new patch. Makes gdk_event_apply_filters
  function safe against changes in the filter list, prevents weird crashes in
  various apps. (LP: #1351890)
* gdk-Fix-GdkWindowFilter-internal-refcounting.patch,
  gdkwindow-Fix-event-unref-iteration.patch: new patches. Fix refcounting
  errors after fix_gdk_event_apply_filters.patch, prevent crashes in some
  applications like Spotify.

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
static gint
254
254
gdk_event_apply_filters (NSEvent *nsevent,
255
255
                         GdkEvent *event,
256
 
                         GList *filters)
 
256
                         GList **filters)
257
257
{
258
258
  GList *tmp_list;
259
259
  GdkFilterReturn result;
260
260
  
261
 
  tmp_list = filters;
 
261
  tmp_list = *filters;
262
262
 
263
263
  while (tmp_list)
264
264
    {
265
265
      GdkEventFilter *filter = (GdkEventFilter*) tmp_list->data;
266
 
      
 
266
      GList *node;
 
267
 
 
268
      if ((filter->flags & GDK_EVENT_FILTER_REMOVED) != 0)
 
269
        {
 
270
          tmp_list = tmp_list->next;
 
271
          continue;
 
272
        }
 
273
 
 
274
      filter->ref_count++;
 
275
      result = filter->function (nsevent, event, filter->data);
 
276
 
 
277
      /* get the next node after running the function since the
 
278
         function may add or remove a next node */
 
279
      node = tmp_list;
267
280
      tmp_list = tmp_list->next;
268
 
      result = filter->function (nsevent, event, filter->data);
269
 
      if (result !=  GDK_FILTER_CONTINUE)
270
 
        return result;
 
281
 
 
282
      filter->ref_count--;
 
283
      if (filter->ref_count == 0)
 
284
        {
 
285
          *filters = g_list_remove_link (*filters, node);
 
286
          g_list_free_1 (node);
 
287
          g_free (filter);
 
288
        }
 
289
 
 
290
      if (result != GDK_FILTER_CONTINUE)
 
291
        return result;
271
292
    }
272
293
 
273
294
  return GDK_FILTER_CONTINUE;
1319
1340
      /* Apply global filters */
1320
1341
      GdkFilterReturn result;
1321
1342
 
1322
 
      result = gdk_event_apply_filters (nsevent, event, _gdk_default_filters);
 
1343
      result = gdk_event_apply_filters (nsevent, event, &_gdk_default_filters);
1323
1344
      if (result != GDK_FILTER_CONTINUE)
1324
1345
        {
1325
1346
          return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
1390
1411
      GdkFilterReturn result;
1391
1412
 
1392
1413
      if (filter_private->filters)
1393
 
        {
1394
 
          g_object_ref (window);
1395
 
 
1396
 
          result = gdk_event_apply_filters (nsevent, event, filter_private->filters);
1397
 
 
1398
 
          g_object_unref (window);
1399
 
 
1400
 
          if (result != GDK_FILTER_CONTINUE)
1401
 
            {
1402
 
              return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
1403
 
              goto done;
1404
 
            }
1405
 
        }
 
1414
        {
 
1415
          g_object_ref (window);
 
1416
 
 
1417
          result = gdk_event_apply_filters (nsevent, event, &filter_private->filters);
 
1418
 
 
1419
          g_object_unref (window);
 
1420
 
 
1421
          if (result != GDK_FILTER_CONTINUE)
 
1422
            {
 
1423
              return_val = (result == GDK_FILTER_TRANSLATE) ? TRUE : FALSE;
 
1424
              goto done;
 
1425
            }
 
1426
        }
1406
1427
    }
1407
1428
 
1408
1429
  /* If the app is not active leave the event to AppKit so the window gets