libbe: Fixed current_team() to work after a fork.
* This allows to start a valid looper in the forked child, for example.
This commit is contained in:
parent
0975f16f7c
commit
8a86ad7593
|
@ -25,6 +25,7 @@ status_t get_app_ref(team_id team, entry_ref *ref, bool traverse = true);
|
|||
status_t get_app_ref(entry_ref *ref, bool traverse = true);
|
||||
|
||||
team_id current_team();
|
||||
void init_team_after_fork();
|
||||
thread_id main_thread_for(team_id team);
|
||||
|
||||
bool is_app_showing_modal_window(team_id team);
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
namespace BPrivate {
|
||||
|
||||
|
||||
static team_id sCurrentTeam = -1;
|
||||
|
||||
|
||||
/*! \brief Returns the path to an application's executable.
|
||||
\param team The application's team ID.
|
||||
\param buffer A pointer to a pre-allocated character array of at least
|
||||
|
@ -123,13 +126,19 @@ get_app_ref(entry_ref *ref, bool traverse)
|
|||
team_id
|
||||
current_team()
|
||||
{
|
||||
static team_id team = -1;
|
||||
if (team < 0) {
|
||||
if (sCurrentTeam < 0) {
|
||||
thread_info info;
|
||||
if (get_thread_info(find_thread(NULL), &info) == B_OK)
|
||||
team = info.team;
|
||||
sCurrentTeam = info.team;
|
||||
}
|
||||
return team;
|
||||
return sCurrentTeam;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
init_team_after_fork()
|
||||
{
|
||||
sCurrentTeam = -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,7 +156,7 @@ main_thread_for(team_id team)
|
|||
// a team info to verify the existence of the team.
|
||||
team_info info;
|
||||
status_t error = get_team_info(team, &info);
|
||||
return (error == B_OK ? team : error);
|
||||
return error == B_OK ? team : error;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <AppMisc.h>
|
||||
#include <LooperList.h>
|
||||
#include <MessagePrivate.h>
|
||||
#include <RosterPrivate.h>
|
||||
|
@ -35,6 +36,7 @@ initialize_forked_child()
|
|||
BMessage::Private::StaticReInitForkedChild();
|
||||
BPrivate::gLooperList.InitAfterFork();
|
||||
BPrivate::gDefaultTokens.InitAfterFork();
|
||||
BPrivate::init_team_after_fork();
|
||||
|
||||
DBG(OUT("initialize_forked_child() done\n"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue