[haiku-development] Re: Setting text in BTextControl

  • From: Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 13 Jul 2008 11:47:53 +0200

Hi James,

On 2008-07-13 at 10:28:22 [+0200], James Kim <jkim202@xxxxxxxxxxxxxxxxx> 
wrote:
[ ... ]
> 
> To be more specific, EditForm::InitializeControls() method initializes
> BTextControl and EditForm::UpdateEditForm() method calls
> BTextControl::SetText().

Many BView methods require the corresponding BLooper to be locked (in order 
to keep other threads from getting in the way). During execution of the hook 
methods, that locking is being done automatically, but whenever your 
application invokes any of the BView methods out of the "event-loop", it has 
to lock the looper manually.

So, I'd suggest to do this in BALM::EditForm::UpdateEditForm():

if (nameOfTextControl->LockLooper()) {
    nameOfTextControl->SetText(...);
    nameOfTextControl->UnlockLooper();
}

If you are interested to learn more, please have a look at the documentation 
of BHandler, where LockLooper() and friends are explained.

Hope that helps.

cheers,
        Oliver

Other related posts: