- if (monitor != NULL)
- g_signal_connect (monitor, "changed",
- (GCallback) dir_monitor_callback, NULL);
- else
- report_file_error ("Cannot watch file", Fcons (file, Qnil));
+ if (! monitor)
+ xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
+
+ /* On all known glib platforms, converting MONITOR directly to a
+ Lisp_Object value results is a Lisp integer, which is safe. This
+ assumption is dicey, though, so check it now. */
+ watch_descriptor = XIL ((intptr_t) monitor);
+ if (! INTEGERP (watch_descriptor))
+ {
+ g_object_unref (monitor);
+ xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
+ file);
+ }
+
+ g_signal_connect (monitor, "changed",
+ (GCallback) dir_monitor_callback, NULL);