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

Cover Art Copy Worker #10902

Merged
merged 18 commits into from
Oct 5, 2022
Merged

Cover Art Copy Worker #10902

merged 18 commits into from
Oct 5, 2022

Conversation

fatihemreyildiz
Copy link
Contributor

As I mentioned earlier on #4887 , this is the basic of the cover art copy worker.

We need it for to have a cover art fetcher #4851 .

Technical details of this PR is, it only works for 'JPG' extension for now and the copying process is default. The rest detailed version of this worker will be improved on #4887 . Such as preferences and comparison page.

For now it looks like this:

coverartcopyworker

src/library/export/coverartcopywizard.h Outdated Show resolved Hide resolved
src/library/export/coverartcopywizard.h Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.cpp Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.cpp Outdated Show resolved Hide resolved
src/library/export/coverartsaver.h Outdated Show resolved Hide resolved
@fatihemreyildiz
Copy link
Contributor Author

Thank you for the review.

@daschuer
Copy link
Member

There are some clazy complains.

src/util/imagefiledata.h Outdated Show resolved Hide resolved
src/util/imagefiledata.h Outdated Show resolved Hide resolved
src/util/imagefiledata.h Outdated Show resolved Hide resolved
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, thank you very much.

src/widget/wcoverartmenu.cpp Outdated Show resolved Hide resolved
return;
}

m_worker.reset(new CoverArtCopyWorker(image, coverArtCopyFilePath));
Copy link
Member

Choose a reason for hiding this comment

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

This smart pointer will delete the worker even though it might still be running.
We need to wait for the task to be finished in the destructor of this class. Check out other places in the code for a template.

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've added a quit() in the last method of the worker, and this triggers a bool member in WCoverArtMenu, I've added a VERIFY_OR_DEBUG_ASSERT(m_isWorkerRunning == false), IDK if that solves this issue.

@fatihemreyildiz
Copy link
Contributor Author

With the last commit, I've moved the disc access in WCoverArtMenu to another thread.

src/library/export/coverartcopyworker.h Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.h Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.h Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.h Show resolved Hide resolved
src/library/export/coverartcopyworker.cpp Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.cpp Show resolved Hide resolved
src/library/export/coverartcopyworker.cpp Outdated Show resolved Hide resolved
src/library/export/coverartcopyworker.cpp Outdated Show resolved Hide resolved
this,
&WCoverArtMenu::slotStarted);

m_worker->start();
Copy link
Member

Choose a reason for hiding this comment

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

the waiting code in the destructor is missing.

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 couldn't understand it could you please explain it a bit more please? Thanks in advance.

Copy link
Member

Choose a reason for hiding this comment

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

Something like this:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, destructor should have this in order to not terminate the working thread, right?

Copy link
Member

Choose a reason for hiding this comment

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

right.

auto coverArtFileInfo = mixxx::FileInfo(m_selectedCoverArtFilePath);
auto selectedCoverFileAccess = mixxx::FileAccess(coverArtFileInfo);
if (!selectedCoverFileAccess.isReadable()) {
if (Sandbox::askForAccess(&coverArtFileInfo)) {
Copy link
Member

Choose a reason for hiding this comment

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

This will issue a message box from this thread. I am not an apply guy. Is this necessary at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I didn't notice that the askForAccess populates message box. That will cause a SEG fault according to my experience with this worker. So I just check if it is readable, if it is not readable emitting fail signal would work IMHO. What do you think?

auto selectedCoverFileAccess = mixxx::FileAccess(coverArtFileInfo);
if (!selectedCoverFileAccess.isReadable()) {
if (Sandbox::askForAccess(&coverArtFileInfo)) {
selectedCoverFileAccess = mixxx::FileAccess(coverArtFileInfo);
Copy link
Member

Choose a reason for hiding this comment

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

We need also check for failure in the second path. if this code remains.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So double check isReadable for both of the paths would work?

Copy link
Member

Choose a reason for hiding this comment

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

We need the isReadable() == true state at least. I have no clue about the implications on macOS.

@fatihemreyildiz
Copy link
Contributor Author

As we have discussed for macOS FileAccess needs to be tested.

@daschuer
Copy link
Member

daschuer commented Oct 4, 2022

I now receive

critical [Main] DEBUG ASSERT: "m_isWorkerRunning == false" in function void WCoverArtMenu::slotChange() at ../../src/widget/wcoverartmenu.cpp:81

@fatihemreyildiz
Copy link
Contributor Author

I now receive

critical [Main] DEBUG ASSERT: "m_isWorkerRunning == false" in function void WCoverArtMenu::slotChange() at ../../src/widget/wcoverartmenu.cpp:81

Could you please tell how to produce this? I tried many times and I've never had this before.

@daschuer daschuer added the changelog This PR should be included in the changelog label Oct 5, 2022
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, Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build changelog This PR should be included in the changelog library ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants