Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call QtPass::setup() from QtPass class constructor (should fix #466) #482

Merged
merged 2 commits into from Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/mainwindow.cpp
Expand Up @@ -44,8 +44,7 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent)
#endif
ui->setupUi(this);

m_qtPass = new QtPass();
m_qtPass->setMainWindow(this);
m_qtPass = new QtPass(this);

// register shortcut ctrl/cmd + Q to close the main window
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
Expand Down Expand Up @@ -119,6 +118,10 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent)
QTimer::singleShot(10, this, SLOT(focusInput()));

ui->lineEdit->setText(searchText);

if (!m_qtPass->init())
// no working config so this should just quit
QApplication::quit();
}

MainWindow::~MainWindow() { delete m_qtPass; }
Expand Down
19 changes: 8 additions & 11 deletions src/qtpass.cpp
Expand Up @@ -22,20 +22,18 @@
#include "debughelper.h"
#endif

QtPass::QtPass() : clippedText(QString()), freshStart(true) {
if (!setup()) {
// no working config so this should quit without config anything
QApplication::quit();
{}
}

QtPass::QtPass(MainWindow *mainWindow) : m_mainWindow(mainWindow),
clippedText(QString()),
freshStart(true) {
setClipboardTimer();
clearClipboardTimer.setSingleShot(true);
connect(&clearClipboardTimer, SIGNAL(timeout()), this,
SLOT(clearClipboard()));

QObject::connect(qApp, &QApplication::aboutToQuit, this,
&QtPass::clearClipboard);

setMainWindow();
}

/**
Expand All @@ -55,10 +53,10 @@ QtPass::~QtPass() {
}

/**
* @brief QtPass::setup make sure we are ready to go as soon as
* @brief QtPass::init make sure we are ready to go as soon as
* possible
*/
bool QtPass::setup() {
bool QtPass::init() {
QString passStore = QtPassSettings::getPassStore(Util::findPasswordStore());
QtPassSettings::setPassStore(passStore);

Expand Down Expand Up @@ -111,8 +109,7 @@ bool QtPass::setup() {
return true;
}

void QtPass::setMainWindow(MainWindow *mW) {
m_mainWindow = mW;
void QtPass::setMainWindow(void) {
m_mainWindow->restoreWindow();

fusedav.setParent(m_mainWindow);
Expand Down
6 changes: 3 additions & 3 deletions src/qtpass.h
Expand Up @@ -11,10 +11,10 @@ class QtPass : public QObject {
Q_OBJECT

public:
QtPass();
QtPass(MainWindow *mainWindow);
~QtPass();

void setMainWindow(MainWindow *mW);
bool init();
void setClippedText(const QString &, const QString &p_output = QString());
void clearClippedText();
void setClipboardTimer();
Expand All @@ -30,7 +30,7 @@ class QtPass : public QObject {
QString clippedText;
bool freshStart;

bool setup();
void setMainWindow();
void connectPassSignalHandlers(Pass *pass);
void mountWebDav();

Expand Down