Skip to content

Commit 8ddc303

Browse files
committed
Merge #17031: gui: Prevent processing duplicate payment requests
3f89e1e Prevent processing duplicate payment requests (João Barbosa) Pull request description: Considering the following from Qt [src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm#L267](https://github.com/qt/qtbase/blob/13e0a36626bd75e631dd9536e795a494432b1945/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm#L267) ```cpp - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { Q_UNUSED(filenames); Q_UNUSED(sender); for (NSString *fileName in filenames) { QString qtFileName = QString::fromNSString(fileName); if (inLaunch) { // We need to be careful because Cocoa will be nice enough to take // command line arguments and send them to us as events. Given the history // of Qt Applications, this will result in behavior people don't want, as // they might be doing the opening themselves with the command line parsing. if (qApp->arguments().contains(qtFileName)) continue; } QWindowSystemInterface::handleFileOpenEvent(qtFileName); } ``` And that a2714a5 was merged, now Qt isn't able to filter out the above notifications, and then a [QFileOpenEvent](https://doc.qt.io/qt-5/qfileopenevent.html) event is delivered to `PaymentServer::eventFilter`, which in turn (re)adds the payment request. This change fixes #17025, but makes sense regardless of the issue. ACKs for top commit: laanwj: Nah, this seems fine, utACK 3f89e1e Sjors: ACK 3f89e1e on macOS 10.14.6 achow101: Code review ACK 3f89e1e Tree-SHA512: dd1e0c73fd84953418173ca71f6f5a67ad74a5dc7e3b1d54915ef0545f513df6a24f27242a77bb094e2833a478e2f3bf30ecd50251f3c55b65e780097cb8ab4d
2 parents f1f284a + 3f89e1e commit 8ddc303

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/qt/paymentserver.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static QString ipcServerName()
8282
// the main GUI window is up and ready to ask the user
8383
// to send payment.
8484

85-
static QList<QString> savedPaymentRequests;
85+
static QSet<QString> savedPaymentRequests;
8686

8787
//
8888
// Sending to the server is done synchronously, at startup.
@@ -107,7 +107,8 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
107107
// will start a mainnet instance and throw a "wrong network" error.
108108
if (arg.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
109109
{
110-
savedPaymentRequests.append(arg);
110+
if (savedPaymentRequests.contains(arg)) continue;
111+
savedPaymentRequests.insert(arg);
111112

112113
SendCoinsRecipient r;
113114
if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty())
@@ -127,7 +128,8 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
127128
#ifdef ENABLE_BIP70
128129
else if (QFile::exists(arg)) // Filename
129130
{
130-
savedPaymentRequests.append(arg);
131+
if (savedPaymentRequests.contains(arg)) continue;
132+
savedPaymentRequests.insert(arg);
131133

132134
PaymentRequestPlus request;
133135
if (readPaymentRequestFromFile(arg, request))
@@ -280,7 +282,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
280282
{
281283
if (saveURIs)
282284
{
283-
savedPaymentRequests.append(s);
285+
savedPaymentRequests.insert(s);
284286
return;
285287
}
286288

0 commit comments

Comments
 (0)