From 4dfafe1513717dd097d04ad0b92ae0a2f2689fa6 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:26:06 +0200 Subject: [PATCH 1/2] Prevent crash when opening NXM link before selecting instance --- src/moapplication.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/moapplication.cpp b/src/moapplication.cpp index bf6a4074..9a3e8ded 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -390,8 +390,14 @@ void MOApplication::externalMessage(const QString& message) } } } else if (isNxmLink(message)) { - MessageDialog::showMessage(tr("Download started"), qApp->activeWindow(), false); - m_core->downloadRequestedNXM(message); + if (InstanceManager::singleton().currentInstance()->gamePlugin() == nullptr) { + // This can happen if MO2 is started with the --pick option and no instance has + // been selected yet, in which case m_core will be null. + reportError(tr("No instance has been selected. Cannot download mod.")); + } else { + MessageDialog::showMessage(tr("Download started"), qApp->activeWindow(), false); + m_core->downloadRequestedNXM(message); + } } else { cl::CommandLine cl; From fef08ef33c85083eaa28475959c5f7a1a82fe511 Mon Sep 17 00:00:00 2001 From: Jonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com> Date: Tue, 15 Oct 2024 08:47:46 +0200 Subject: [PATCH 2/2] Improve error message --- src/moapplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/moapplication.cpp b/src/moapplication.cpp index 9a3e8ded..f06a85d1 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -393,7 +393,7 @@ void MOApplication::externalMessage(const QString& message) if (InstanceManager::singleton().currentInstance()->gamePlugin() == nullptr) { // This can happen if MO2 is started with the --pick option and no instance has // been selected yet, in which case m_core will be null. - reportError(tr("No instance has been selected. Cannot download mod.")); + reportError(tr("You need to select an instance before trying to download mods.")); } else { MessageDialog::showMessage(tr("Download started"), qApp->activeWindow(), false); m_core->downloadRequestedNXM(message);