1.9.1 valid tag in debug, crash in release.

Yogesh Marwaha yogeshm.007 at gmail.com
Tue Oct 29 13:48:15 UTC 2013


On 29 October 2013 03:25, Festus Hagen <festushagenlists at yahoo.com> wrote:
>         const TagLib::FileRef f( reinterpret_cast<const wchar_t*>(path.utf16()) );
> Or
>         const TagLib::FileRef f(path.toUtf8().data());
> Work reliably for me, I am on WinXP using Qt5.
>
> I use:
>         const TagLib::MPEG::File f(path.toLocal8Bit().constData());


Well, I think I've been through this mud before. Though I have been
out of touch for long, it seems the problem lies in
http://harmattan-dev.nokia.com/docs/library/html/qt4/qbytearray.html?tab=3&q=QByteArray#data

const TagLib::FileRef f(path.toUtf8().data());

Here path.toUtf8() creates a QByteArray which is (as per my
knowledge/or lack thereof) deleted as soon as it goes out of scope.

So, following my theory, any success with
const TagLib::FileRef f(path.toUtf8().data());
OR
const TagLib::MPEG::File f(path.toLocal8Bit().constData());
is a matter of chance.

You can try by, e.g.:
QByteArray a = path.toUtf8(); OR path.toLocal8Bit()
const TagLib::MPEG::File f(a.constData()); OR a.data();

Please correct me if I'm wrong. (I've not practically tried this)

Regards,

-- 
Yogesh Marwaha


More information about the taglib-devel mailing list