network: fix editing connections without a device
For example, fix adding new VPN connections.
In 60b4956c05
I correctly observed that we
need to not run code that requires a device when there is no device.
NetConnectionEditor is a multipurpose dialog and self->device is
optional when creating the dialog. E.g. when modifying VPN
configuration, we update just the configuration, not an NMDevice.
However, I added this check too soon, before updating the connection
configuration. We need to update the configuration first, then only bail
before proceeding to update the device, not sooner.
Fix #2668
This commit is contained in:
parent
2397db38c3
commit
6219cbdca5
1 changed files with 13 additions and 8 deletions
|
@ -240,6 +240,12 @@ updated_connection_cb (GObject *source_object,
|
|||
|
||||
nm_connection_clear_secrets (NM_CONNECTION (source_object));
|
||||
|
||||
if (!self->device) {
|
||||
update_complete (self, TRUE);
|
||||
g_object_unref (self);
|
||||
return;
|
||||
}
|
||||
|
||||
nm_device_reapply_async (self->device, NM_CONNECTION (self->orig_connection),
|
||||
0, 0, NULL, device_reapply_cb, self /* owned */);
|
||||
}
|
||||
|
@ -251,12 +257,16 @@ added_connection_cb (GObject *source_object,
|
|||
{
|
||||
NetConnectionEditor *self = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (!nm_client_add_connection_finish (NM_CLIENT (source_object), res, &error)) {
|
||||
g_warning ("Failed to add connection: %s", error->message);
|
||||
success = FALSE;
|
||||
update_complete (self, success);
|
||||
update_complete (self, FALSE);
|
||||
g_object_unref (self);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self->device) {
|
||||
update_complete (self, TRUE);
|
||||
g_object_unref (self);
|
||||
return;
|
||||
}
|
||||
|
@ -272,11 +282,6 @@ apply_clicked_cb (NetConnectionEditor *self)
|
|||
|
||||
eap_method_ca_cert_ignore_save (self->connection);
|
||||
|
||||
if (!self->device) {
|
||||
update_complete (self, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->is_new_connection) {
|
||||
nm_client_add_connection_async (self->client,
|
||||
self->orig_connection,
|
||||
|
|
Loading…
Add table
Reference in a new issue