diff options
author | Simon Rettberg | 2017-11-24 16:57:14 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-11-24 16:57:14 +0100 |
commit | 98b93b40e8e875ae3928509d61715851f62aa376 (patch) | |
tree | c0d1818c61e4b3a14b2550f4707263acba963f48 /src | |
parent | Merge branch 'master' of git.openslx.org:openslx-ng/vmchooser2 (diff) | |
download | vmchooser2-98b93b40e8e875ae3928509d61715851f62aa376.tar.gz vmchooser2-98b93b40e8e875ae3928509d61715851f62aa376.tar.xz vmchooser2-98b93b40e8e875ae3928509d61715851f62aa376.zip |
Fix invalid memory access (off by one error)
Diffstat (limited to 'src')
-rw-r--r-- | src/dialog.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp index c07a71d..7a378a1 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -70,6 +70,7 @@ Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent) ui->PVS_checkbox->setVisible(g_pvsEnabled); ui->PVS_checkbox->setChecked(g_pvsChecked); + activeTab_ = -1; if (examMode_) { ui->tabButtonLocal->setEnabled(false); this->onTabButtonChanged(TAB_ALL_VMS); @@ -82,8 +83,6 @@ Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent) this->onTabButtonChanged(TAB_NATIVE); this->selectPreviousSession(); } - //activeTab_ = 2; - //ui->tabButtonAllClasses->setChecked(true); ui->chkAdminMode->setVisible(g_allowVmEdit); ui->chkAdminMode->setEnabled(false); @@ -134,9 +133,9 @@ void Dialog::on_treeView_doubleClicked(const QModelIndex& index) } } if (ui->chkAdminMode->isEnabled() && ui->chkAdminMode->isChecked()) { - setenv("VMCHOOSER_ADMIN_MODE", "TRUE", 1); + setenv("VMCHOOSER_ADMIN_MODE", "TRUE", 1); } else { - setenv("VMCHOOSER_ADMIN_MODE", "FALSE", 1); + setenv("VMCHOOSER_ADMIN_MODE", "FALSE", 1); } // Run session @@ -251,7 +250,7 @@ void Dialog::on_pushButtonStart_clicked() { bool Dialog::selectSession(const QString& name) { QModelIndex root(ui->treeView->rootIndex()); - for (int tab = 0; tab <= TAB_COUNT; ++tab) { + for (int tab = 0; tab < TAB_COUNT; ++tab) { for (int i = 0; i < model_[tab]->rowCount(root); ++i) { QModelIndex section(model_[tab]->index(i, 0, root)); if (!section.isValid()) { @@ -329,19 +328,21 @@ void Dialog::selectPreviousSession() { qDebug() << "Not selecting previous session as user interacted or session was already selected"; return; } - if (!ChooserSettings::getSetting("last-session").isEmpty()) { - qDebug() << "Trying to select last session: " << ChooserSettings::getSetting("last-session"); + QString lastSession = ChooserSettings::getSetting("last-session"); + if (!lastSession.isEmpty()) { + qDebug() << "Trying to select last session: " << lastSession; ui->treeView->clearSelection(); - if (selectSession(ChooserSettings::getSetting("last-session"))) { + if (selectSession(lastSession)) { qDebug() << "Success"; userInteracted_ = true; return; } } // could not find last session, change to last used tab - if (!ChooserSettings::getSetting("last-tab").isEmpty()) { - qDebug() << "Trying to select last tab " << ChooserSettings::getSetting("last-tab"); - this->onTabButtonChanged(ChooserSettings::getSetting("last-tab").toInt()); + QString lastTab = ChooserSettings::getSetting("last-tab"); + if (!lastTab.isEmpty()) { + qDebug() << "Trying to select last tab " << lastTab; + this->onTabButtonChanged(lastTab.toInt()); } else { qDebug() << "Selected default tab " << defaultTab_; // Select default tab |