View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001760 | OpenMPT | Installer and Update | public | 2024-03-24 13:12 | 2024-10-10 08:15 |
| Reporter | Saga Musix | Assigned To | manx | ||
| Priority | low | Severity | minor | Reproducibility | sometimes |
| Status | resolved | Resolution | fixed | ||
| Product Version | OpenMPT 1.31.06.00 / libopenmpt 0.7.6 (upgrade first) | ||||
| Fixed in Version | OpenMPT 1.31.07.00 / libopenmpt 0.7.7 (upgrade first) | ||||
| Summary | 0001760: Closing OpenMPT while updates are fetched in the background can lead to a crash | ||||
| Description | When updates are automatically searche for on OpenMPT startup, and the OpenMPT window is closed while the update is still running in the background, we try to access the | ||||
| Tags | No tags attached. | ||||
| Has the bug occurred in previous versions? | |||||
| Tested code revision (in case you know it) | |||||
|
A simple and good solution is surprisingly difficult because we need the message loop to be running for any communication with the update check thread to be possible at all. update-check-cancel-on-exit-v1.patch (2,720 bytes)
Index: mptrack/MainFrm.cpp
===================================================================
--- mptrack/MainFrm.cpp (revision 20463)
+++ mptrack/MainFrm.cpp (working copy)
@@ -375,6 +375,10 @@
}
}
+#if defined(MPT_ENABLE_UPDATE)
+ m_cancelUpdateCheck = true;
+#endif // MPT_ENABLE_UPDATE
+
CChildFrame *pMDIActive = (CChildFrame *)MDIGetActive();
BeginWaitCursor();
@@ -400,6 +404,10 @@
m_InputHandler->m_activeCommandSet->SaveFile(TrackerSettings::Instance().m_szKbdFile);
}
+#if defined(MPT_ENABLE_UPDATE)
+ CUpdateCheck::WaitForUpdateCheckFinished();
+#endif // MPT_ENABLE_UPDATE
+
EndWaitCursor();
CMDIFrameWnd::OnClose();
}
@@ -2765,6 +2773,10 @@
LRESULT CMainFrame::OnUpdateCheckProgress(WPARAM wparam, LPARAM lparam)
{
+ if(m_cancelUpdateCheck)
+ {
+ return FALSE;
+ }
bool isAutoUpdate = wparam != 0;
CString updateText = MPT_CFORMAT("Checking for updates... {}%")(lparam);
if(isAutoUpdate)
Index: mptrack/Mainfrm.h
===================================================================
--- mptrack/Mainfrm.h (revision 20463)
+++ mptrack/Mainfrm.h (working copy)
@@ -191,6 +191,7 @@
#if defined(MPT_ENABLE_UPDATE)
class CUpdateSetupDlg *m_UpdateOptionsDialog = nullptr;
std::unique_ptr<UpdateCheckResult> m_updateCheckResult;
+ bool m_cancelUpdateCheck = false;
#endif // MPT_ENABLE_UPDATE
DWORD helpCookie = 0;
bool m_bOptionsLocked = false;
Index: mptrack/UpdateCheck.cpp
===================================================================
--- mptrack/UpdateCheck.cpp (revision 20463)
+++ mptrack/UpdateCheck.cpp (working copy)
@@ -462,6 +462,24 @@
}
+void CUpdateCheck::WaitForUpdateCheckFinished()
+{
+ while(GetNumCurrentRunningInstances() > 0)
+ {
+ MSG msg;
+ while(::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+ }
+ if(GetNumCurrentRunningInstances() > 0)
+ {
+ Sleep(1);
+ }
+ }
+}
+
+
// Start update check
void CUpdateCheck::StartUpdateCheckAsync(bool isAutoUpdate)
{
Index: mptrack/UpdateCheck.h
===================================================================
--- mptrack/UpdateCheck.h (revision 20463)
+++ mptrack/UpdateCheck.h (working copy)
@@ -62,7 +62,7 @@
static std::vector<mpt::ustring> GetDefaultUpdateSigningKeysRootAnchors();
static mpt::ustring GetDefaultAPIURL();
- int32 GetNumCurrentRunningInstances();
+ static int32 GetNumCurrentRunningInstances();
static bool IsSuitableUpdateMoment();
@@ -69,6 +69,8 @@
static void DoAutoUpdateCheck() { StartUpdateCheckAsync(true); }
static void DoManualUpdateCheck() { StartUpdateCheckAsync(false); }
+ static void WaitForUpdateCheckFinished();
+
public:
struct Context
|
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2024-03-24 13:12 | Saga Musix | New Issue | |
| 2024-03-24 13:12 | Saga Musix | Priority | normal => low |
| 2024-03-24 14:49 | manx | Note Added: 0005883 | |
| 2024-03-24 14:49 | manx | File Added: update-check-cancel-on-exit-v1.patch | |
| 2024-03-26 13:20 | manx | Assigned To | => manx |
| 2024-03-26 13:20 | manx | Status | new => resolved |
| 2024-03-26 13:20 | manx | Resolution | open => fixed |
| 2024-03-26 13:20 | manx | Fixed in Version | => OpenMPT 1.31.07.00 / libopenmpt 0.7.7 (upgrade first) |
| 2024-03-26 13:20 | manx | Note Added: 0005888 | |
| 2024-03-26 13:21 | manx | Relationship added | related to 0001763 |
| 2024-10-10 08:15 | manx | Category | General => Installer and Update |