diff options
author | Arne Schwabe <arne@rfc2549.org> | 2024-08-09 16:48:35 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2024-08-09 17:09:53 +0200 |
commit | 017fa17bb823698c02118e95f1fc501f0a12182d (patch) | |
tree | 9188f4f76569629adf4a4dab3cf04c8238566951 /main/src | |
parent | f64ce22ef5d34c7e593b74ebb9197fabd5f616a4 (diff) |
fix lateinit crashes in settings
Diffstat (limited to 'main/src')
3 files changed, 11 insertions, 1 deletions
diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java b/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java index 802e0b49..0b2ebde2 100644 --- a/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java +++ b/main/src/ui/java/de/blinkt/openvpn/fragments/OpenVpnPreferencesFragment.java @@ -52,7 +52,10 @@ public abstract class OpenVpnPreferencesFragment extends PreferenceFragmentCompa @Override public void onSaveInstanceState (Bundle outState) { super.onSaveInstanceState(outState); - saveSettings(); + if (getView() != null) { + //if we have no view, there is no point in trying to save anything. + saveSettings(); + } outState.putString(VpnProfile.EXTRA_PROFILEUUID, mProfile.getUUIDString()); } } diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_Authentication.kt b/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_Authentication.kt index 51a4e2e3..944aa41a 100644 --- a/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_Authentication.kt +++ b/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_Authentication.kt @@ -69,6 +69,9 @@ class Settings_Authentication : OpenVpnPreferencesFragment(), Preference.OnPrefe } override fun loadSettings() { + if (!this::mExpectTLSCert.isInitialized) { + return; + } mExpectTLSCert.isChecked = mProfile.mExpectTLSCert mCheckRemoteCN.isChecked = mProfile.mCheckRemoteCN mRemoteCN.setDN(mProfile.mRemoteCN) diff --git a/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt b/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt index ef69f3f4..fef4861b 100644 --- a/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt +++ b/main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt @@ -66,6 +66,10 @@ class Settings_IP : OpenVpnPreferencesFragment(), Preference.OnPreferenceChangeL override fun loadSettings() { + // Since we maybe not have preferences bound yet, check if we actually have them bound. + if (!this::mUsePull.isInitialized) { + return; + } if (mProfile.mAuthenticationType == VpnProfile.TYPE_STATICKEYS) mUsePull.isEnabled = false else mUsePull.isChecked = mProfile.mUsePull mIPv4.text = mProfile.mIPv4Address |