-
-
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
Recording: fix table refresh issues #4648
Conversation
still WIP until I verified all commits build |
edb6559
to
f05c355
Compare
All good. Ready for review. |
e9edfe4
to
8f28523
Compare
saveCurrentViewState(); | ||
QString recordingDir = m_pRecordingManager->getRecordingDir(); | ||
// Hack: append "/" so the model stores the complete path the model state key | ||
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo( |
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.
BrowseTabelModel::setPath()
should be responsible for normalizing the path as needed. Otherwise this only works for DlgRecording, but not for anyone else.
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.
BrowseTabelModel::setPath()
gets /path/to/some/dir/
from the BrowseFeature and this works for both the model key as well as passing the path to BrwoseThread. Besides, "anyone else" is fictional since no other feature uses the BrowseTableModel.
The actual "issue" is that we store /path/to/recording/directory
in ConfigKey(RECORDING_PREF_KEY, "Directory") without trailing separator (and I didn't want to touch how RecordingManager handles this)
So, IMO this 'hack' for the exceptional DlgRecording is okay IMO, compared to complicating the code elsewhere (and I thought about how to to do this safely and with little effort more than twice).
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.
Qt normally doe not use a trailing separator for directories. I have not yet understand why this makes a difference here. Can you add another sentence that explains what happens otherwise?
How about assert that case inside setPath?
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.
The "issue" is that the browseModel does send paths with trailing /
See the commit message of e79a977
The existing code that works perfectly fine for BrowseModel which I will not touch:
mixxx/src/library/browse/browsetablemodel.cpp
Lines 212 to 219 in f455527
void BrowseTableModel::setPath(mixxx::FileAccess path) { | |
if (path.info().hasLocation()) { | |
m_currentDirectory = path.info().locationPath(); | |
} else { | |
m_currentDirectory = QString(); | |
} | |
m_pBrowseThread->executePopulation(std::move(path), this); | |
} |
- Model view state keys are stored without trailing /
/any/path/passed/from/BrowseModel/
has trailing / and becomes/any/path/passed/from/BrowseModel
which is fine because any accidentally passed/path/to/MUSIC/file.ext
would properly be stripped to/path/to/MUSIC
- Without trailing / the rec path from the config
/home/me/Music/Recordings
would become/home/me/Music
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.
Comments about the current code should be added to the code instead of hiding this information in a commit message.
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.
Okay, I'll add those to browsetablemodel.cpp
Is the issue resolved for you then?
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.
ping
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.
FWIW the / is appended in BrowseFeature, even though it is not needed to populate the track view (the Rec view was obviously working fine without /)
See
mixxx/src/library/browse/browsefeature.cpp
Lines 420 to 425 in b648a88
// We here create new items for the sidebar models | |
// Once the items are added to the TreeItemModel, | |
// the models takes ownership of them and ensures their deletion | |
TreeItem* folder = new TreeItem( | |
one.fileName(), | |
QVariant(one.absoluteFilePath() + QStringLiteral("/"))); |
Maybe it's needed for FolderTreeModel::hasChildren
or Mixxx::FileInfo is Dir (used by Library > addDir)
idk, and I won't touch it.
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.
There is also the issue that BrowseTableModel::setPath(mixxx::FileAccess path) is either badly named or broken.
Because it expects a "file" location.
I think this will solve the issue by its roots:
void BrowseTableModel::setPath(mixxx::FileAccess path) {
if (path.info().hasLocation()) {
if (path.info().isFile()) {
m_currentDirectory = path.info().locationPath();
} else {
m_currentDirectory = path.info().location();
}
} else {
m_currentDirectory = QString();
}
m_pBrowseThread->executePopulation(std::move(path), this);
}
saveCurrentViewState(); | ||
QString recordingDir = m_pRecordingManager->getRecordingDir(); | ||
// Hack: append "/" so the model stores the complete path the model state key | ||
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo( |
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.
Qt normally doe not use a trailing separator for directories. I have not yet understand why this makes a difference here. Can you add another sentence that explains what happens otherwise?
How about assert that case inside setPath?
As usual: |
saveCurrentViewState(); | ||
QString recordingDir = m_pRecordingManager->getRecordingDir(); | ||
// Hack: append "/" so the model stores the complete path the model state key | ||
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo( |
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.
Please note that neither mixxx::FileInfo nor QFileInfo promise to keep a trailing slashes.
It looks like the current mechanism for storing paths as model keys has serious shortcomings and these hacks may stop working at any time.
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.
The issue is slightly different anyway. See #4648 (comment)
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.
These checks is exactly what I wanted to avoid.
Back to square one:
Browse passes all paths with trailing / (manually appended, for no obvious reason).
Removing the / was actually just a cosmetic issue for the model key string and path.info().locationPath()
a simple way to
- check if path "is valid" and
- remove /
Rec is the only feature that was passing a fixed path without trailing slash.
My change to append / there, too, is only working around .locationPath()
chopping the last dir part.
We may simply check for path.info().isDir()
and use the submitted path
then.
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo(m_recordingDir))); | ||
saveCurrentViewState(); | ||
QString recordingDir = m_pRecordingManager->getRecordingDir(); | ||
// Hack: append "/" so the model stores the complete path the model state key |
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.
So it is actually not a hack but a requirement. How about this:
// Hack: append "/" so the model stores the complete path the model state key | |
// Append "/" to avoid the folder name is treated as a file name in BrowseTableModel::setPath() |
saveCurrentViewState(); | ||
QString recordingDir = m_pRecordingManager->getRecordingDir(); | ||
// Hack: append "/" so the model stores the complete path the model state key | ||
m_browseModel.setPath(mixxx::FileAccess(mixxx::FileInfo( |
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.
There is also the issue that BrowseTableModel::setPath(mixxx::FileAccess path) is either badly named or broken.
Because it expects a "file" location.
I think this will solve the issue by its roots:
void BrowseTableModel::setPath(mixxx::FileAccess path) {
if (path.info().hasLocation()) {
if (path.info().isFile()) {
m_currentDirectory = path.info().locationPath();
} else {
m_currentDirectory = path.info().location();
}
} else {
m_currentDirectory = QString();
}
m_pBrowseThread->executePopulation(std::move(path), this);
}
Since void BrowseTableModel::setPath(mixxx::FileAccess path) {
if (path.info().hasLocation() && path.info().isDir()) {
m_currentDirectory = path.info().location();
} else {
m_currentDirectory = QString();
}
m_pBrowseThread->executePopulation(std::move(path), this);
} Given @uklotzde's approval the other commits are fine. |
Thank you! |
in case the recording path was changed in preferences
This is already triggered by RecordingFeature::activate
:setPath gets passed /any/file/path/. For the model view key we use locationPath() to chop the last / and everything after. Though, in the config we store /path/to/recording and this is used to call setPath(path), thus append / to get the correct model key.
No need to read the recording dir from config, check/create the dir and print "Recordings folder set to..." for every 1 MB written to disk.
954ed93
to
cf62a0d
Compare
Squashed and commit message adjusted. |
if (path.info().hasLocation()) { | ||
m_currentDirectory = path.info().locationPath(); | ||
if (path.info().hasLocation() && path.info().isDir()) { | ||
m_currentDirectory = path.info().location(); |
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.
It turns out that location() does not strip a trailing slash. Is this new behaviour desired?
I have hacked up a test to verify this:
https://github.com/daschuer/mixxx/blob/2114f3e34122b195bde868e2a3355f9626324bf6/src/test/fileinfo_test.cpp#L62
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.
Yes, intended:
Since
locationPath()
was chosen only to remove the trailing / from the paths passed by the BrowseFeature to have a 'clean' model key, and working around the sideeffect caused by the Rec path (no trailing /)...
I changed setPath() to use the entire path location (with /) for the model key and avoid the Rec issue in the first place:
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.
LGTM
I noticed that the track view selection and position was reset when I
In the end this is a fixup for #4177, as well as some tweaks I discovered while trying to find the cause for the issue.
Selection bug fixed by
26a5cea
26a5cea