Skip to content

Commit

Permalink
Don't call QtPass::setup() from QtPass class constructor
Browse files Browse the repository at this point in the history
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 bc19f9e.

Rename QtPass::setup() to QtPass::init() and call it explicitly at the end
of the MainWindow constructor.

Should fix #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).
  • Loading branch information
maciejsszmigiero committed Oct 2, 2019
1 parent fc2aed3 commit 3454fcf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
10 changes: 2 additions & 8 deletions src/qtpass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/qtpass.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class QtPass : public QObject {
QtPass(MainWindow *mainWindow);
~QtPass();

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

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

Expand Down

0 comments on commit 3454fcf

Please sign in to comment.