Skip to content
Permalink
Browse files

Fix crashing if you click back while update is still downloading, the…

…n go back to updates menu (Thanks 123DMWM)
  • Loading branch information...
UnknownShadow200 committed May 12, 2019
1 parent 0f86255 commit 22e3252b0e77ed21607bb7553df59a0ffac5724b
Showing with 29 additions and 7 deletions.
  1. +11 −3 src/LScreens.c
  2. +9 −3 src/LWeb.c
  3. +9 −1 src/Window.c
@@ -1609,16 +1609,24 @@ static void UpdatesScreen_Tick(struct LScreen* 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 UpdatesScreen* s = &UpdatesScreen_Instance;
LScreen_Reset((struct LScreen*)s);
s->Init = UpdatesScreen_Init;
s->Draw = UpdatesScreen_Draw;
s->Tick = UpdatesScreen_Tick;
s->Free = UpdatesScreen_Free;
s->Reposition = UpdatesScreen_Reposition;

s->BuildName = NULL;
s->BuildProgress = -1;
return (struct LScreen*)s;
}
#endif
@@ -531,10 +531,17 @@ void FetchUpdateTask_Run(bool release, bool d3d9) {
const char* exe_ogl = "ClassiCube.unknown";
#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_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",
release ? "release" : "latest",
d3d9 ? exe_d3d9 : exe_ogl);
@@ -543,8 +550,7 @@ void FetchUpdateTask_Run(bool release, bool d3d9) {
LWebTask_Reset(&FetchUpdateTask.Base);
FetchUpdateTask.Timestamp = release ? CheckUpdateTask.RelTimestamp : CheckUpdateTask.DevTimestamp;

FetchUpdateTask.Base.Identifier = id;
Http_AsyncGetData(&url, false, &id);
Http_AsyncGetData(&url, false, &FetchUpdateTask.Base.Identifier);
FetchUpdateTask.Base.Handle = FetchUpdateTask_Handle;
}

@@ -711,7 +711,15 @@ void Window_EnableRawMouse(void) {
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) {
rawMouseEnabled = false;
Window_DefaultDisableRawMouse();

0 comments on commit 22e3252

Please sign in to comment.
You can’t perform that action at this time.