On 08/02/10 13:30, Alexander Nicolaysen Sørnes wrote:
These are displayed in Internet Explorer.
Alexander N. Sørnes
+LPCWSTR get_statustext(INT id, BOOL has_arg, LPCWSTR arg_in)
WHy do you need has_arg argument? Isn't NULL arg_in enough to recognize no argument?
+{ + static LPWSTR strings[NUM_STATUS_STRINGS]; + int index = id - IDS_STATUS_DONE; + DWORD maxlen = 255; + DWORD len = maxlen; + LPWSTR* p = &strings[index]; + + if(!*p) + { + if(has_arg) + len *= 3; + + *p = heap_alloc(len * sizeof(WCHAR)); + len = LoadStringW(hInst, id, *p, len); + len++; + + if(!has_arg) + *p = heap_realloc(*p, len * sizeof(WCHAR)); + } + + if(has_arg) + { + LPWSTR p2 = strings[index] + maxlen; + LPCWSTR arg = arg_in; + + if(!arg) + { + const WCHAR empty = 0; + arg = ∅ + ERR("Missing arg for message (id=%d) '%s'\n", id, debugstr_w(strings[index])); + } + snprintfW(p2, (maxlen * 2) - 1, strings[index], arg); + + return p2; + } + + return *p; +}
This caching mechanism is broken and not thread safe.
+ LPCWSTR text = get_statustext(IDS_STATUS_DONE, FALSE, NULL); + IOleInPlaceFrame_SetStatusText(doc_obj->frame, text);
The helper function should take care of calling SetStatusText.
if(doc->frame) - IOleInPlaceFrame_SetStatusText(doc->frame, NULL /* FIXME */); + { + LPCWSTR text = get_statustext(IDS_STATUS_DOWNLOADINGFROM, TRUE, task->url); + CoTaskMemFree(task->url); + IOleInPlaceFrame_SetStatusText(doc->frame, text); + }
You leak task->url here if doc->frame is NULL.
Jacek