Skip to content

(fix) WTrackTableView: assert track model, p prefix - #13623

Merged
daschuer merged 1 commit into
mixxxdj:2.4from
ronso0:tracks-assert-track-model
Sep 15, 2024
Merged

(fix) WTrackTableView: assert track model, p prefix#13623
daschuer merged 1 commit into
mixxxdj:2.4from
ronso0:tracks-assert-track-model

Conversation

@ronso0

@ronso0 ronso0 commented Sep 3, 2024

Copy link
Copy Markdown
Member

followup for #13620
(sorry for the big diff)

I'll take care of merging to 2.5/main

Comment thread src/widget/wtracktableview.cpp
@ronso0
ronso0 force-pushed the tracks-assert-track-model branch from d9562ec to 655f22e Compare September 3, 2024 12:41
Comment thread src/widget/wtracktableview.cpp Outdated
Comment on lines +505 to +508
TrackModel* pTrackModel = getTrackModel();
if (!pTrackModel) {
return;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trackmodel is unused here. Do we really need to check it then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, not directly. But this is called by [Library], show_track_menu, so this is one function a controller could call before we have track model (or just item model).

Tbh I'm not entirely happy with this PR but it's the best / most simple fix I found.
There are two aspects:

  1. verify we have a selectionModel()
    could happen there is none and we want to throw a warning then, eg. it's theoretically_ possible to setSelectionModel(nullptr)
  2. verify we have a model and simply return if there's none
    that's the controller case I mentioned, and (again theoretically) it is possible such functions in other ways before the GUI is ready.
    I think we should not throw an assertion then. Admittedly this only affects builds with DEBUG_ASSERTIONS_FATAL, but nevertheless such assertions are hard to debug.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I can remove it here, since it's in getSelectedRows(), too.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, remove it when getSelectedRows() already takes care of it.

Comment on lines +848 to +846
if (getTrackModel() == nullptr) {
return {};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I installed this as some sort of pre-DEBUG_ASSERT exit in case someone uses getSelectedRows() without verifying there's a model. (see my explanation above)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah keep this one then. Though I'm undecided on whether it should be a debug assert as well...

@ronso0
ronso0 force-pushed the tracks-assert-track-model branch from 655f22e to 6547e76 Compare September 4, 2024 12:21
@ronso0 ronso0 added this to the 2.4.2 milestone Sep 6, 2024

@daschuer daschuer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. LGTM

@daschuer
daschuer merged commit 0b584d2 into mixxxdj:2.4 Sep 15, 2024
@ronso0
ronso0 deleted the tracks-assert-track-model branch September 15, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants