Skip to content

Commit

Permalink
fix lateinit crashes in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
schwabe committed Aug 9, 2024
1 parent f64ce22 commit 017fa17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
@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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions main/src/ui/java/de/blinkt/openvpn/fragments/Settings_IP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 017fa17

Please sign in to comment.