Use std::vector<CString> instead of std::vector<WCHAR*>
Because this is better.
因为在做一个项目的过程中,发现当push_back进大约24个左右WCHAR*到vector里面后,vector就开始成为乱码了。
改成std::vector<CString>则几百个都没有出现问题。
出现问题的代码类似:
... GetWinDir(cWinDir); if(cWinDir.IsEmpty()) { ++nCount; continue; } cWinDir += lpszFilePath; cWinDir += lpszFileName; //check if file exist, if not add it to fix_list if(!(pThis->DoesFileExist(cWinDir.GetBuffer()))) { m_vFixList.push_back(cWinDir); NotifyScanObservers(EV_FILENOTFOUND, 0, (LPARAM)cWinDir.GetBuffer()); } ...
至于原因猜想是后台的一些优化程序或者vector的内部机制移动了指针所指向的字符串。

浙公网安备 33010602011771号