summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.cpp
diff options
context:
space:
mode:
authorChristian Klinger2016-05-19 16:05:20 +0200
committerChristian Klinger2016-05-19 16:05:20 +0200
commit6e0dd4bd2848b1be03ab733803130b5f07b6b696 (patch)
treed323eb5bcecb33d56f7bddc268e954446f3e2bd8 /src/server/mainwindow/mainwindow.cpp
parent[shared/server] define preferred styles and enable it if supported (diff)
parentCloses bug #2807. (And also cleans the code (a bit)) (diff)
downloadpvs2-6e0dd4bd2848b1be03ab733803130b5f07b6b696.tar.gz
pvs2-6e0dd4bd2848b1be03ab733803130b5f07b6b696.tar.xz
pvs2-6e0dd4bd2848b1be03ab733803130b5f07b6b696.zip
Merge branch 'bugfix/segfault-clientsize'
Diffstat (limited to 'src/server/mainwindow/mainwindow.cpp')
-rw-r--r--src/server/mainwindow/mainwindow.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp
index c21f2d6..453c8e0 100644
--- a/src/server/mainwindow/mainwindow.cpp
+++ b/src/server/mainwindow/mainwindow.cpp
@@ -190,7 +190,8 @@ float distance(QPoint a, QPoint b) {
void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred)
{
qDebug() << "placeFrameInFreeSlot(preferred = " << preferred << ")";
- const QSize& clientSize = Global::getRooms()[Global::getCurrentRoom()]->clientSize;
+ const QSize& clientSize = Global::getCurrentRoom()->clientSize;
+ // TODO: Fix this qDebug() << "clientSize: " << &clientSize
/* Get occupied cell of each frame and store status in an array */
bool grid[_tilesX][_tilesY];
memset(grid, 0, sizeof(bool) * _tilesX * _tilesY); // set everything to false
@@ -222,7 +223,6 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred)
}
if (isFree) {
QPoint freePos(x,y);
- qDebug() << "found free: " << freePos;
freePositions.push_back(freePos);
}
}
@@ -252,8 +252,8 @@ void MainWindow::placeFrameInFreeSlot(ConnectionFrame* frame, QPoint preferred)
ConnectionFrame* MainWindow::createFrame()
{
// Allocate and resize
- int width = getTileWidthPx() * Global::getRooms()[Global::getCurrentRoom()]->clientSize.width();
- int height= getTileHeightPx() * Global::getRooms()[Global::getCurrentRoom()]->clientSize.height();
+ int width = getTileWidthPx() * Global::getCurrentRoom()->clientSize.width();
+ int height= getTileHeightPx() * Global::getCurrentRoom()->clientSize.height();
ConnectionFrame *cf = new ConnectionFrame(ui->frmRoom, width, height);
_clientFrames.append(cf);
@@ -272,7 +272,7 @@ ConnectionFrame* MainWindow::createFrame()
ConnectionFrame* MainWindow::createFrame(QString computerId, QPoint pxCoord, QPoint gridPosition)
{
// Allocate and resize
- Room* room = Global::getRooms()[Global::getCurrentRoom()];
+ const Room* room = Global::getCurrentRoom();
qDebug() << "createFrame, access room: " << room;
int width = getTileWidthPx() * (room == NULL ? 1 : room->clientSize.width());
int height = getTileHeightPx() * (room == NULL ? 1 : room->clientSize.height());
@@ -562,11 +562,12 @@ AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize) {
*/
void MainWindow::resizeEvent(QResizeEvent* e)
{
- Room* room = Global::getRooms()[Global::getCurrentRoom()];
+ const Room* room = Global::getCurrentRoom();
+ const QSize& clientSize = room->clientSize;
-
- if (room == NULL) {return; } /* Nothing to do here */
- QSize& clientSize = room->clientSize;
+ // TODO: Do I still need this?
+ // if (room == NULL) {return; } /* Nothing to do here */
+ // QSize& clientSize = room->clientSize;
if (ui->frmRoom->size().width() < 100 || ui->frmRoom->size().height() < 100 || _tilesX <= 0 || _tilesY <= 0) { return; }
QSize newGridSize = room->gridSize;
@@ -895,7 +896,7 @@ void MainWindow::onReloadRoomOk()
}
/* load background image */
- QString imgPath = Global::getRooms()[Global::getCurrentRoom()]->imagePath;
+ QString imgPath = Global::getCurrentRoom()->imagePath;
if (imgPath == "") {
/* set empty pixmap*/
QPixmap empty;