Opened 20 years ago
Closed 20 years ago
MythVideo fails to display files with square brackets in properly
If I have two files, named 'Test [1 - 1].avi' and 'Test [2 - 1].avi', and use Video Manager to import them into the videometadata table, they show up successfully in that table, but with the same value in the title column, 'Test'. When browsing videos, this causes only one of them to show up in the Tree View (also seems to be a problem in Gallery Mode). Removing the square brackets and reloading the database through Video Manager allows both files to be seen correctly.
This problem has been introduced since Myth 0.18 - previously such files displayed correctly.
Change History
(6)
by sphery <mtdean@…>, 20 years ago
Owner: |
changed from jdonavan to cpinkham
|
by sphery <mtdean@…>, 20 years ago
Resolution: |
→ fixed
|
Status: |
new → closed
|
As discussed in http://www.gossamer-threads.com/lists/mythtv/dev/184376#184376 , removing the bracketed text from the filename to create the video name is most likely not a bug (but, rather, the intended behavior); however, the inability to display multiple videos with the same name is a bug.
The problem is in videolist.cpp. If the user chooses to sort videos by title, VideoList re-sorts the videos after stripping articles from the beginning of the video name. (All other sorting is done by MySQL with the query, so the bug only appears if sorting by title.) The VideoList uses a hack with a QMap keyed by the video name without the initial articles to perform the sort. Because the QMap replaces values given the same key, only one video with any given name (before or after the initial articles are removed) survives the sort.
Since QMap's insertMulti() function and QMultiMap were introduced in QT4, I couldn't just modify the hack to use either of them, instead. And, since QPtrList is only available in QT4 as a QT3 compatibility class, it seemed that doing a proper sort by creating a subclass of QPtrList and providing a compareItems() function would result in a new class that would be completely unnecessary if Myth is ported to QT4 (especially since QT4 allows passing a "compare" function to qSort() for sorting a QList).
Therefore, I added a hack to the hack by appending the string version of the video's ID to the end of the key. That way, each key used for the map is unique and all videos survive the sort.
If you prefer a proper sort, let me know and I'll do another patch. (Sorry about the long description for the short patch. :)