Multiple threads with access to TextEditor

Hi all,

Working on a GUI application in which there is a read-only TextEditor that is used for message output to the user. Currently there are two background threads in addition to the “main” thread that call insertTextAtCaret(). I would like to know if this is thread-safe (I suspect that it isn’t) and if it is not thread safe, would std::atomic rectify the issue? Or would it be necessary to create a third, low-priority background thread to handle the TextEditor, perhaps with a FIFO structure into which the threads can push strings that will be added to the TextEditor output?

Thanks,

Take a look at the PluginVal project by @dave96.

he has a very cool means of sending output text to a ‘console’ within the app from a background thread. I would borrow that design, as it’s thread-safe, and a great example of how to pass big chunks of data between a non-gui thread and the GUI thread.

1 Like