-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MSVC warning fix #4867
MSVC warning fix #4867
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. How much effort would it be to contribute the libshout related changed upstream?
@@ -458,7 +458,7 @@ void SeratoBeatGrid::setBeats(BeatsPointer pBeats, | |||
} | |||
} | |||
|
|||
nonTerminalMarkers.reserve(markers.size()); | |||
nonTerminalMarkers.reserve(static_cast<int>(markers.size())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonTerminalMarkers.reserve(static_cast<int>(markers.size())); | |
nonTerminalMarkers.reserve(static_cast<qsizetype>(markers.size())); |
To remain warning free with Qt6.
Please be careful in general when casting size-related types to int
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonTerminalMarkers is a QList in Qt5 it has reserve(int alloc)
A qsizetype cast is a std::ptrdiff_t in Qt5 and Qt6 so the proposed change will become a lossy operation in Qt5.
So for now the current solution works warning free.
We may consider to introduce a type that is qsizetype in Qt 6 and int in Qt 5 to make it correct. But IMHO there is no technical need and that will be surprising cast for all new contributors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhmm yeah, thats unfortunate. Those warnings will come back for Qt6 though since there reserve
takes a qsizetype
(I was hoping it was just int
on Qt5). Introducing ifdefs everywhere is also bad. I guess its better to have a widening conversion than narrowing... so I guess we can keep int
.
We need to do that on the main branch of libshout, since we are using an old version and the idjc fork, it is not directly beneficial. But maybe I feel lucky to do it ... |
Mhmm ok, no worries. Just figured I'd ask. |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM
@Swiftb0y Can this be merged? |
Yep, wanted to give others a chance to comment too. |
This fixes a couple of warnings that are generated by MSVC. See commit messages.