3 * Copyright 2004 Michael Pfeiffer. All Rights Reserved.
6 #include "DialogWindow.h"
10 DialogWindow::DialogWindow(BRect frame
,
15 : BWindow(frame
, title
, type
, flags
, workspace
)
16 , fPreviousResult(B_OK
)
22 DialogWindow::DialogWindow(BRect frame
,
28 : BWindow(frame
, title
, look
, feel
, flags
, workspace
)
29 , fPreviousResult(B_OK
)
35 void DialogWindow::MessageReceived(BMessage
*msg
)
37 if (msg
->what
== kGetThreadId
) {
39 reply
.AddInt32("thread_id", Thread());
40 msg
->SendReply(&reply
);
43 BWindow::MessageReceived(msg
);
46 status_t
DialogWindow::Go()
48 BMessenger
messenger(this, this);
49 // store result in local variable and
50 // initialize it with previous result
51 volatile status_t result
= fPreviousResult
;
52 // new results are stored on the stack
57 // at this point we must not access member variables,
58 // because this object (the window) could already be deleted.
60 // get thread id of window thread
62 if (messenger
.SendMessage(kGetThreadId
, &reply
) != B_OK
) {
65 thread_id windowThread
;
66 if (reply
.FindInt32("thread_id", &windowThread
) != B_OK
) {
70 // wait for window thread to die
71 // The window thread will crash if the image holding the
72 // code used by the window thread is unloaded while the thread is
74 status_t status
= B_ERROR
;
75 wait_for_thread(windowThread
, &status
);
80 void DialogWindow::SetResult(status_t result
)
82 if (fResult
!= NULL
) {
85 fPreviousResult
= result
;