diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-07-15 20:58:10 +0300 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2018-07-15 20:58:10 +0300 |
commit | fde066e2369f50ebfa275cbc55e4c84ac88a0214 (patch) | |
tree | e2ff5abe4c4611d7bbb37fb20f3ca53ad4842d67 /src/dialogs | |
parent | De-duplicate the m.room.encryption event (diff) | |
download | nheko-fde066e2369f50ebfa275cbc55e4c84ac88a0214.tar.xz |
Use MainWindow instead of QApplication::activeWindow to reference the main window
The latter will not always return a valid pointer. fixes #363
Diffstat (limited to 'src/dialogs')
-rw-r--r-- | src/dialogs/PreviewUploadOverlay.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/dialogs/PreviewUploadOverlay.cc b/src/dialogs/PreviewUploadOverlay.cc index e01d2b17..a4e31a7a 100644 --- a/src/dialogs/PreviewUploadOverlay.cc +++ b/src/dialogs/PreviewUploadOverlay.cc @@ -25,6 +25,7 @@ #include "Config.h" #include "Logging.hpp" +#include "MainWindow.h" #include "Utils.h" #include "dialogs/PreviewUploadOverlay.h" @@ -61,9 +62,16 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent) void PreviewUploadOverlay::init() { - auto window = QApplication::activeWindow(); - auto winsize = window->frameGeometry().size(); - auto center = window->frameGeometry().center(); + QSize winsize; + QPoint center; + + auto window = MainWindow::instance(); + if (window) { + winsize = window->frameGeometry().size(); + center = window->frameGeometry().center(); + } else { + nhlog::ui()->warn("unable to load the retrieve MainWindow's size"); + } fileName_.setText(QFileInfo{filePath_}.fileName()); |