[haiku] Re: BWindow pointer

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku@xxxxxxxxxxxxx
  • Date: Fri, 23 Mar 2012 15:33:42 +0100

Hi,

Am 23.03.2012 14:52, schrieb Chris Moore:
I'm having a headache trying to use a BWindow subclass as an instance
variable.

I've got a main window class (MainWindow) that has a private instance
variable of another BWindow subclass (CredentialsWindow).
In the header, I've got this:

private:
CredentialsWindow *credWin;

In the MainWindow class, if I add this to the constructor:
credWin = new CredentialsWindow();

Then in another method, I try
credWin->Show();

It freezes... However, if I do both the initialisation and Show() as a
local variable, it works fine.

Any ideas?

When you call Show() for the first time, it starts the CredentialsWindow event thread. For the second time onward, you need to call Lock() before calling Show(). Also, how do you hide the window?

If you for some reason want to run the CredentialsWindow event thread at construction time, you can do this in your constructor:

credWin->Hide();
credWin->Show();

Without locking around it, after Show() returns, you always need to Lock() and Unlock() before calling methods of the CredentialsWindow. Alternatively, you can do this in the CredentialsWindow constructor.

Best regards,
-Stephan


Other related posts: