mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
[Client] Skip the startup connection when a macOS URL launch owns the connection
This commit is contained in:
parent
d174307bce
commit
ad08fbbe79
2 changed files with 25 additions and 1 deletions
|
|
@ -708,6 +708,12 @@ void MainWindow::applyStartupDestination()
|
|||
return;
|
||||
}
|
||||
|
||||
// A cockatrice:// link owns the startup connection while its chain runs;
|
||||
// connecting here would race (and tear down) the link's own connection.
|
||||
if (skipStartupAutoConnect) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int destination = SettingsCache::instance().tabs().getStartupTabIndex();
|
||||
if (destination != StartupTab::StartupTabServer && destination != StartupTab::StartupTabServerRoom) {
|
||||
return;
|
||||
|
|
@ -936,6 +942,16 @@ void MainWindow::onUrlChainFinished(bool connected)
|
|||
if (connected || !skipStartupAutoConnect || getRemoteClient()->getStatus() != StatusDisconnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (startupDestinationConnectsToServer()) {
|
||||
// Users whose startup tab is a Server / Server Room connect through the
|
||||
// startup destination, not through auto-connect; retry that instead.
|
||||
qCInfo(WindowMainStartupAutoconnectLog) << "URL chain ended without a connection; retrying startup destination";
|
||||
skipStartupAutoConnect = false;
|
||||
applyStartupDestination();
|
||||
return;
|
||||
}
|
||||
|
||||
qCInfo(WindowMainStartupAutoconnectLog) << "URL chain ended without a connection; retrying startup connect";
|
||||
skipStartupAutoConnect = false;
|
||||
attemptStartupAutoConnect();
|
||||
|
|
|
|||
|
|
@ -331,9 +331,17 @@ int main(int argc, char *argv[])
|
|||
// URL connects to the server named in the URL, so the window's own startup
|
||||
// auto-connect must not race against it (two connectToServer calls tear
|
||||
// each other down via doDisconnectFromServer).
|
||||
const bool hasUrlActivation = std::any_of(startupFiles.begin(), startupFiles.end(), [](const QString &file) {
|
||||
bool hasUrlActivation = std::any_of(startupFiles.begin(), startupFiles.end(), [](const QString &file) {
|
||||
return file.startsWith(QStringLiteral("cockatrice://"));
|
||||
});
|
||||
#ifdef Q_OS_MAC
|
||||
// On macOS the launch can arrive through the URL scheme instead of as a
|
||||
// positional argument (captured in pendingMacUrls); count those too or the
|
||||
// window would auto-connect into the link's own connection attempt.
|
||||
hasUrlActivation = hasUrlActivation ||
|
||||
std::any_of(pendingMacUrls.cbegin(), pendingMacUrls.cend(),
|
||||
[](const QString &url) { return url.startsWith(QStringLiteral("cockatrice://")); });
|
||||
#endif
|
||||
ui.setSkipStartupAutoConnect(hasUrlActivation);
|
||||
|
||||
auto handleActivation = [&ui](const QString &file) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue