Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when deleting an account with subaccounts under certain conditions #460

Closed
rivaldi8 opened this issue Jan 3, 2016 · 1 comment

Comments

@rivaldi8
Copy link
Collaborator

commented Jan 3, 2016

Deleting an account with subaccounts makes the application crash under certain conditions:

FATAL EXCEPTION: main
 java.lang.IllegalArgumentException: accounts Record ID -9223372036854775808 does not exist in the db
     at org.gnucash.android.db.DatabaseAdapter.getUID(DatabaseAdapter.java:426)
     at org.gnucash.android.ui.account.DeleteAccountDialogFragment$4.onClick(DeleteAccountDialogFragment.java:221)
     at android.view.View.performClick(View.java:2494)
     at android.view.View$PerformClick.run(View.java:9105)
     at android.os.Handler.handleCallback(Handler.java:587)
     at android.os.Handler.dispatchMessage(Handler.java:92)
     at android.os.Looper.loop(Looper.java:130)
     at android.app.ActivityThread.main(ActivityThread.java:3683)
     at java.lang.reflect.Method.invokeNative(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:507)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
     at dalvik.system.NativeStart.main(Native Method)

Steps to reproduce with default accounts:

  1. Enter "Assets" account.
  2. Select "DELETE" from the "Current Assets" account's menu.
  3. Press "Delete".
  4. The application crashes.

The problem is due to the code in mOkButton.setOnClickListener(). The code under the condition mMoveTransactionsRadioButton.isChecked() is always executed, even when there aren't any transactions to move. This happens because, when the layout is loaded, mMoveTransactionsRadioButton is set to checked state.

The concrete condition under which the application crashes is when mTransactionsDestinationAccountSpinner doesn't have any item. Then, the call to mTransactionsDestinationAccountSpinner.getSelectedItemId() returns INVALID_ROW_ID (-9223372036854775808, see javadoc) and accountsDbAdapter.getUID(targetAccountId) fails.

I'm working on a fix.

rivaldi8 added a commit to rivaldi8/gnucash-android that referenced this issue Jan 6, 2016

rivaldi8 added a commit to rivaldi8/gnucash-android that referenced this issue Jan 6, 2016

codinguser added a commit that referenced this issue Jan 6, 2016

Merge pull request #463 from rivaldi8/bugfix-460-crash-on-delete-account
Fix crash when deleting an account with subaccounts under certain conditions
Fixes #460
@rivaldi8

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 8, 2016

Fixed in develop.

@rivaldi8 rivaldi8 closed this Jan 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.