Fix Amarok crash with Audio CD inserted

Review Request #111626 - Created July 21, 2013 and submitted

Christoph Feck
amarok, kdelibs, solid says:

"Looking at the backtrace, KFilePlacesItem tries to detect Audio CDs as follows:

    Solid::Device d = device();
    if (d.isValid()) {
            if (m_access) {
                return QUrl(KUrl(m_access->filePath()));
            } else if (m_disc && (m_disc->availableContent() & Solid::OpticalDisc::Audio)!=0) {
                QString device =<Solid::Block>()->device();
                return QUrl(QString("audiocd:/?device=%1").arg(device));

The crash happens, because<Solid::Block> returns 0, in other words, Audio CDs are no longer treated as block devices.

Failure of said cast can be easily detected, but the question is rather, if it's not a Solid bug, how the code needs to be modified to correctly get the audiocd:/ URL for the block device."

While I did not yet figure out, how I can get the block device URL for a disc in case block is 0, I propose this temporary fix. It should fix the crash, but could fail to correctly invoke the audiocd:/ kio with multiple disc drives.
I could not test, my system has no disc drives.
Lukáš Tinkl
Àlex Fiestas
Mark Kretschmann
Commit Hook
Christoph Feck
Review request changed

Status: Closed (submitted)