Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Commit

Permalink
Use MainWindow instead of QApplication::activeWindow to reference the…
Browse files Browse the repository at this point in the history
… main window

The latter will not always return a valid pointer.

fixes #363
  • Loading branch information
mujx committed Jul 15, 2018
1 parent 31d09db commit fde066e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/CommunitiesList.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Cache.h"
#include "CommunitiesList.h"
#include "Cache.h"
#include "Logging.hpp"
#include "MatrixClient.h"

Expand Down
14 changes: 11 additions & 3 deletions src/dialogs/PreviewUploadOverlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "Config.h"
#include "Logging.hpp"
#include "MainWindow.h"
#include "Utils.h"

#include "dialogs/PreviewUploadOverlay.h"
Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit fde066e

Please sign in to comment.