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

Refactor/pref sound tab order #11926

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

Swiftb0y
Copy link
Member

@Swiftb0y Swiftb0y commented Sep 6, 2023

Alternative to #11921 along with minor refactorings

@Swiftb0y
Copy link
Member Author

Swiftb0y commented Sep 6, 2023

the outdated compiler on macos is really annoying... lets update it #11927

@daschuer
Copy link
Member

daschuer commented Sep 6, 2023

The original PR was against 2.4. Was the switch to main desired?

@daschuer daschuer changed the base branch from main to 2.4 September 6, 2023 18:51
@Swiftb0y Swiftb0y marked this pull request as draft September 6, 2023 20:16
@Swiftb0y
Copy link
Member Author

Swiftb0y commented Sep 6, 2023

The original PR was against 2.4. Was the switch to main desired?

Yes and no, I forgot to switch away from the default main, on the other hand I'm not sure if all compiler- and language features used are available in 2.4.

@daschuer
Copy link
Member

daschuer commented Sep 6, 2023

It looks like only the <=> operator is not available everywhere, but it is anyway not fully used. If you replace that with operator< it works.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Here some comments.

namespace {

bool soundItemAlreadyExists(const AudioPath& output, const QWidget& widget) {
for (const QObject* obj : widget.children()) {
Copy link
Member

Choose a reason for hiding this comment

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

We use p prefix for pointer and smart pointers.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, forgot to change when copying from previous code

bool soundItemAlreadyExists(const AudioPath& output, const QWidget& widget) {
for (const QObject* obj : widget.children()) {
auto item = qobject_cast<const DlgPrefSoundItem*>(obj);
if (!item || item->type() == output.getType()) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this condition. Is it inverted?
Please add a comment if it is correct.

Copy link
Member Author

@Swiftb0y Swiftb0y Sep 6, 2023

Choose a reason for hiding this comment

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

no, that was a bug thank you. fixed in upcoming commit

}
AudioPathType type = output.getType();
// TODO who owns this?
DlgPrefSoundItem* pSoundItem = AudioPath::isIndexed(type)
Copy link
Member

Choose a reason for hiding this comment

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

Can the conditional go to the last optional argument? The same below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically a little leaky as the caller now knows the default value, but who cares. done.

const AudioPath& rhs) {
// Exclude m_channelGroup from comparison!
// See also: hashValue()/qHash()
// TODO: Why??
Copy link
Member

Choose a reason for hiding this comment

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

Do you have an explanation here?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, it came from the previous code and I didn't bother much into it. likely because m_channelGroup is synthesized or not important for distinguishing instances of the class.


// TODO: remove this ifdef when AppleClang ships a libc++
// implementation with operator<=> for tuples (XCode 14 probably)
#ifdef __APPLE__
Copy link
Member

Choose a reason for hiding this comment

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

Just use operator< for all. The rest of the space ship operator is not used anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, but its bad practice to only define the ordering partially and operator<=> is better than having to define all six ordering overloads manually (especially considering the friend boilerplate).

Copy link
Member Author

Choose a reason for hiding this comment

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

CI passes on all platforms, do you still insist on the manual implementation?

Copy link
Member

Choose a reason for hiding this comment

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

It fails also on Ubuntu Focal unfortunately. It knows nothing about <=>

Right, but its bad practice to only define the ordering partially

It is also bad practice to define unused functions.

So in this case I would just replace <=> by operator< for all and nothing else.
This is IMHO enough and does not clutters the code with #ifdefs for code that is not used anyway.

I will do a PR, for this because you are not able to test it.
You can than use it to remove the Apple conditions in a fixup.

Copy link
Member

Choose a reason for hiding this comment

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

Here it is: Swiftb0y#17 tested and fully working.

@Swiftb0y Swiftb0y force-pushed the refactor/pref-sound-tab-order branch from ded4252 to c468504 Compare September 6, 2023 23:13
@Swiftb0y
Copy link
Member Author

Swiftb0y commented Sep 7, 2023

I believe I've addressed all your review requests. please rereview

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

LGTM, ready for removing Draft state.

@Swiftb0y Swiftb0y force-pushed the refactor/pref-sound-tab-order branch from c468504 to d27dc61 Compare September 7, 2023 22:29
@Swiftb0y Swiftb0y marked this pull request as ready for review September 7, 2023 22:31
@daschuer
Copy link
Member

daschuer commented Sep 8, 2023

Thank you.

@daschuer daschuer merged commit 8dafd29 into mixxxdj:2.4 Sep 8, 2023
11 checks passed
@Swiftb0y
Copy link
Member Author

Swiftb0y commented Sep 8, 2023

Thank you.

@Swiftb0y Swiftb0y deleted the refactor/pref-sound-tab-order branch September 8, 2023 05:32
@ronso0
Copy link
Member

ronso0 commented Sep 8, 2023

Working btw, thanks!

@Swiftb0y
Copy link
Member Author

Swiftb0y commented Sep 8, 2023

Thank you for testing. I didn't test thoroughly tbh, good to know it works.

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