diff --git a/src/CrashHandler.cpp b/src/CrashHandler.cpp index 5585d29436f..87bb7b8dd4d 100644 --- a/src/CrashHandler.cpp +++ b/src/CrashHandler.cpp @@ -401,7 +401,7 @@ static DWORD WINAPI CrashDumpThread(LPVOID) { // set the SUMATRAPDF_FULLDUMP environment variable for more complete dumps DWORD n = GetEnvironmentVariableA("SUMATRAPDF_FULLDUMP", nullptr, 0); bool fullDump = (0 != n); - WCHAR* ws = ToWStrTemp(gCrashDumpPath); + TempWStr ws = ToWStrTemp(gCrashDumpPath); dbghelp::WriteMiniDump(ws, &gMei, fullDump); return 0; } diff --git a/src/Favorites.cpp b/src/Favorites.cpp index 27029f396f9..2c05d620d3f 100644 --- a/src/Favorites.cpp +++ b/src/Favorites.cpp @@ -331,7 +331,7 @@ static void AppendFavMenuItems(HMENU m, FileState* f, int& idx, bool combined, b s = FavReadableNameTemp(fn); } auto safeStr = MenuToSafeStringTemp(s); - WCHAR* ws = ToWStrTemp(safeStr); + TempWStr ws = ToWStrTemp(safeStr); AppendMenuW(m, MF_STRING, (UINT_PTR)fn->menuId, ws); } } diff --git a/src/Menu.cpp b/src/Menu.cpp index 27475e8981f..9634f9fa327 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -1397,7 +1397,7 @@ HMENU BuildMenuFromMenuDef(MenuDef* menuDef, HMENU menu, BuildMenuCtx* ctx) { if (subMenuDef == menuDefFile) { DynamicPartOfFileMenu(subMenu, ctx); } - WCHAR* ws = ToWStrTemp(title); + TempWStr ws = ToWStrTemp(title); AppendMenuW(menu, flags, (UINT_PTR)subMenu, ws); } else { str::Str title2 = title; @@ -1408,7 +1408,7 @@ HMENU BuildMenuFromMenuDef(MenuDef* menuDef, HMENU menu, BuildMenuCtx* ctx) { } } UINT flags = MF_STRING | (disableMenu ? MF_DISABLED : MF_ENABLED); - WCHAR* ws = ToWStrTemp(title2.Get()); + TempWStr ws = ToWStrTemp(title2.Get()); AppendMenuW(menu, flags, md.idOrSubmenu, ws); } @@ -1514,7 +1514,7 @@ void MenuUpdatePrintItem(MainWindow* win, HMENU menu, bool disableOnly = false) } } if (!filePrintAllowed || !disableOnly) { - WCHAR* ws = ToWStrTemp(printItem.Get()); + TempWStr ws = ToWStrTemp(printItem.Get()); ModifyMenuW(menu, CmdPrint, MF_BYCOMMAND | MF_STRING, (UINT_PTR)CmdPrint, ws); } MenuSetEnabled(menu, CmdPrint, filePrintEnabled && filePrintAllowed); @@ -2214,7 +2214,7 @@ void MenuCustomDrawItem(HWND hwnd, DRAWITEMSTRUCT* dis) { // DrawTextEx handles & => underscore drawing rc.top += padY; rc.left += cxCheckMark; - WCHAR* ws = ToWStrTemp(menuText); + TempWStr ws = ToWStrTemp(menuText); DrawTextExW(hdc, ws, -1, &rc, DT_LEFT, nullptr); if (shortcutText != nullptr) { ws = ToWStrTemp(shortcutText); diff --git a/src/PdfSync.cpp b/src/PdfSync.cpp index 2f55ff55719..fd5a7b5e95f 100644 --- a/src/PdfSync.cpp +++ b/src/PdfSync.cpp @@ -532,7 +532,7 @@ int SyncTex::RebuildIndexIfNeeded() { TempStr syncPathTemp = str::DupTemp(syncFilePath.Get()); Repeat: - WCHAR* ws = ToWStrTemp(syncPathTemp); + TempWStr ws = ToWStrTemp(syncPathTemp); AutoFreeStr pathAnsi = strconv::WstrToAnsi(ws); scanner = synctex_scanner_new_with_output_file(pathAnsi, nullptr, 1); if (scanner) { diff --git a/src/SearchAndDDE.cpp b/src/SearchAndDDE.cpp index f435c27e616..83bd94806f6 100644 --- a/src/SearchAndDDE.cpp +++ b/src/SearchAndDDE.cpp @@ -395,7 +395,7 @@ void FindTextOnThread(MainWindow* win, TextSearchDirection direction, const char // TODO: for https://github.com/sumatrapdfreader/sumatrapdf/issues/2655 char* ReverseTextTemp(char* s) { - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); int n = str::Leni(ws); for (int i = 0; i < n / 2; i++) { WCHAR c1 = ws[i]; diff --git a/src/SumatraDialogs.cpp b/src/SumatraDialogs.cpp index 83f8a8654a3..25033368317 100644 --- a/src/SumatraDialogs.cpp +++ b/src/SumatraDialogs.cpp @@ -757,7 +757,7 @@ static INT_PTR CALLBACK Dialog_Settings_Proc(HWND hDlg, UINT msg, WPARAM wp, LPA cmdLine = detected[0]; } for (char* s : detected) { - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); // if no existing command was selected then set the user custom command in the combo ComboBox_AddString(hwndComboBox, ws); } diff --git a/src/SumatraPDF.cpp b/src/SumatraPDF.cpp index 64e24cb769a..7b7328583ac 100644 --- a/src/SumatraPDF.cpp +++ b/src/SumatraPDF.cpp @@ -2753,7 +2753,7 @@ void CloseWindow(MainWindow* win, bool quitIfLast, bool forceClose) { } // returns false if no filter has been appended -static bool AppendFileFilterForDoc(DocController* ctrl, str::WStr& fileFilter) { +static bool AppendFileFilterForDoc(DocController* ctrl, str::Str& fileFilter) { // TODO: use ctrl->GetDefaultFileExt() Kind type = nullptr; if (ctrl->AsFixed()) { @@ -2764,32 +2764,32 @@ static bool AppendFileFilterForDoc(DocController* ctrl, str::WStr& fileFilter) { auto ext = ctrl->GetDefaultFileExt(); if (str::EqI(ext, ".xps")) { - fileFilter.Append(_TR("XPS documents")); + fileFilter.Append(_TRA("XPS documents")); } else if (type == kindEngineDjVu) { - fileFilter.Append(_TR("DjVu documents")); + fileFilter.Append(_TRA("DjVu documents")); } else if (type == kindEngineComicBooks) { - fileFilter.Append(_TR("Comic books")); + fileFilter.Append(_TRA("Comic books")); } else if (type == kindEngineImage) { WCHAR* extW = ToWStrTemp(ctrl->GetDefaultFileExt() + 1); - fileFilter.AppendFmt(_TR("Image files (*.%s)"), extW); + fileFilter.AppendFmt(_TRA("Image files (*.%s)"), extW); } else if (type == kindEngineImageDir) { return false; // only show "All files" } else if (type == kindEnginePostScript) { - fileFilter.Append(_TR("Postscript documents")); + fileFilter.Append(_TRA("Postscript documents")); } else if (type == kindEngineChm) { - fileFilter.Append(_TR("CHM documents")); + fileFilter.Append(_TRA("CHM documents")); } else if (type == kindEngineEpub) { - fileFilter.Append(_TR("EPUB ebooks")); + fileFilter.Append(_TRA("EPUB ebooks")); } else if (type == kindEngineMobi) { - fileFilter.Append(_TR("Mobi documents")); + fileFilter.Append(_TRA("Mobi documents")); } else if (type == kindEngineFb2) { - fileFilter.Append(_TR("FictionBook documents")); + fileFilter.Append(_TRA("FictionBook documents")); } else if (type == kindEnginePdb) { - fileFilter.Append(_TR("PalmDoc documents")); + fileFilter.Append(_TRA("PalmDoc documents")); } else if (type == kindEngineTxt) { - fileFilter.Append(_TR("Text documents")); + fileFilter.Append(_TRA("Text documents")); } else { - fileFilter.Append(_TR("PDF documents")); + fileFilter.Append(_TRA("PDF documents")); } return true; } @@ -2825,20 +2825,20 @@ static void SaveCurrentFileAs(MainWindow* win) { return; } - TempWStr defExt = ToWStrTemp(ctrl->GetDefaultFileExt()); + auto defExt = ctrl->GetDefaultFileExt(); // Prepare the file filters (use \1 instead of \0 so that the // double-zero terminated string isn't cut by the string handling // methods too early on) - str::WStr fileFilter(256); + str::Str fileFilter(256); if (AppendFileFilterForDoc(ctrl, fileFilter)) { - fileFilter.AppendFmt(L"\1*%s\1", defExt); + fileFilter.AppendFmt("\1*%s\1", defExt); } - fileFilter.Append(_TR("All files")); - fileFilter.Append(L"\1*.*\1"); - str::TransCharsInPlace(fileFilter.Get(), L"\1", L"\0"); + fileFilter.Append(_TRA("All files")); + fileFilter.Append("\1*.*\1"); + str::TransCharsInPlace(fileFilter.CStr(), "\1", "\0"); WCHAR dstFileName[MAX_PATH]; - auto baseName = path::GetBaseNameTemp(srcFileName); + TempStr baseName = path::GetBaseNameTemp(srcFileName); str::BufSet(dstFileName, dimof(dstFileName), baseName); if (str::FindChar(dstFileName, ':')) { // handle embed-marks (for embedded PDF documents): @@ -2854,7 +2854,7 @@ static void SaveCurrentFileAs(MainWindow* win) { ext = colon; } memmove(ext, colon, (str::Len(colon) + 1) * sizeof(WCHAR)); - } else if (str::EndsWithI(dstFileName, defExt)) { + } else if (str::EndsWithI(dstFileName, ToWStrTemp(defExt))) { // Remove the extension so that it can be re-added depending on the chosen filter int idx = str::Leni(dstFileName) - str::Leni(defExt); dstFileName[idx] = '\0'; @@ -2865,13 +2865,13 @@ static void SaveCurrentFileAs(MainWindow* win) { ofn.hwndOwner = win->hwndFrame; ofn.lpstrFile = dstFileName; ofn.nMaxFile = dimof(dstFileName); - ofn.lpstrFilter = fileFilter.Get(); + ofn.lpstrFilter = ToWStrTemp(fileFilter); ofn.nFilterIndex = 1; // defExt can be null, we want to skip '.' if (str::Leni(defExt) > 0 && defExt[0] == L'.') { defExt++; } - ofn.lpstrDefExt = defExt; + ofn.lpstrDefExt = ToWStrTemp(defExt); ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; // note: explicitly not setting lpstrInitialDir so that the OS // picks a reasonable default (in particular, we don't want this @@ -2885,9 +2885,8 @@ static void SaveCurrentFileAs(MainWindow* win) { TempStr realDstFileName = ToUtf8Temp(dstFileName); // Make sure that the file has a valid extension - if (!str::EndsWithI(dstFileName, defExt)) { - TempWStr s = str::JoinTemp(dstFileName, defExt); - realDstFileName = ToUtf8(dstFileName); + if (!str::EndsWithI(realDstFileName, defExt)) { + realDstFileName = str::JoinTemp(realDstFileName, defExt); } logf("Saving '%s' to '%s'\n", srcFileName, realDstFileName); @@ -2984,19 +2983,20 @@ static void RenameCurrentFile(MainWindow* win) { // Prepare the file filters (use \1 instead of \0 so that the // double-zero terminated string isn't cut by the string handling // methods too early on) - const WCHAR* defExt = ToWStrTemp(ctrl->GetDefaultFileExt()); - str::WStr fileFilter(256); + const char* defExt = ctrl->GetDefaultFileExt(); + TempWStr defExtW = ToWStrTemp(defExt); + str::Str fileFilter(256); bool ok = AppendFileFilterForDoc(ctrl, fileFilter); CrashIf(!ok); - fileFilter.AppendFmt(L"\1*%s\1", defExt); - str::TransCharsInPlace(fileFilter.Get(), L"\1", L"\0"); + fileFilter.AppendFmt("\1*%s\1", defExt); + str::TransCharsInPlace(fileFilter.Get(), "\1", "\0"); WCHAR dstFileName[MAX_PATH]; auto baseName = path::GetBaseNameTemp(srcPath); str::BufSet(dstFileName, dimof(dstFileName), baseName); // Remove the extension so that it can be re-added depending on the chosen filter - if (str::EndsWithI(dstFileName, defExt)) { - int idx = str::Leni(dstFileName) - str::Leni(defExt); + if (str::EndsWithI(dstFileName, defExtW)) { + int idx = str::Leni(dstFileName) - str::Leni(defExtW); dstFileName[idx] = '\0'; } @@ -3008,12 +3008,13 @@ static void RenameCurrentFile(MainWindow* win) { ofn.hwndOwner = win->hwndFrame; ofn.lpstrFile = dstFileName; ofn.nMaxFile = dimof(dstFileName); - ofn.lpstrFilter = fileFilter.Get(); + ofn.lpstrFilter = ToWStrTemp(fileFilter); + ; ofn.nFilterIndex = 1; // note: the other two dialogs are named "Open" and "Save As" ofn.lpstrTitle = _TR("Rename To"); ofn.lpstrInitialDir = initDir; - ofn.lpstrDefExt = defExt + 1; + ofn.lpstrDefExt = defExtW + 1; ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; ok = GetSaveFileNameW(&ofn); diff --git a/src/SumatraProperties.cpp b/src/SumatraProperties.cpp index 2213340c1b1..0e2cb3f9531 100644 --- a/src/SumatraProperties.cpp +++ b/src/SumatraProperties.cpp @@ -560,7 +560,7 @@ static void GetProps(DocController* ctrl, PropertiesLayout* layoutData, bool ext if (IsUIRightToLeft() && IsWindowsVistaOrGreater()) { // ensure that the size remains ungarbled left-to-right // (note: XP doesn't know about \u202A...\u202C) - WCHAR* ws = ToWStrTemp(strTemp); + TempWStr ws = ToWStrTemp(strTemp); ws = str::Format(L"\u202A%s\u202C", ws); strTemp = ToUtf8Temp(ws); str::Free(ws); diff --git a/src/TableOfContents.cpp b/src/TableOfContents.cpp index 2a864fe7611..216235f9211 100644 --- a/src/TableOfContents.cpp +++ b/src/TableOfContents.cpp @@ -379,7 +379,7 @@ static void GetLeftRightCounts(TocItem* node, int& l2r, int& r2l) { return; } if (node->title) { - WCHAR* ws = ToWStrTemp(node->title); + TempWStr ws = ToWStrTemp(node->title); for (const WCHAR* c = ws; *c; c++) { if (isLeftToRightChar(*c)) { l2r++; diff --git a/src/scratch.txt b/src/scratch.txt index b2ee6d14394..80e8c27e212 100644 --- a/src/scratch.txt +++ b/src/scratch.txt @@ -1,7 +1,7 @@ Ideas for refactorings: - change all size_t => int -- remove all use of _TR( : 61 matches (was 74, 94, 141) +- remove all use of _TR( : 48 matches (was 61, 74, 94, 141) - change use of Str::Get() => Str::CStr() (or maybe make it Str() as in StrSpan?) ------------------------------------------------------------------ diff --git a/src/utils/BaseUtil.h b/src/utils/BaseUtil.h index ff6b4e58f77..1641bed798f 100644 --- a/src/utils/BaseUtil.h +++ b/src/utils/BaseUtil.h @@ -667,10 +667,14 @@ defer { fclose(f); }; defer { instance->Release(); }; */ +// exists just to mark the intent, needed by both StrUtil.h and TempAllocator.h +using TempStr = char*; +using TempWStr = WCHAR*; + #include "GeomUtil.h" #include "Vec.h" -#include "TempAllocator.h" #include "StrUtil.h" +#include "TempAllocator.h" #include "StrVec.h" #include "StrconvUtil.h" #include "Scoped.h" diff --git a/src/utils/FileUtil.cpp b/src/utils/FileUtil.cpp index 9f6b609c0bf..a604d5ed4cc 100644 --- a/src/utils/FileUtil.cpp +++ b/src/utils/FileUtil.cpp @@ -463,7 +463,7 @@ bool Match(const char* path, const char* filter) { } bool IsAbsolute(const char* path) { - WCHAR* ws = ToWStrTemp(path); + TempWStr ws = ToWStrTemp(path); return !PathIsRelativeW(ws); } diff --git a/src/utils/StrconvUtil.cpp b/src/utils/StrconvUtil.cpp index 3208e5516b5..a6ee4a98853 100644 --- a/src/utils/StrconvUtil.cpp +++ b/src/utils/StrconvUtil.cpp @@ -160,7 +160,7 @@ char* WstrToAnsi(const WCHAR* src) { } char* Utf8ToAnsi(const char* s) { - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); return WstrToAnsi(ws); } diff --git a/src/utils/TempAllocator.cpp b/src/utils/TempAllocator.cpp index c04afe3f13d..59d6961a4c8 100644 --- a/src/utils/TempAllocator.cpp +++ b/src/utils/TempAllocator.cpp @@ -131,3 +131,13 @@ TempWStr ToWStrTemp(const char* s, size_t cb) { } return strconv::Utf8ToWstr(s, cb, GetTempAllocator()); } + +// handles embedded 0 in the string +TempWStr ToWStrTemp(const str::Str& str) { + if (str.IsEmpty()) { + return nullptr; + } + char* s = str.CStr(); + size_t cb = str.Size(); + return strconv::Utf8ToWstr(s, cb, GetTempAllocator()); +} diff --git a/src/utils/TempAllocator.h b/src/utils/TempAllocator.h index a3119853fc3..83c773cb99c 100644 --- a/src/utils/TempAllocator.h +++ b/src/utils/TempAllocator.h @@ -13,10 +13,6 @@ FORCEINLINE T* AllocArrayTemp(size_t n) { return (T*)Allocator::AllocZero(a, n * sizeof(T)); } -// exists just to mark the intentA -using TempStr = char*; -using TempWStr = WCHAR*; - namespace str { TempStr DupTemp(const char* s, size_t cb = (size_t)-1); TempWStr DupTemp(const WCHAR* s, size_t cch = (size_t)-1); @@ -33,3 +29,4 @@ TempStr FormatTemp(const char* fmt, ...); TempStr ToUtf8Temp(const WCHAR* s, size_t cch = (size_t)-1); TempWStr ToWStrTemp(const char* s, size_t cb = (size_t)-1); +TempWStr ToWStrTemp(const str::Str& s); diff --git a/src/utils/ThreadUtil.cpp b/src/utils/ThreadUtil.cpp index a19807b2876..3f5afd28055 100644 --- a/src/utils/ThreadUtil.cpp +++ b/src/utils/ThreadUtil.cpp @@ -30,7 +30,7 @@ typedef struct tagTHREADNAME_INFO { #pragma warning(disable : 6322) // silence /analyze: Empty _except block void SetThreadName(const char* threadName, DWORD threadId) { if (DynSetThreadDescription && threadId == 0) { - WCHAR* ws = ToWStrTemp(threadName); + TempWStr ws = ToWStrTemp(threadName); DynSetThreadDescription(GetCurrentThread(), ws); return; } diff --git a/src/utils/WinUtil.cpp b/src/utils/WinUtil.cpp index eccd15394ed..b1bc5765b36 100755 --- a/src/utils/WinUtil.cpp +++ b/src/utils/WinUtil.cpp @@ -582,7 +582,7 @@ bool LoggedDeleteRegValue(HKEY hkey, const char* keyName, const char* valName) { } HRESULT CLSIDFromString(const char* lpsz, LPCLSID pclsid) { - WCHAR* ws = ToWStrTemp(lpsz); + TempWStr ws = ToWStrTemp(lpsz); return CLSIDFromString(ws, pclsid); } @@ -1340,7 +1340,7 @@ static bool CopyOrAppendTextToClipboard(const WCHAR* text, bool appendOnly) { } static bool CopyOrAppendTextToClipboard(const char* s, bool appendOnly) { - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); return CopyOrAppendTextToClipboard(ws, appendOnly); } @@ -1730,7 +1730,7 @@ void MenuSetText(HMENU m, int id, const WCHAR* s) { } void MenuSetText(HMENU m, int id, const char* s) { - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); MenuSetText(m, id, ws); } @@ -2670,7 +2670,7 @@ void HwndSetText(HWND hwnd, const char* sv) { SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)L""); return; } - WCHAR* ws = ToWStrTemp(sv); + TempWStr ws = ToWStrTemp(sv); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)ws); } @@ -2837,7 +2837,7 @@ int HdcDrawText(HDC hdc, const char* s, RECT* r, uint fmt, HFONT font) { if (!s) { return 0; } - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); if (!ws) { return 0; } @@ -2860,7 +2860,7 @@ int HdcDrawText(HDC hdc, const char* s, const Point& pos, uint fmt, HFONT font) // uses the same logic as HdcDrawText Size HdcMeasureText(HDC hdc, const char* s, uint fmt, HFONT font) { fmt |= DT_CALCRECT; - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); if (!ws) { return {}; } diff --git a/src/wingui/WinGui.cpp b/src/wingui/WinGui.cpp index 190b4057083..ab23afa8d24 100644 --- a/src/wingui/WinGui.cpp +++ b/src/wingui/WinGui.cpp @@ -1417,7 +1417,7 @@ void TooltipAddTools(HWND hwnd, HWND owner, TooltipInfo* tools, int nTools) { for (int i = 0; i < nTools; i++) { TooltipInfo& tti = tools[i]; - WCHAR* ws = ToWStrTemp(tti.s); + TempWStr ws = ToWStrTemp(tti.s); TOOLINFOW ti = {0}; ti.cbSize = sizeof(ti); ti.hwnd = owner; @@ -1459,7 +1459,7 @@ static bool TooltipUpdateText(HWND hwnd, HWND owner, int id, const char* s, bool } SetMaxWidthForText(hwnd, s, multiline); - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); TOOLINFOW ti = {0}; ti.cbSize = sizeof(ti); ti.hwnd = owner; @@ -1508,7 +1508,7 @@ void Tooltip::SetMaxWidth(int dx) { int Tooltip::Add(const char* s, const Rect& rc, bool multiline) { int id = GetNextTooltipID(); SetMaxWidthForText(hwnd, s, multiline); - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); TOOLINFOW ti = {0}; ti.cbSize = sizeof(ti); ti.hwnd = parent; @@ -1613,7 +1613,7 @@ static bool EditSetCueText(HWND hwnd, const char* s) { if (!hwnd) { return false; } - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); bool ok = Edit_SetCueBannerText(hwnd, ws) == TRUE; return ok; } @@ -2030,7 +2030,7 @@ static void SetDropDownItems(HWND hwnd, StrVec& items) { int n = items.Size(); for (int i = 0; i < n; i++) { char* s = items[i]; - WCHAR* ws = ToWStrTemp(s); + TempWStr ws = ToWStrTemp(s); ComboBox_AddString(hwnd, ws); } } @@ -2563,7 +2563,7 @@ void Webview2Wnd::UpdateWebviewSize() { } void Webview2Wnd::Eval(const char* js) { - WCHAR* ws = ToWStrTemp(js); + TempWStr ws = ToWStrTemp(js); webview->ExecuteScript(ws, nullptr); } @@ -2580,12 +2580,12 @@ void Webview2Wnd::SetHtml(const char* html) { } void Webview2Wnd::Init(const char* js) { - WCHAR* ws = ToWStrTemp(js); + TempWStr ws = ToWStrTemp(js); webview->AddScriptToExecuteOnDocumentCreated(ws, nullptr); } void Webview2Wnd::Navigate(const char* url) { - WCHAR* ws = ToWStrTemp(url); + TempWStr ws = ToWStrTemp(url); webview->Navigate(ws); } @@ -3489,7 +3489,7 @@ void TabsCtrl::Paint(HDC hdc, RECT& rc) { rTxt.X += 8; rTxt.Width -= (8 + r.dx + 8); br.SetColor(GdipCol(textColor)); - WCHAR* ws = ToWStrTemp(ti->text); + TempWStr ws = ToWStrTemp(ti->text); gfx.DrawString(ws, -1, &f, rTxt, &sf, &br); } } @@ -3525,7 +3525,7 @@ HBITMAP TabsCtrl::RenderForDragging(int idx) { rTxt.X += 8; rTxt.Width -= (8 + 8); br.SetColor(GdipCol(textCol)); - WCHAR* ws = ToWStrTemp(ti->text); + TempWStr ws = ToWStrTemp(ti->text); gfx->DrawString(ws, -1, &f, rTxt, &sf, &br); HBITMAP ret;