Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Memory access violation when appending to initialized QLinkedList

$
0
0
Hey, So I’ve written a MainWindow that starts a few things, one of which is a server that handles connections in another thread. It’s basically a peer to peer instant message client over TCP. I haven’t really been able to test that it’s working correctly because I’m getting a memory access violation when appending text to my QLinkedList of data items. The underlying threads have access to this list and on a timer scan the list to find the data that still needs to be sent over that socket. In the main window, when the user clicks the pushbutton the text that is in the box should be appended into that list of data to be sent by the sockets. However, every time I attempt to append something, I get a memory access violation error. I’ve been trying to debug this for hours stepping through with Visual Studio and I am now looking for a fresh set of eyes. Here’s my MainWindow class implementation: MainWindow::MainWindow(QWidget *parent) :     QMainWindow(parent),     ui(new Ui::MainWindow) {     timer = new QTimer;  sysFrame = new int;  data = new QLinkedList<Data>;     timer->start(500);     connect(timer,SIGNAL(timeout(QPrivateSignal)),this,SLOT(handleTime()));     *sysFrame =0;  addr = new QString;     msgs = new QString;     lock = new QMutex;  name = new QString;     startDialog start(name,addr);     start.setModal(true);     start.exec();     Server serv(sysFrame,data,lock,*addr,msgs);     serv.StartServer();     ui->setupUi(this); }   MainWindow::~MainWindow() {  delete sysFrame;  delete timer;  delete addr;  delete data;     delete msgs;     delete lock;     delete ui; }   void MainWindow::on_pushButton_clicked() {     Data tempData;     QString tempString;     tempString.clear();     tempString.append("<").append(name).append(">: ");     tempString.append(ui->lineEdit->text());     ui->lineEdit->clear();     lock->lock();     tempData.frame=*sysFrame;     tempData.text=tempString;     data->append(tempData); //Memory access violation here.     msgs->append(tempString);     msgs->append("\n");     lock->unlock(); }   void MainWindow::handleTime() {     ui->textBrowser->clear();     ui->textBrowser->setText(*msgs);     ui->textBrowser->repaint(); } The line that fails on me is commented. It’s in the “on_pushbutton_clicked” method. Any help is really appreciated, Thanks.

Viewing all articles
Browse latest Browse all 18427

Latest Images

Trending Articles



Latest Images