Fix a few errors in board URL retrieval

Some functions accessed an empty QString (m_boardUrl) because it was not
yet filled at the time, breaking logic elsewhere. This is now fixed.
This commit is contained in:
Luca Beltrame 2015-02-15 22:10:58 +01:00
parent b951cddee4
commit 70ccd49d04

View file

@ -186,13 +186,14 @@ QString DanbooruConnectWidget::password() const
}
void DanbooruConnectWidget::accept()
{
QString hashedPassword;
QString currentBoard = danbooruUrlComboBox->currentText();
if (!userLineEdit->text().isEmpty() && !passwdLineEdit->text().isEmpty()) {
if (m_wallet && !m_wallet->hasEntry(m_boardUrl.url())) {
if (m_wallet && !m_wallet->hasEntry(currentBoard)) {
QMap<QString, QString> dataMap;
dataMap.insert(QLatin1String("username"), m_username);
dataMap.insert(QLatin1String("password"), passwdLineEdit->text());
@ -202,8 +203,8 @@ void DanbooruConnectWidget::accept()
// Only calculate if we haven't set a password from the wallet already
if (m_password.isEmpty()) {
hashedPassword = boardSalts.value(m_boardUrl);
hashedPassword = hashedPassword.arg(passwdLineEdit->text());
QString hashedPassword = boardSalts.value(danbooruUrlComboBox->currentText());
hashedPassword = hashedPassword.arg(currentBoard);
hashedPassword = QCryptographicHash::hash(hashedPassword.toUtf8(),
QCryptographicHash::Sha1).toHex();
m_password = hashedPassword;