summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>2019-10-02 22:45:53 +0200
committerMaciej S. Szmigiero <mail@maciej.szmigiero.name>2019-10-02 22:52:04 +0200
commit3454fcf68288b9bd67ce624e591a60d5d2758610 (patch)
treedff13d0ce4484da7b0194f057029b063b1efff68
parentfc2aed35a9eae1ecede54321fd0644f89f9bd3c3 (diff)
Don't call QtPass::setup() from QtPass class constructor
QtPass::setup() cannot be called from this class constructor as it possibly calls back MainWindow::config() method. QtPass constructor is in turn called from the MainWindow one so the MainWindow object might not be fully constructed yet. It looks like this was introduced in commit bc19f9eeb5bbcd. Rename QtPass::setup() to QtPass::init() and call it explicitly at the end of the MainWindow constructor. Should fix https://github.com/IJHack/QtPass/issues/466, but the whole thing really needs a refactoring to establish a clear QtPass -> MainWindow (or MainWindow -> QtPass) relationship and to make sure there aren't any circular dependencies there (and other similar bugs).
-rw-r--r--src/mainwindow.cpp4
-rw-r--r--src/qtpass.cpp10
-rw-r--r--src/qtpass.h2
3 files changed, 7 insertions, 9 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index db241c2b..69a492e1 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -118,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; }
diff --git a/src/qtpass.cpp b/src/qtpass.cpp
index 8d90d370..22366c06 100644
--- a/src/qtpass.cpp
+++ b/src/qtpass.cpp
@@ -25,12 +25,6 @@
QtPass::QtPass(MainWindow *mainWindow) : m_mainWindow(mainWindow),
clippedText(QString()),
freshStart(true) {
- if (!setup()) {
- // no working config so this should quit without config anything
- QApplication::quit();
- {}
- }
-
setClipboardTimer();
clearClipboardTimer.setSingleShot(true);
connect(&clearClipboardTimer, SIGNAL(timeout()), this,
@@ -59,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);
diff --git a/src/qtpass.h b/src/qtpass.h
index 707ad5d2..064edfce 100644
--- a/src/qtpass.h
+++ b/src/qtpass.h
@@ -14,6 +14,7 @@ public:
QtPass(MainWindow *mainWindow);
~QtPass();
+ bool init();
void setClippedText(const QString &, const QString &p_output = QString());
void clearClippedText();
void setClipboardTimer();
@@ -30,7 +31,6 @@ private:
bool freshStart;
void setMainWindow();
- bool setup();
void connectPassSignalHandlers(Pass *pass);
void mountWebDav();