[geary/wip/validator-fixes: 2/2] Fix NetworkAddressValidator not updating port number
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/validator-fixes: 2/2] Fix NetworkAddressValidator not updating port number
- Date: Wed, 6 Mar 2019 07:40:24 +0000 (UTC)
commit 7dc07bdad61c692b210323cdc462192b09d715c0
Author: Michael Gratton <mike vee net>
Date: Wed Mar 6 18:38:44 2019 +1100
Fix NetworkAddressValidator not updating port number
Ensure the validated address is updated even if we know it is valid,
since the port number may have changed.
Fixes #294
src/client/components/components-validator.vala | 51 ++++++++++++++-----------
1 file changed, 28 insertions(+), 23 deletions(-)
---
diff --git a/src/client/components/components-validator.vala b/src/client/components/components-validator.vala
index 257d8195..199751cd 100644
--- a/src/client/components/components-validator.vala
+++ b/src/client/components/components-validator.vala
@@ -453,30 +453,35 @@ public class Components.NetworkAddressValidator : Validator {
debug("Error parsing host name \"%s\": %s", value, err.message);
}
- // Only re-validate if previously invalid or the host has
- // changed
- if (address != null && (
- this.validated_address == null ||
- this.validated_address.hostname != address.hostname)) {
- this.cancellable = new GLib.Cancellable();
- this.resolver.lookup_by_name_async.begin(
- address.hostname, this.cancellable,
- (obj, res) => {
- try {
- this.resolver.lookup_by_name_async.end(res);
- this.validated_address = address;
- update_state(Validator.Validity.VALID, reason);
- } catch (GLib.IOError.CANCELLED err) {
- this.validated_address = null;
- } catch (GLib.Error err) {
- this.validated_address = null;
- update_state(Validator.Validity.INVALID, reason);
+ if (address != null) {
+ // Re-validate if previously invalid or the host has
+ // changed
+ if (this.validated_address == null ||
+ this.validated_address.hostname != address.hostname) {
+ this.cancellable = new GLib.Cancellable();
+ this.resolver.lookup_by_name_async.begin(
+ address.hostname, this.cancellable,
+ (obj, res) => {
+ try {
+ this.resolver.lookup_by_name_async.end(res);
+ this.validated_address = address;
+ update_state(Validator.Validity.VALID, reason);
+ } catch (GLib.IOError.CANCELLED err) {
+ this.validated_address = null;
+ } catch (GLib.Error err) {
+ this.validated_address = null;
+ update_state(Validator.Validity.INVALID, reason);
+ }
+ this.cancellable = null;
}
- this.cancellable = null;
- }
- );
-
- ret = Validator.Validity.IN_PROGRESS;
+ );
+ ret = Validator.Validity.IN_PROGRESS;
+ } else {
+ // Update the validated address in case the port
+ // number is being edited and has changed
+ this.validated_address = address;
+ ret = Validator.Validity.VALID;
+ }
}
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]