开发者

Why is wxTextCtrl so slow at displaying text?

I have a wxTextCtrl and I need to put a very large string into it. (Lik开发者_JAVA技巧e a 15 MB string) The only problem is it's very slow. Here is what I'm doing:

char * buff = ...
wxString data(buff, wxConvUTF8);
text->ChangeValue(data);

However, this is not the bottleneck. That occurrs as soon as the function this block of code is in returns. The whole app freezes for about 30 seconds. I tried wxYield right after ChangeValue and that causes the first few lines of the string to be displayed in the control but it still freezes after. How can I avoid this?

I must stress that ChangeValue returns almost instantaneously. The delay happens after this, probably in wxTextCtrl's internal message handlers or something.


wxTextCtrl wraps the standard text control of the OS only, so any limits this has will be apparent with wxTextCtrl as well. What you can do is to use the wxStyledTextCtrl instead, which is able to load multi-megabyte texts and doesn't take long to do it. You could even highlight portions of your log by styling them (for example error messages in read), but that would probably increase loading time again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜