mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 10:42:11 +01:00
Avoid unnecessary work if mount watching not specified (#585360)
If G_FILE_MONITOR_WATCH_MOUNTS isn't specified, don't do all the work when the mtab changes.
This commit is contained in:
parent
4ab9132735
commit
6cf974af38
@ -36,7 +36,8 @@
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_DIRNAME
|
||||
PROP_DIRNAME,
|
||||
PROP_FLAGS
|
||||
};
|
||||
|
||||
static gboolean g_local_directory_monitor_cancel (GFileMonitor *monitor);
|
||||
@ -74,6 +75,9 @@ g_local_directory_monitor_set_property (GObject *object,
|
||||
case PROP_DIRNAME:
|
||||
/* Do nothing */
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
/* Do nothing */
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@ -89,6 +93,7 @@ g_local_directory_monitor_constructor (GType type,
|
||||
GLocalDirectoryMonitorClass *klass;
|
||||
GObjectClass *parent_class;
|
||||
GLocalDirectoryMonitor *local_monitor;
|
||||
GFileMonitorFlags flags = 0;
|
||||
const gchar *dirname = NULL;
|
||||
gint i;
|
||||
|
||||
@ -106,13 +111,19 @@ g_local_directory_monitor_constructor (GType type,
|
||||
{
|
||||
g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value));
|
||||
dirname = g_value_get_string (construct_properties[i].value);
|
||||
break;
|
||||
}
|
||||
if (strcmp ("flags", g_param_spec_get_name (construct_properties[i].pspec)) == 0)
|
||||
{
|
||||
g_warn_if_fail (G_VALUE_HOLDS_FLAGS (construct_properties[i].value));
|
||||
flags = g_value_get_flags (construct_properties[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
local_monitor->dirname = g_strdup (dirname);
|
||||
local_monitor->flags = flags;
|
||||
|
||||
if (!klass->mount_notify)
|
||||
if (!klass->mount_notify &&
|
||||
(flags & G_FILE_MONITOR_WATCH_MOUNTS))
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
/*claim everything was mounted */
|
||||
@ -159,6 +170,16 @@ g_local_directory_monitor_class_init (GLocalDirectoryMonitorClass* klass)
|
||||
G_PARAM_CONSTRUCT_ONLY|
|
||||
G_PARAM_WRITABLE|
|
||||
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_FLAGS,
|
||||
g_param_spec_flags ("flags",
|
||||
P_("Monitor flags"),
|
||||
P_("Monitor flags"),
|
||||
G_TYPE_FILE_MONITOR_FLAGS,
|
||||
0,
|
||||
G_PARAM_CONSTRUCT_ONLY|
|
||||
G_PARAM_WRITABLE|
|
||||
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
|
||||
|
||||
klass->mount_notify = FALSE;
|
||||
}
|
||||
@ -268,7 +289,7 @@ _g_local_directory_monitor_new (const char *dirname,
|
||||
|
||||
monitor = NULL;
|
||||
if (type != G_TYPE_INVALID)
|
||||
monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, NULL));
|
||||
monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, "flags", flags, NULL));
|
||||
else
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
_("Unable to find default local directory monitor type"));
|
||||
|
@ -45,6 +45,7 @@ struct _GLocalDirectoryMonitor
|
||||
GFileMonitor parent_instance;
|
||||
|
||||
gchar *dirname;
|
||||
GFileMonitorFlags flags;
|
||||
/* For mount emulation */
|
||||
GUnixMountMonitor *mount_monitor;
|
||||
gboolean was_mounted;
|
||||
|
Loading…
x
Reference in New Issue
Block a user