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

introduce CoreServices to decouple backend from QWidgets #3446

Merged
merged 11 commits into from
Dec 14, 2020

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Dec 14, 2020

This is a prerequisite for using a QQuickWindow (or QOpenGLWindow) as Mixxx's GUI.

Inspired by #941.

TODO:

  • cleanup sloppy usage of std::shared_ptr::get

Comment on lines +193 to +203
// Create effect backends. We do this after creating EngineMaster to allow
// effect backends to refer to controls that are produced by the engine.
BuiltInBackend* pBuiltInBackend = new BuiltInBackend(m_pEffectsManager.get());
m_pEffectsManager->addEffectsBackend(pBuiltInBackend);
#ifdef __LILV__
m_pLV2Backend = new LV2Backend(m_pEffectsManager.get());
// EffectsManager takes ownership
m_pEffectsManager->addEffectsBackend(m_pLV2Backend);
#else
m_pLV2Backend = nullptr;
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this mess is cleaned up in #2618

@@ -1489,15 +932,19 @@ void MixxxMainWindow::rebootMixxxView() {
}

bool MixxxMainWindow::loadConfiguredSkin() {
// TODO: use std::shared_ptr throughout skin widgets instead of these hacky get() calls
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would require changes in tons of files throughout the GUI code. Let's leave it for another PR.

@Be-ing
Copy link
Contributor Author

Be-ing commented Dec 14, 2020

Please review and merge quickly. This changes lots of files and will develop merge conflicts quickly.

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

How about using typedefs for all thosee pointer types instead of scattering std::shared_ptr everywhere in the code?

src/coreservices.h Outdated Show resolved Hide resolved
@uklotzde
Copy link
Contributor

Thank you for taking over! I agree that we should reduce the changes in this initial step to a bar minimum. Just split the classes and hand out managed pointers.

@Be-ing
Copy link
Contributor Author

Be-ing commented Dec 14, 2020

How about using typedefs for all thosee pointer types instead of scattering std::shared_ptr everywhere in the code?

I'm not really a fan of this pattern. If the number of characters in the type name are a concern, I'd rather use using namespace std than typedef everything.

@uklotzde
Copy link
Contributor

How about using typedefs for all thosee pointer types instead of scattering std::shared_ptr everywhere in the code?

I'm not really a fan of this pattern. If the number of characters in the type name are a concern, I'd rather use using namespace std than typedef everything.

Ok, I also don't have a strong opinion about this. std::shared_ptr<ClassName> is transparent and unambiguous.

@Be-ing Be-ing force-pushed the init_refactor branch 4 times, most recently from 6875322 to 528053c Compare December 14, 2020 21:26
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.

Some comments.

#include "preferences/dlgpreferencepage.h"
#include "preferences/settingsmanager.h"
#include "preferences/usersettings.h"
Copy link
Member

Choose a reason for hiding this comment

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

Forward declaration of
class DlgPrefController;
below is not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please don't ask me to change code I did not touch. I am keeping this PR as small as possible to get it merged ASAP.

Copy link
Member

Choose a reason for hiding this comment

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

OK. I don't mind. But it is only a matter of removing a line.

src/preferences/dialog/dlgpreferences.cpp Outdated Show resolved Hide resolved
src/coreservices.h Show resolved Hide resolved
src/mixxx.cpp Outdated

for (int i = 0; i < kAuxiliaryCount; ++i) {
m_pPlayerManager->addAuxiliary();
for (const auto& group : m_pCoreServices->getPlayerManager()->getVisualPlayerGroups()) {
Copy link
Member

Choose a reason for hiding this comment

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

We should at least assert if these rows of pointers is not null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what you mean. This is a QStringList that is being iterated.

Copy link
Member

Choose a reason for hiding this comment

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

Can you replace auto with QString to make that obvious?

Copy link
Member

Choose a reason for hiding this comment

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

Good Idea.

I meant original:
DEBUG_ASSERT(m_pCoreServices && m_pCoreServices->getPlayerManager())

Copy link
Contributor

@uklotzde uklotzde Dec 14, 2020

Choose a reason for hiding this comment

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

Please don't suggest to combine multiple asserts with &&. Use separate statements instead. Ok, maybe a special case here. Still not recommended.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay
6fee01f

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asserting that m_pCoreServices isn't null would be pointless. The application would have crashed before that if it was.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, so the assert can be placed at the very beginning of the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems superfluous, but okay, done:
2b1eb59

@Be-ing
Copy link
Contributor Author

Be-ing commented Dec 14, 2020

I don't know how to deal with this clazy error:

Error: /home/runner/work/mixxx/mixxx/src/mixxx.cpp:123:5: error: c++11 range-loop might detach Qt container (QStringList) [-Wclazy-range-loop]
    for (const auto& group : m_pCoreServices->getPlayerManager()->getVisualPlayerGroups()) {
    ^

Neither std::as_const nor qAsConst work with QStringList

@uklotzde
Copy link
Contributor

I don't know how to deal with this clazy error:

Error: /home/runner/work/mixxx/mixxx/src/mixxx.cpp:123:5: error: c++11 range-loop might detach Qt container (QStringList) [-Wclazy-range-loop]
    for (const auto& group : m_pCoreServices->getPlayerManager()->getVisualPlayerGroups()) {
    ^

Neither std::as_const nor qAsConst work with QStringList

I remember that Jan introduced temporary variables for these cases.

@Be-ing
Copy link
Contributor Author

Be-ing commented Dec 14, 2020

CI passed. Merge?

@uklotzde
Copy link
Contributor

LGTM

@uklotzde uklotzde merged commit 3c9435d into mixxxdj:main Dec 14, 2020
@Be-ing
Copy link
Contributor Author

Be-ing commented Dec 14, 2020

Thanks everyone for being quick with this review so it actually got merged without building up tons of conflicts.

@Be-ing Be-ing deleted the init_refactor branch December 14, 2020 23:45
@Be-ing Be-ing mentioned this pull request Dec 15, 2020
@uklotzde
Copy link
Contributor

Another bug appeared: Tool tips are now enabled on every restart. Anyone else experiences that?

std::shared_ptr<RecordingManager> getRecordingManager() const {
return m_pRecordingManager;
}

Copy link

@jospezial jospezial Jan 3, 2021

Choose a reason for hiding this comment

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

I think it needs #ifdef __BROADCAST__
with -DBROADCAST=off:
In file included from /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/mixxx.h:8,
from /var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/mixxx.cpp:1:
/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/coreservices.h: In member function ‘std::shared_ptr mixxx::CoreServices::getBroadcastManager() const’:
/var/tmp/portage/media-sound/mixxx-9999/work/mixxx-9999/src/coreservices.h:64:16: error: ‘m_pBroadcastManager’ was not declared in this scope; did you mean ‘getBroadcastManager’?
64 | return m_pBroadcastManager;
| ^~~~~~~~~~~~~~~~~~~
| getBroadcastManager

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Right, I will take care.

Copy link
Member

Choose a reason for hiding this comment

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

@ywwg
Copy link
Member

ywwg commented Feb 20, 2021

It looks like this PR is the source of a bunch of regressions, is there a plan to fix them?

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 20, 2021

What are they?

@ronso0
Copy link
Member

ronso0 commented Feb 20, 2021

tooltips visibility & vinyl lead-in time not saved, a few skin COs not available for controllers

snue added a commit to snue/mixxx that referenced this pull request Jun 23, 2022
The settings restoration is currently done in the preferences
dialog. This was dropped accidentally with the introduction of
coreservices in mixxxdj#3446.
Strictly speaking it would be cleaner to not rely on a temporary
widget here. For now this enures modplug tracker files can be
loaded and play correctly after application startup.
snue added a commit to snue/mixxx that referenced this pull request Jun 23, 2022
The settings restoration is currently done in the preferences
dialog. This was dropped accidentally with the introduction of
coreservices in mixxxdj#3446.
Strictly speaking it would be cleaner to not rely on a temporary
widget here. For now this enures modplug tracker files can be
loaded and play correctly after application startup.
snue added a commit to snue/mixxx that referenced this pull request Jun 23, 2022
The settings restoration is currently done in the preferences
dialog. This was dropped accidentally with the introduction of
coreservices in mixxxdj#3446.
Strictly speaking it would be cleaner to not rely on a temporary
widget here. For now this enures modplug tracker files can be
loaded and play correctly after application startup.
napaalm pushed a commit to napaalm/mixxx that referenced this pull request Mar 24, 2023
introduce CoreServices to decouple backend from QWidgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants