QTcpSocket.readLine causing segmentation failure
i am using QTcpsocket.readLine to read from a socket in a thread. it is working well otherwise but causing a segmentation failure. this the code:
Header file
Code:
#ifndef CLIENTTHREAD_H
#define CLIENTTHREAD_H
#include<QtNetwork/QTcpSocket>
#include<QThread>
{
Q_OBJECT
public:
// MainWindow *m;
// int index;
void run();
signals:
private slots:
void readFromClient();
private:
};
#endif // CLIENTTHREAD_H
Source File;
Code:
#include "clientthread.h"
socket(_socket),name(_name)
{
connect(socket,SIGNAL(disconnected()),this,SLOT(terminate()));
}
void clientThread::run(){
char *data;
uint i;
i=1024;
qDebug()<<"client thread started";
}
void clientThread::readFromClient(){
char *data;
uint i;
i=1024;
[COLOR="Red"] socket->readLine(data,i);[/COLOR]
emit updatechat(tr(data),name);
}
Any Ideas why this is happening.
Please help
Re: QTcpSocket.readLine causing segmentation failure
Quote:
char *data;
socket->readLine(data,i);
Of course this crashes. What does data point to?