* The destructor doesn't kill the looper thread any more, as this doesn't
work very well with BApplication and has some issue with plain loopers too. * DispatchMessage(): _QUIT_ doesn't delete the object any longer. The looper thread simply falls through the dispatching loop and deletes the object. * Caused by not killing the looper thread in the destructor, Quit() had to be adjusted. When called from the looper thread the thread exists. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@576 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
98207f6f77
commit
c26a5cea91
@ -131,7 +131,12 @@ BLooper::~BLooper()
|
||||
}
|
||||
|
||||
Lock();
|
||||
kill_thread(fTaskID);
|
||||
// bonefish: Killing the looper thread doesn't work very well with
|
||||
// BApplication. In fact here it doesn't work too well either. When the
|
||||
// looper thread encounters a _QUIT_ message it deletes the BLooper object
|
||||
// and thus commits suicide at this point. That is, the following cleanup
|
||||
// isn't done.
|
||||
// kill_thread(fTaskID);
|
||||
delete fQueue;
|
||||
delete_sem(fLockSem);
|
||||
delete_port(fMsgPort);
|
||||
@ -230,7 +235,13 @@ DBG(OUT("BLooper::DispatchMessage(%.4s)\n", (char*)&message->what));
|
||||
// Can't call Quit() to do this, because of the slight chance
|
||||
// another thread with have us locked between now and then.
|
||||
fTerminating = true;
|
||||
delete this;
|
||||
// bonefish: Now it works straight forward: The thread running here is
|
||||
// the looper thread, so after returning from DispatchMessage() it will
|
||||
// quit the dispatching loop, and delete the object in _task0_(), directly
|
||||
// before dying. Even better, this solution is BApplication friendly as
|
||||
// Quit() doesn't delete the application object.
|
||||
// TODO: Remove this.
|
||||
// delete this;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -478,11 +489,18 @@ DBG(OUT("BLooper::Quit()\n"));
|
||||
|
||||
DBG(OUT(" is locked\n"));
|
||||
|
||||
if (!fRunCalled || find_thread(NULL) == fTaskID)
|
||||
if (!fRunCalled)
|
||||
{
|
||||
DBG(OUT(" Run() has not been called yet or we are the looper thread\n"));
|
||||
DBG(OUT(" Run() has not been called yet\n"));
|
||||
fTerminating = true;
|
||||
delete this;
|
||||
}
|
||||
else if (find_thread(NULL) == fTaskID)
|
||||
{
|
||||
DBG(OUT(" We are the looper thread\n"));
|
||||
fTerminating = true;
|
||||
delete this;
|
||||
exit_thread(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user