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

Bugfix - don't allow multiple dialogs for same tx in TransactionView #817

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/qt/transactiondescdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *pa
ui(new Ui::TransactionDescDialog)
{
ui->setupUi(this);
setWindowTitle(tr("Details for %1").arg(idx.data(TransactionTableModel::TxHashRole).toString()));
m_transaction_id = idx.data(TransactionTableModel::TxHashRole).toString();
setWindowTitle(tr("Details for %1").arg(m_transaction_id));
QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString();
ui->detailText->setHtml(desc);

Expand Down
4 changes: 4 additions & 0 deletions src/qt/transactiondescdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_QT_TRANSACTIONDESCDIALOG_H

#include <QDialog>
#include <QString>

namespace Ui {
class TransactionDescDialog;
Expand All @@ -24,8 +25,11 @@ class TransactionDescDialog : public QDialog
explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = nullptr);
~TransactionDescDialog();

QString getTransactionId() {return m_transaction_id;};

private:
Ui::TransactionDescDialog *ui;
QString m_transaction_id;
};

#endif // BITCOIN_QT_TRANSACTIONDESCDIALOG_H
28 changes: 21 additions & 7 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QPoint>
#include <QScrollBar>
#include <QSettings>
#include <QString>
#include <QTableView>
#include <QTimer>
#include <QUrl>
Expand Down Expand Up @@ -528,13 +529,15 @@ void TransactionView::showDetails()
QModelIndexList selection = transactionView->selectionModel()->selectedRows();
if(!selection.isEmpty())
{
TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0));
dlg->setAttribute(Qt::WA_DeleteOnClose);
m_opened_dialogs.append(dlg);
connect(dlg, &QObject::destroyed, [this, dlg] {
m_opened_dialogs.removeOne(dlg);
});
dlg->show();
if(!detailsAlreadyShown(selection.at(0))) {
TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0));
dlg->setAttribute(Qt::WA_DeleteOnClose);
m_opened_dialogs.append(dlg);
connect(dlg, &QObject::destroyed, [this, dlg] {
m_opened_dialogs.removeOne(dlg);
});
dlg->show();
}
}
}

Expand Down Expand Up @@ -663,3 +666,14 @@ void TransactionView::closeOpenedDialogs()
}
m_opened_dialogs.clear();
}

bool TransactionView::detailsAlreadyShown(const QModelIndex &idx)
{
for (TransactionDescDialog* dlg : m_opened_dialogs) {
if (dlg->getTransactionId() == idx.data(TransactionTableModel::TxHashRole).toString()) {
GUIUtil::bringToFront(dlg);
return true;
}
}
return false;
}
1 change: 1 addition & 0 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private Q_SLOTS:
void updateWatchOnlyColumn(bool fHaveWatchOnly);
void abandonTx();
void bumpFee(bool checked);
bool detailsAlreadyShown(const QModelIndex &idx);

Q_SIGNALS:
void doubleClicked(const QModelIndex&);
Expand Down
Loading