From 87f6719c74ab169f342962ff40b46c83df29af59 Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Mon, 2 May 2016 16:51:33 +0200 Subject: fixed "off-by-one" bug. --- src/server/mainwindow/mainwindow.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/server/mainwindow/mainwindow.cpp') diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index 32d5186..c21f2d6 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -209,8 +209,8 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred) /* Now place in next free cell, start looking at current position of frame */ vector freePositions; - for (int x = 0; x < _tilesX - clientSize.width(); x++) { - for ( int y = 0; y < _tilesY - clientSize.height(); y++) { + for (int x = 0; x <= _tilesX - clientSize.width(); x++) { + for ( int y = 0; y <= _tilesY - clientSize.height(); y++) { /* check if (x,y) is free */ bool isFree = true; for (int dx = 0; dx < clientSize.width(); dx++) { @@ -222,6 +222,7 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred) } if (isFree) { QPoint freePos(x,y); + qDebug() << "found free: " << freePos; freePositions.push_back(freePos); } } @@ -617,6 +618,7 @@ void MainWindow::unlockContextButtons() { ui->action_SetAsTutor->setEnabled(false); ui->action_StudentToTutorExclusive->setEnabled(false); ui->action_StudentToTutor->setEnabled(false); + ui->action_TutorToStudent->setEnabled(false); } @@ -695,14 +697,18 @@ void MainWindow::onPlaceFrame(bool activateTrash, ConnectionFrame* connectionFra /* round to grid */ int x = p.x() / getTileWidthPx(); int y = p.y() / getTileHeightPx(); - if (x < 0) + if (x < 0) { x = 0; - else if (x > s.width() - getTileWidthPx()) + } else if (x > s.width() - getTileWidthPx()) { + qDebug() << "oopsie"; x = (_tilesX - 1); - if (y < 0) + } + if (y < 0) { y = 0; - else if (y > s.height() - getTileHeightPx()) + } else if (y > s.height() - getTileHeightPx()) { + qDebug() << "oopsie2"; y = (_tilesY - 1); + } /* --- */ QPoint newPos(x,y); -- cgit v1.2.3-55-g7522