~ubuntu-branches/debian/jessie/glib2.0/jessie

« back to all changes in this revision

Viewing changes to gio/gfilemonitor.c

Tags: upstream-2.16.1
Import upstream version 2.16.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 * are monitoring, connect to the #GFileMonitor::changed signal.
46
46
 **/
47
47
 
 
48
G_LOCK_DEFINE_STATIC(cancelled);
 
49
 
48
50
enum {
49
51
  CHANGED,
50
52
  LAST_SIGNAL
117
119
      break;
118
120
 
119
121
    case PROP_CANCELLED:
 
122
      G_LOCK (cancelled);
120
123
      g_value_set_boolean (value, priv->cancelled);
 
124
      G_UNLOCK (cancelled);
121
125
      break;
122
126
 
123
127
    default:
165
169
  monitor = G_FILE_MONITOR (object);
166
170
 
167
171
  /* Make sure we cancel on last unref */
168
 
  if (!monitor->priv->cancelled)
169
 
    g_file_monitor_cancel (monitor);
 
172
  g_file_monitor_cancel (monitor);
170
173
  
171
174
  if (G_OBJECT_CLASS (g_file_monitor_parent_class)->dispose)
172
175
    (*G_OBJECT_CLASS (g_file_monitor_parent_class)->dispose) (object);
247
250
g_file_monitor_is_cancelled (GFileMonitor *monitor)
248
251
{
249
252
  g_return_val_if_fail (G_IS_FILE_MONITOR (monitor), FALSE);
 
253
  gboolean res;
250
254
 
251
 
  return monitor->priv->cancelled;
 
255
  G_LOCK (cancelled);
 
256
  res = monitor->priv->cancelled;
 
257
  G_UNLOCK (cancelled);
 
258
  
 
259
  return res;
252
260
}
253
261
 
254
262
/**
266
274
  
267
275
  g_return_val_if_fail (G_IS_FILE_MONITOR (monitor), FALSE);
268
276
  
 
277
  G_LOCK (cancelled);
269
278
  if (monitor->priv->cancelled)
270
 
    return TRUE;
 
279
    {
 
280
      G_UNLOCK (cancelled);
 
281
      return TRUE;
 
282
    }
271
283
  
272
284
  monitor->priv->cancelled = TRUE;
 
285
  G_UNLOCK (cancelled);
 
286
  
273
287
  g_object_notify (G_OBJECT (monitor), "cancelled");
274
288
 
275
289
  klass = G_FILE_MONITOR_GET_CLASS (monitor);
351
365
  source = g_idle_source_new ();
352
366
  g_source_set_priority (source, 0);
353
367
 
354
 
  g_source_set_callback (source, emit_cb, change, file_change_free);
 
368
  g_source_set_callback (source, emit_cb, change, (GDestroyNotify)file_change_free);
355
369
  g_source_attach (source, NULL);
356
370
  g_source_unref (source);
357
371
}