Commit f9c875dd authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Fixed status text cache implementation.

parent 2d206abe
...@@ -49,7 +49,7 @@ DWORD mshtml_tls = TLS_OUT_OF_INDEXES; ...@@ -49,7 +49,7 @@ DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
static HINSTANCE shdoclc = NULL; static HINSTANCE shdoclc = NULL;
static HDC display_dc; static HDC display_dc;
static LPWSTR status_strings[NUM_STATUS_STRINGS]; static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
static void thread_detach(void) static void thread_detach(void)
{ {
...@@ -68,7 +68,7 @@ static void thread_detach(void) ...@@ -68,7 +68,7 @@ static void thread_detach(void)
static void free_strings(void) static void free_strings(void)
{ {
int i; int i;
for(i = 0; i < NUM_STATUS_STRINGS; i++) for(i = 0; i < sizeof(status_strings)/sizeof(*status_strings); i++)
heap_free(status_strings[i]); heap_free(status_strings[i]);
} }
...@@ -89,30 +89,29 @@ static void process_detach(void) ...@@ -89,30 +89,29 @@ static void process_detach(void)
void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg) void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg)
{ {
int index = id - IDS_STATUS_DONE; int index = id - IDS_STATUS_FIRST;
LPWSTR p = status_strings[index]; WCHAR *p = status_strings[index];
DWORD len;
if(!doc->frame) if(!doc->frame)
return; return;
if(!p) if(!p) {
{ len = 255;
DWORD len = 255;
p = heap_alloc(len * sizeof(WCHAR)); p = heap_alloc(len * sizeof(WCHAR));
len = LoadStringW(hInst, id, p, len); len = LoadStringW(hInst, id, p, len) + 1;
len++;
p = heap_realloc(p, len * sizeof(WCHAR)); p = heap_realloc(p, len * sizeof(WCHAR));
if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) {
{
heap_free(p); heap_free(p);
p = status_strings[index]; p = status_strings[index];
} }
} }
if(arg) if(arg) {
{ WCHAR *buf;
DWORD len = lstrlenW(p) + lstrlenW(arg) - 1;
LPWSTR buf = heap_alloc(len * sizeof(WCHAR)); len = lstrlenW(p) + lstrlenW(arg) - 1;
buf = heap_alloc(len * sizeof(WCHAR));
snprintfW(buf, len, p, arg); snprintfW(buf, len, p, arg);
......
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
#define IDS_HTMLDISABLED 7500 #define IDS_HTMLDISABLED 7500
#define IDS_HTMLDOCUMENT 7501 #define IDS_HTMLDOCUMENT 7501
#define NUM_STATUS_STRINGS 2 #define IDS_STATUS_FIRST 7550
#define IDS_STATUS_DOWNLOADINGFROM 7550 #define IDS_STATUS_DOWNLOADINGFROM IDS_STATUS_FIRST
#define IDS_STATUS_DONE 7551 #define IDS_STATUS_DONE (IDS_STATUS_FIRST+1)
#define IDS_STATUS_LAST IDS_STATUS_DONE
#define ID_PROMPT_DIALOG 7700 #define ID_PROMPT_DIALOG 7700
#define ID_PROMPT_PROMPT 7701 #define ID_PROMPT_PROMPT 7701
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment