]> git.zarvox.org Git - shareboard.git/commitdiff
Fix double-insertion of action pointer into localActions array.
authorDrew Fisher <drew.m.fisher@gmail.com>
Fri, 8 Oct 2010 03:54:14 +0000 (20:54 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Fri, 8 Oct 2010 03:54:14 +0000 (20:54 -0700)
The bug here caused segfaults on the arrival of the second server-approved
event from the client, since the Action had already been deleted.

shareboard.cpp

index cd39d63558bff3832809074d0d69ec3b1be67379..171c49055ef2216cdeeab4ec532c616cde07f7f3 100644 (file)
@@ -16,6 +16,9 @@ Shareboard::Shareboard(QWidget* parent) : QWidget(parent) {
        setLayout(layout);
        setMinimumSize(640,480);
 
+       // All real userIDs are positive, so we won't trigger the delete in postAction until setUserID is called
+       userID = -1;
+
        QObject::connect(prompt, SIGNAL(connectToServer(QString, QString)), this, SIGNAL(connectToServer(QString, QString)));
        QObject::connect(canvas, SIGNAL(mouseMovedTo(QPointF)), this, SLOT(handleMouseMoved(QPointF)));
        QObject::connect(canvas, SIGNAL(segmentDrawn(QPointF,QPointF)), this, SLOT(handleSegmentDrawn(QPointF,QPointF)));
@@ -32,7 +35,6 @@ void Shareboard::handleMouseMoved(QPointF pos) {
        MouseMoveAction* action = new MouseMoveAction();
        action->userID = userID;
        action->pos = pos;
-       localHistory.append(action);
        emit actionHappened(action);
        qDebug() << "shareboard.cpp: mouse moved to" << pos;
 }