Z-Bolt / OctoScreen

LCD touch interface for our OctoPrint
GNU Affero General Public License v3.0
716 stars 118 forks source link

Fix crash in FilesPanel #345

Closed the-ress closed 1 year ago

the-ress commented 2 years ago

Fixes a crash caused by FilesPanel location history getting empty when it shouldn't.

Repro steps

  1. Remove SD card from printer (if inserted)
  2. Tap Print
  3. Tap the back button
  4. Tap Print again
  5. Tap a gcode file
  6. Press Yes

OctoScreen crashes with "index out of range" at FilesPanel.go, line 444.

JeffB42 commented 1 year ago

@the-ress I tried the repro steps in my 2.8.0-dev branch but wasn't able to reproduce the issue. That's not too surprising though, as I've done a lot of work in this area. I'm thinking of releasing a beta for 2.8.0 b/f I release it. When I post a beta, I'll at-mention you here and see if you can repro the issue.

the-ress commented 1 year ago

I just tried it with current state of 2.8.0-dev (1862d56) and I can still easily reproduce it.

7c26822e-4c32-418c-ada3-91a39b69182d

the-ress commented 1 year ago

~Should I rebase the fix onto the 2.8.0 branch?~ Edit: Changed target do 2.8.0-dev

JeffB42 commented 1 year ago

I'm still not able to reproduce the issue. Here are the steps I'm performing:

  1. Remove SD card from my 3D printer
  2. Turn 3D printer and RPi on
  3. OctoPrint and OctoScreen start up, and this is when I started recording:

https://github.com/Z-Bolt/OctoScreen/assets/10328858/bac067c0-f99b-4ff8-8956-d942b2af8e40

  1. Wait for OctoPrint to start, and OctoScreen to connect to OctoPrint (then get taken to the Idle panel)

  2. Click the Print button (in the Idle panel) (then get taken to the "Select source location" panel)

  3. Click the "OctoPrint" list item (then get taken to the "Select file" panel)

  4. Click the Back button (this takes me back to the "Select source location" panel)

  5. Click the Back button again (this takes me back to the Idle panel)

  6. Click the Print button again (this takes me to the "Select source location" panel)

  7. Click the "OctoPrint" list item (then get taken to the "Select file" panel)

  8. Click the Print icon of the first file that was listed

  9. I'm then prompted to confirm that I want to print, and I click the Yes button

  10. After a pause, I'm taken to the Printing panel.

the-ress commented 1 year ago

The difference is I'm not getting the "Select source location" panel, pressing Print takes me right to "Select file panel" because filesPanel.sdIsReady returns false when I don't insert the SD.

    /*
     * If we are at `root` (display the option for SD AND Local), but SD is not
     * ready, push us up and into Local so the user doesn't have to work harder
     * than they have to.
     */
    if atRootLevel && !this.sdIsReady() {
        atRootLevel = false
        this.locationHistory = utils.LocationHistory {
            Locations: []dataModels.Location{dataModels.Local},
        }
    }
JeffB42 commented 1 year ago

Ahi, got it. Thanks @the-ress , and thanks for the contribution.