fix to potential crash when reloading database
This commit is contained in:
@@ -475,22 +475,26 @@ namespace keepass2android
|
|||||||
|
|
||||||
builder.SetMessage(activity.GetString(Resource.String.AskReloadFile));
|
builder.SetMessage(activity.GetString(Resource.String.AskReloadFile));
|
||||||
|
|
||||||
builder.SetPositiveButton(activity.GetString(Android.Resource.String.Yes),
|
bool buttonPressed = false;
|
||||||
|
|
||||||
|
builder.SetPositiveButton(activity.GetString(Android.Resource.String.Yes),
|
||||||
(dlgSender, dlgEvt) =>
|
(dlgSender, dlgEvt) =>
|
||||||
{
|
{
|
||||||
|
buttonPressed = true;
|
||||||
CurrentDb.ReloadRequested = true;
|
CurrentDb.ReloadRequested = true;
|
||||||
activity.SetResult(KeePass.ExitReloadDb);
|
activity.SetResult(KeePass.ExitReloadDb);
|
||||||
activity.Finish();
|
activity.Finish();
|
||||||
if (actionOnResult != null)
|
if (actionOnResult != null)
|
||||||
{
|
{
|
||||||
actionOnResult(true);
|
actionOnResult(true);
|
||||||
actionOnResult = null;
|
actionOnResult = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.SetNegativeButton(activity.GetString(Android.Resource.String.No), (dlgSender, dlgEvt) =>
|
builder.SetNegativeButton(activity.GetString(Android.Resource.String.No), (dlgSender, dlgEvt) =>
|
||||||
{
|
{
|
||||||
if (actionOnResult != null)
|
buttonPressed = true;
|
||||||
|
if (actionOnResult != null)
|
||||||
{
|
{
|
||||||
actionOnResult(false);
|
actionOnResult(false);
|
||||||
actionOnResult = null;
|
actionOnResult = null;
|
||||||
@@ -501,10 +505,18 @@ namespace keepass2android
|
|||||||
Dialog dialog = builder.Create();
|
Dialog dialog = builder.Create();
|
||||||
|
|
||||||
dialog.SetOnDismissListener(new Util.DismissListener(() =>
|
dialog.SetOnDismissListener(new Util.DismissListener(() =>
|
||||||
{
|
{
|
||||||
if (actionOnResult != null)
|
//dismiss can be called when we're calling activity.Finish() during button press.
|
||||||
actionOnResult(false);
|
//don't do anything then.
|
||||||
}));
|
if (buttonPressed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (actionOnResult != null)
|
||||||
|
{
|
||||||
|
actionOnResult(false);
|
||||||
|
actionOnResult = null;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
dialog.Show();
|
dialog.Show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,10 +77,15 @@ namespace keepass2android.view
|
|||||||
AddView(gv, lp);
|
AddView(gv, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateView(View gv, PwGroup pw) {
|
private void PopulateView(View gv, PwGroup pw)
|
||||||
|
{
|
||||||
_pwGroup = pw;
|
_pwGroup = pw;
|
||||||
|
Kp2aLog.Log($"Populating group view {_groupBaseActivity.IsFinishing} {pw.Name}");
|
||||||
ImageView iv = (ImageView) gv.FindViewById(Resource.Id.icon);
|
|
||||||
|
if (_groupBaseActivity.IsFinishing)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImageView iv = (ImageView) gv.FindViewById(Resource.Id.icon);
|
||||||
Database db = App.Kp2a.FindDatabaseForElement(pw);
|
Database db = App.Kp2a.FindDatabaseForElement(pw);
|
||||||
db.DrawableFactory.AssignDrawableTo(iv, _groupBaseActivity, db.KpDatabase, pw.IconId, pw.CustomIconUuid, true);
|
db.DrawableFactory.AssignDrawableTo(iv, _groupBaseActivity, db.KpDatabase, pw.IconId, pw.CustomIconUuid, true);
|
||||||
gv.FindViewById(Resource.Id.icon).Visibility = ViewStates.Visible;
|
gv.FindViewById(Resource.Id.icon).Visibility = ViewStates.Visible;
|
||||||
|
|||||||
Reference in New Issue
Block a user