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

Bugfixes #413

Merged
merged 4 commits into from
Sep 25, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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