apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: Crash in UploadWizard when one is cancelled using alertDialog and then another is removed using the cross button on top thumbnail

Open ShashwatKedia opened this issue 4 months ago • 0 comments

Summary

App crashes when removing an image using the x button on the top thumbnail, after cancelling an image using the alert dialog. Introduced by #5636

Steps to reproduce

  1. Start a multi-image upload with images that would have some problems (such as already on commons, downloaded from the internet, etc.)
  2. When the alert dialog is shown that the image has a problem, click on the 'Cancel Upload' button
  3. After the image is cancelled, click on the remove button (x) on the top thumbnail of the following image

Expected behaviour

App should not crash and safely remove the required image from the upload wizard

Actual behaviour

App crashes

Device name

OnePlus Nord CE 2 Lite

Android version

Android 12

Commons app version

main branch

Device logs

FATAL EXCEPTION: main Process: fr.free.nrw.commons, PID: 12705 java.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 2 at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) at java.util.Objects.checkIndex(Objects.java:359) at java.util.ArrayList.get(ArrayList.java:434) at fr.free.nrw.commons.upload.UploadPresenter.deletePictureAtIndex(UploadPresenter.java:162) at fr.free.nrw.commons.upload.UploadActivity.onThumbnailDeleted(UploadActivity.java:837) at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder.lambda$bind$0$fr-free-nrw-commons-upload-ThumbnailsAdapter$ViewHolder(ThumbnailsAdapter.java:119) at fr.free.nrw.commons.upload.ThumbnailsAdapter$ViewHolder$$ExternalSyntheticLambda0.onClick(Unknown Source:4) at android.view.View.performClick(View.java:7488) at android.view.View.performClickInternal(View.java:7464) at android.view.View.access$3700(View.java:841) at android.view.View$PerformClick.run(View.java:28900) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:233) at android.os.Looper.loop(Looper.java:344) at android.app.ActivityThread.main(ActivityThread.java:8191) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034)

Screen-shots

Screencast:

https://github.com/commons-app/apps-android-commons/assets/142137555/46caddab-890c-43b4-9483-258049182578

Would you like to work on the issue?

None

ShashwatKedia avatar Mar 30 '24 10:03 ShashwatKedia