diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-25 08:57:59 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-04-25 08:57:59 +0300 |
commit | 7887ec31b59b40dcfa7eca225fbc788e2c961727 (patch) | |
tree | 865f94b57666fd9adf6699310377ded0a86b42c6 /src/ui/documentwidget.c | |
parent | d57240fea98543eb5b0394a3e01268ee2e08b6ec (diff) |
GmRequest: Use unique IDs to avoid confusion
It is conceivable that a newly created GmRequest gets the same memory location than the one just destroyed.
IssueID #148
Diffstat (limited to 'src/ui/documentwidget.c')
-rw-r--r-- | src/ui/documentwidget.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 11baf9ee..cdf3faa5 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -442,13 +442,21 @@ static void requestUpdated_DocumentWidget_(iAnyObject *obj) { | |||
442 | iDocumentWidget *d = obj; | 442 | iDocumentWidget *d = obj; |
443 | const int wasUpdated = exchange_Atomic(&d->isRequestUpdated, iTrue); | 443 | const int wasUpdated = exchange_Atomic(&d->isRequestUpdated, iTrue); |
444 | if (!wasUpdated) { | 444 | if (!wasUpdated) { |
445 | postCommand_Widget(obj, "document.request.updated doc:%p request:%p", d, d->request); | 445 | postCommand_Widget(obj, |
446 | "document.request.updated doc:%p reqid:%u request:%p", | ||
447 | d, | ||
448 | id_GmRequest(d->request), | ||
449 | d->request); | ||
446 | } | 450 | } |
447 | } | 451 | } |
448 | 452 | ||
449 | static void requestFinished_DocumentWidget_(iAnyObject *obj) { | 453 | static void requestFinished_DocumentWidget_(iAnyObject *obj) { |
450 | iDocumentWidget *d = obj; | 454 | iDocumentWidget *d = obj; |
451 | postCommand_Widget(obj, "document.request.finished doc:%p request:%p", d, d->request); | 455 | postCommand_Widget(obj, |
456 | "document.request.finished doc:%p reqid:%u request:%p", | ||
457 | d, | ||
458 | id_GmRequest(d->request), | ||
459 | d->request); | ||
452 | } | 460 | } |
453 | 461 | ||
454 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { | 462 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { |
@@ -1060,7 +1068,7 @@ static void updateDocument_DocumentWidget_(iDocumentWidget *d, const iGmResponse | |||
1060 | if (d->state == ready_RequestState) { | 1068 | if (d->state == ready_RequestState) { |
1061 | return; | 1069 | return; |
1062 | } | 1070 | } |
1063 | const iBool isRequestFinished = !d->request || isFinished_GmRequest(d->request); | 1071 | const iBool isRequestFinished = isFinished_GmRequest(d->request); |
1064 | /* TODO: Do document update in the background. However, that requires a text metrics calculator | 1072 | /* TODO: Do document update in the background. However, that requires a text metrics calculator |
1065 | that does not try to cache the glyph bitmaps. */ | 1073 | that does not try to cache the glyph bitmaps. */ |
1066 | const enum iGmStatusCode statusCode = response->statusCode; | 1074 | const enum iGmStatusCode statusCode = response->statusCode; |
@@ -2103,7 +2111,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
2103 | return iTrue; | 2111 | return iTrue; |
2104 | } | 2112 | } |
2105 | else if (equalWidget_Command(cmd, w, "document.request.updated") && | 2113 | else if (equalWidget_Command(cmd, w, "document.request.updated") && |
2106 | d->request && pointerLabel_Command(cmd, "request") == d->request) { | 2114 | id_GmRequest(d->request) == argU32Label_Command(cmd, "reqid")) { |
2107 | set_Block(&d->sourceContent, &lockResponse_GmRequest(d->request)->body); | 2115 | set_Block(&d->sourceContent, &lockResponse_GmRequest(d->request)->body); |
2108 | unlockResponse_GmRequest(d->request); | 2116 | unlockResponse_GmRequest(d->request); |
2109 | if (document_App() == d) { | 2117 | if (document_App() == d) { |
@@ -2114,7 +2122,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
2114 | return iFalse; | 2122 | return iFalse; |
2115 | } | 2123 | } |
2116 | else if (equalWidget_Command(cmd, w, "document.request.finished") && | 2124 | else if (equalWidget_Command(cmd, w, "document.request.finished") && |
2117 | d->request && pointerLabel_Command(cmd, "request") == d->request) { | 2125 | id_GmRequest(d->request) == argU32Label_Command(cmd, "reqid")) { |
2118 | set_Block(&d->sourceContent, body_GmRequest(d->request)); | 2126 | set_Block(&d->sourceContent, body_GmRequest(d->request)); |
2119 | if (!isSuccess_GmStatusCode(status_GmRequest(d->request))) { | 2127 | if (!isSuccess_GmStatusCode(status_GmRequest(d->request))) { |
2120 | format_String(&d->sourceHeader, | 2128 | format_String(&d->sourceHeader, |