2

I have a wxTextCtrl and I need to put a very large string into it. (Like 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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
  • 1
    It sounds like the people who designed wxTextCtrl didn't anticipate someone stuffing a 15 mb string (roughly the size of an entire programming book) into it. – Robert Harvey Jan 24 '10 at 07:25
  • You can implement a paging mechanism, and only load a small window of the total text at one time. This approach should be almost instantaneous. I don't have enough expertise in wxWidgets to tell you how to do that, though. – Robert Harvey Jan 24 '10 at 07:49

1 Answers1

2

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.

mghie
  • 32,028
  • 6
  • 87
  • 129