aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-02 20:22:25 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-02 20:22:25 -0700
commit4004e0faeed99b3deb0ffb0b0f469594843ca14b (patch)
tree045b8d67888d55ec34978a2ff93ead1cf9d8e45e /launcher
parentc523765c197cf63d6830d205f1554cd73e38109e (diff)
downloadPrismLauncher-4004e0faeed99b3deb0ffb0b0f469594843ca14b.tar.gz
PrismLauncher-4004e0faeed99b3deb0ffb0b0f469594843ca14b.tar.bz2
PrismLauncher-4004e0faeed99b3deb0ffb0b0f469594843ca14b.zip
fix: segfault in progress dialog
- dialog tries to resize after unhiding the subtask scroll area - after resize attempts to recenter on parent - `calls parentWidget()->{x|y}()` - what if there is no parent? nullptr->() = segfault - recenter on last pos, don't access parent Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher')
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 246a0fd4..84f9db7e 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -34,6 +34,7 @@
*/
#include "ProgressDialog.h"
+#include <qpoint.h>
#include "ui_ProgressDialog.h"
#include <limits>
@@ -96,21 +97,30 @@ ProgressDialog::~ProgressDialog()
void ProgressDialog::updateSize()
{
QSize lastSize = this->size();
- QSize qSize = QSize(480, minimumSizeHint().height());
+ QPoint lastPos = this->pos();
+ int minHeight = minimumSizeHint().height();
+ if (ui->taskProgressScrollArea->isHidden())
+ minHeight -= ui->taskProgressScrollArea->minimumSizeHint().height();
+ QSize labelMinSize = ui->globalStatusLabel->minimumSize();
+ int labelHeight = ui->globalStatusLabel->height();
+ if (labelHeight > labelMinSize.height())
+ minHeight += labelHeight - labelMinSize.height(); // account for multiline label
+ minHeight = std::max(minHeight, 0);
+ QSize minSize = QSize(480, minHeight);
// if the current window is too small
- if ((lastSize != qSize) && (lastSize.height() < qSize.height()))
+ if ((lastSize != minSize) && (lastSize.height() < minSize.height()))
{
- resize(qSize);
-
- // keep the dialog in the center after a resize
- this->move(
- this->parentWidget()->x() + (this->parentWidget()->width() - this->width()) / 2,
- this->parentWidget()->y() + (this->parentWidget()->height() - this->height()) / 2
- );
+ resize(minSize);
+
+ QSize newSize = this->size();
+ QSize sizeDiff = lastSize - newSize; // last size was smaller, the results should be negative
+ // center on old position after resize
+ QPoint newPos(lastPos.x() + (sizeDiff.width() / 2), lastPos.y() + (sizeDiff.height() / 2));
+ this->move(newPos);
}
- setMinimumSize(qSize);
+ setMinimumSize(minSize);
}