Skip to content

Commit

Permalink
Merge pull request #413 from rdoeffinger/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
annejan committed Sep 25, 2018
2 parents 4fe1a73 + 68490dc commit d5f9939
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion qtpass.pri
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CONFIG(coverage) {
}

CONFIG(debug, debug|release) {
QMAKE_CXXFLAGS += -g -c -Wall -O0
!msvc:QMAKE_CXXFLAGS += -g -c -Wall -O0
QMAKE_LFLAGS += -O0
}

Expand Down
2 changes: 1 addition & 1 deletion src/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void Executor::finished(int exitCode, QProcess::ExitStatus exitStatus) {
QTextCodec *codec = QTextCodec::codecForLocale();
if (i.readStdout)
output = codec->toUnicode(m_process.readAllStandardOutput());
if (i.readStderr or exitCode != 0) {
if (i.readStderr || exitCode != 0) {
err = codec->toUnicode(m_process.readAllStandardError());
if (exitCode != 0)
dbg() << exitCode << err;
Expand Down
8 changes: 6 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,12 @@ void MainWindow::config() {
this->show();

updateProfileBox();
ui->treeView->setRootIndex(proxyModel.mapFromSource(
model.setRootPath(QtPassSettings::getPassStore())));
// For freshStart, proxyModel is not yet configured
// and maniplating it will assert
if (!freshStart) {
ui->treeView->setRootIndex(proxyModel.mapFromSource(
model.setRootPath(QtPassSettings::getPassStore())));
}

if (freshStart && Util::checkConfig())
config();
Expand Down
20 changes: 12 additions & 8 deletions src/qtpasssettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
bool QtPassSettings::initialized = false;

Pass *QtPassSettings::pass;
RealPass QtPassSettings::realPass;
ImitatePass QtPassSettings::imitatePass;
// Go via pointer to avoid dynamic initialization,
// due to "random" initialization order realtive to other
// globals, especially around QObject emtadata dynamic initialization
// can lead to crashes depending on compiler, linker etc.
QScopedPointer<RealPass> QtPassSettings::realPass;
QScopedPointer<ImitatePass> QtPassSettings::imitatePass;

QtPassSettings *QtPassSettings::m_instance = nullptr;
QtPassSettings *QtPassSettings::getInstance() {
Expand Down Expand Up @@ -83,9 +87,9 @@ void QtPassSettings::setProfiles(const QHash<QString, QString> &profiles) {
Pass *QtPassSettings::getPass() {
if (!pass) {
if (isUsePass()) {
QtPassSettings::pass = &QtPassSettings::realPass;
QtPassSettings::pass = getRealPass();
} else {
QtPassSettings::pass = &QtPassSettings::imitatePass;
QtPassSettings::pass = getImitatePass();
}
pass->init();
}
Expand Down Expand Up @@ -149,9 +153,9 @@ bool QtPassSettings::isUsePass(const bool &defaultValue) {
}
void QtPassSettings::setUsePass(const bool &usePass) {
if (usePass) {
QtPassSettings::pass = &QtPassSettings::realPass;
QtPassSettings::pass = getRealPass();
} else {
QtPassSettings::pass = &QtPassSettings::imitatePass;
QtPassSettings::pass = getImitatePass();
}
getInstance()->setValue(SettingsConstants::usePass, usePass);
}
Expand Down Expand Up @@ -527,5 +531,5 @@ void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) {
templateAllFields);
}

RealPass *QtPassSettings::getRealPass() { return &realPass; }
ImitatePass *QtPassSettings::getImitatePass() { return &imitatePass; }
RealPass *QtPassSettings::getRealPass() { if (realPass.isNull()) realPass.reset(new RealPass()); return realPass.data(); }
ImitatePass *QtPassSettings::getImitatePass() { if (imitatePass.isNull()) imitatePass.reset(new ImitatePass()); return imitatePass.data(); }
4 changes: 2 additions & 2 deletions src/qtpasssettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class QtPassSettings : public QSettings {
static QtPassSettings *m_instance;

static Pass *pass;
static RealPass realPass;
static ImitatePass imitatePass;
static QScopedPointer<RealPass> realPass;
static QScopedPointer<ImitatePass> imitatePass;

public:
static QtPassSettings *getInstance();
Expand Down

0 comments on commit d5f9939

Please sign in to comment.