QString 在 Windows 7 RC 上 Crash 的問題

目前在進行的程式,是在 Windows XP SP2 中,以 VS2005 SP1 來 compile。
官方的文件說明,這個組合,是可以在 Vista 上跑的。
而既然 Windows 7 的核心與 Vista 差異不大,自然也沒問題。


在我試驗的 Windows 7 RC 中,如果使用以下的語法,會很容易(非 100%)導致程式 crash:


QString str = "123";
str.toStdString();


所以如果要得到 string,那就只好用迂迴的:


std::string str2;
str2.assign(str.toAscii());


另外一個是使用 std::string,使用它的 find 函式,也會很容易(非 100%)導致程式 crash:


std::string str = "123";
str.find("1");


 


留言

熱門文章