View Full Version : QString assignment
valgaba
25th April 2010, 12:58
class TagAudio
{
private:
protected:
public:
QString TagNombre;
TagAudio();
void Iniciar(const char *file );
};
TagAudio::TagAudio()
{
}
void TagAudio::Iniciar(const char *file){
TagLib::FileRef tagFile(file);
if(!tagFile.isNull()){
QString TagTmp;
TagTmp = TStringToQString(tagFile.tag()->album()); //yes
TagNombre = TStringToQString(tagFile.tag()->album()); //no ?
}
}
For the second assignment is not possible TagNombre
thanks
caduel
25th April 2010, 13:20
what error message do you get?
Lykurg
25th April 2010, 14:29
... and how is TStringToQString defined?
valgaba
25th April 2010, 15:14
#ifndef TAGAUDIO_H
#define TAGAUDIO_H
#include <QString>
#include "fileref.h"
#include "tag.h"
#include "tbytevector.h"
#include "taglib_export.h"
class TagAudio
{
private:
protected:
public:
TagAudio();
void Iniciar(const char *file );
QString TagNombre;
};
#endif // TAGAUDIO_H
#include <iostream>
#include <stdio.h>
#include <QDebug>
#include <QString>
#include <QMessageBox>
#include <QByteArray>
#include <QFile>
#include "fileref.h"
#include "tag.h"
#include "tbytevector.h"
#include "TagAudio.h"
#include "taglib_export.h"
using namespace std;
TagAudio::TagAudio()
{
}
void TagAudio::Iniciar(const char *file){
TagLib::FileRef tagFile(file);
if(!tagFile.isNull()){
TagNombre=TStringToQString(tagFile.tag()->album()); // causes CRASH application ?
qDebug() << "salida" << TStringToQString(tagFile.tag()->album()); //perfect start
}
}
TagNombre=TStringToQString(tagFile.tag()->album()); // causes CRASH application ?
squidge
25th April 2010, 18:31
There's probably a temporary class object being created somewhere which is being freed on the return and so your line is dereferencing freed memory. Try and seperate it out a bit more (eg. assign the tag()->album first, and then use TStringToQString)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.