mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 20:15:35 -04:00
Fix crashing if you click back while update is still downloading, then go back to updates menu (Thanks 123DMWM)
This commit is contained in:
parent
0f862553ac
commit
22e3252b0e
@ -1609,16 +1609,24 @@ static void UpdatesScreen_Tick(struct LScreen* s_) {
|
|||||||
UpdatesScreen_CheckTick(s);
|
UpdatesScreen_CheckTick(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Aborts fetch if it is in progress */
|
||||||
|
static void UpdatesScreen_Free(struct LScreen* s_) {
|
||||||
|
struct UpdatesScreen* s = (struct UpdatesScreen*)s_;
|
||||||
|
s->BuildName = NULL;
|
||||||
|
s->BuildProgress = -1;
|
||||||
|
|
||||||
|
FetchUpdateTask.Base.Working = false;
|
||||||
|
s->LblStatus.Text.length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct LScreen* UpdatesScreen_MakeInstance(void) {
|
struct LScreen* UpdatesScreen_MakeInstance(void) {
|
||||||
struct UpdatesScreen* s = &UpdatesScreen_Instance;
|
struct UpdatesScreen* s = &UpdatesScreen_Instance;
|
||||||
LScreen_Reset((struct LScreen*)s);
|
LScreen_Reset((struct LScreen*)s);
|
||||||
s->Init = UpdatesScreen_Init;
|
s->Init = UpdatesScreen_Init;
|
||||||
s->Draw = UpdatesScreen_Draw;
|
s->Draw = UpdatesScreen_Draw;
|
||||||
s->Tick = UpdatesScreen_Tick;
|
s->Tick = UpdatesScreen_Tick;
|
||||||
|
s->Free = UpdatesScreen_Free;
|
||||||
s->Reposition = UpdatesScreen_Reposition;
|
s->Reposition = UpdatesScreen_Reposition;
|
||||||
|
|
||||||
s->BuildName = NULL;
|
|
||||||
s->BuildProgress = -1;
|
|
||||||
return (struct LScreen*)s;
|
return (struct LScreen*)s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
12
src/LWeb.c
12
src/LWeb.c
@ -531,10 +531,17 @@ void FetchUpdateTask_Run(bool release, bool d3d9) {
|
|||||||
const char* exe_ogl = "ClassiCube.unknown";
|
const char* exe_ogl = "ClassiCube.unknown";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const static String id = String_FromConst("CC update fetch");
|
static char idBuffer[24];
|
||||||
|
static int idCounter;
|
||||||
String url; char urlBuffer[URL_MAX_SIZE];
|
String url; char urlBuffer[URL_MAX_SIZE];
|
||||||
String_InitArray(url, urlBuffer);
|
String_InitArray(url, urlBuffer);
|
||||||
|
|
||||||
|
String_InitArray(FetchUpdateTask.Base.Identifier, idBuffer);
|
||||||
|
String_Format1(&FetchUpdateTask.Base.Identifier, "CC update fetch%i", &idCounter);
|
||||||
|
/* User may click another update button in the updates menu before original update finished downloading */
|
||||||
|
/* Hence must use a different ID for each update fetch, otherwise old update gets downloaded and applied */
|
||||||
|
idCounter++;
|
||||||
|
|
||||||
String_Format2(&url, "http://cs.classicube.net/c_client/%c/%c",
|
String_Format2(&url, "http://cs.classicube.net/c_client/%c/%c",
|
||||||
release ? "release" : "latest",
|
release ? "release" : "latest",
|
||||||
d3d9 ? exe_d3d9 : exe_ogl);
|
d3d9 ? exe_d3d9 : exe_ogl);
|
||||||
@ -543,8 +550,7 @@ void FetchUpdateTask_Run(bool release, bool d3d9) {
|
|||||||
LWebTask_Reset(&FetchUpdateTask.Base);
|
LWebTask_Reset(&FetchUpdateTask.Base);
|
||||||
FetchUpdateTask.Timestamp = release ? CheckUpdateTask.RelTimestamp : CheckUpdateTask.DevTimestamp;
|
FetchUpdateTask.Timestamp = release ? CheckUpdateTask.RelTimestamp : CheckUpdateTask.DevTimestamp;
|
||||||
|
|
||||||
FetchUpdateTask.Base.Identifier = id;
|
Http_AsyncGetData(&url, false, &FetchUpdateTask.Base.Identifier);
|
||||||
Http_AsyncGetData(&url, false, &id);
|
|
||||||
FetchUpdateTask.Base.Handle = FetchUpdateTask_Handle;
|
FetchUpdateTask.Base.Handle = FetchUpdateTask_Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/Window.c
10
src/Window.c
@ -711,7 +711,15 @@ void Window_EnableRawMouse(void) {
|
|||||||
rawMouseInited = true;
|
rawMouseInited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_UpdateRawMouse(void) { Window_CentreMousePosition(); }
|
void Window_UpdateRawMouse(void) {
|
||||||
|
if (rawMouseSupported) {
|
||||||
|
/* handled in WM_INPUT messages */
|
||||||
|
Window_CentreMousePosition();
|
||||||
|
} else {
|
||||||
|
Window_DefaultUpdateRawMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Window_DisableRawMouse(void) {
|
void Window_DisableRawMouse(void) {
|
||||||
rawMouseEnabled = false;
|
rawMouseEnabled = false;
|
||||||
Window_DefaultDisableRawMouse();
|
Window_DefaultDisableRawMouse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user