BRoster::Launch() didn't send a B_SILENT_RELAUNCH message to an already
running app. Fixes bug #1162. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20743 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+18
-11
@@ -1923,9 +1923,9 @@ BRoster::_LaunchApp(const char *mimeType, const entry_ref *ref,
|
|||||||
|
|
||||||
// send "on launch" messages
|
// send "on launch" messages
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
// If the target app is B_ARGV_ONLY almost no messages are sent to it.
|
// If the target app is B_ARGV_ONLY, only if it is newly launched
|
||||||
// More precisely, the launched app gets at least B_ARGV_RECEIVED and
|
// messages are sent to it (namely B_ARGV_RECEIVED and B_READY_TO_RUN).
|
||||||
// B_READY_TO_RUN, an already running app gets nothing.
|
// An already running B_ARGV_ONLY app won't get any messages.
|
||||||
bool argvOnly = (appFlags & B_ARGV_ONLY)
|
bool argvOnly = (appFlags & B_ARGV_ONLY)
|
||||||
|| (alreadyRunning && (otherAppFlags & B_ARGV_ONLY));
|
|| (alreadyRunning && (otherAppFlags & B_ARGV_ONLY));
|
||||||
const BList *_messageList = (argvOnly ? NULL : messageList);
|
const BList *_messageList = (argvOnly ? NULL : messageList);
|
||||||
@@ -1935,7 +1935,7 @@ BRoster::_LaunchApp(const char *mimeType, const entry_ref *ref,
|
|||||||
|| argVector.Count() > 1 ? NULL : docRef;
|
|| argVector.Count() > 1 ? NULL : docRef;
|
||||||
if (!(argvOnly && alreadyRunning)) {
|
if (!(argvOnly && alreadyRunning)) {
|
||||||
_SendToRunning(team, argVector.Count(), argVector.Args(),
|
_SendToRunning(team, argVector.Count(), argVector.Args(),
|
||||||
_messageList, _ref, !alreadyRunning);
|
_messageList, _ref, alreadyRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2357,8 +2357,9 @@ BRoster::_SniffFile(const entry_ref *file, BNodeInfo *nodeInfo,
|
|||||||
\param messageList List of BMessages to be sent to the target. May be
|
\param messageList List of BMessages to be sent to the target. May be
|
||||||
\c NULL or empty.
|
\c NULL or empty.
|
||||||
\param ref entry_ref to be sent to the target. May be \c NULL.
|
\param ref entry_ref to be sent to the target. May be \c NULL.
|
||||||
\param readyToRun \c true, if a \c B_READY_TO_RUN message shall be sent,
|
\param alreadyRunning \c true, if the target app is not newly launched,
|
||||||
\c false otherwise.
|
but was already running, \c false otherwise (a \c B_READY_TO_RUN
|
||||||
|
message will be sent in this case).
|
||||||
\return
|
\return
|
||||||
- \c B_OK: Everything went fine.
|
- \c B_OK: Everything went fine.
|
||||||
- an error code otherwise
|
- an error code otherwise
|
||||||
@@ -2366,7 +2367,7 @@ BRoster::_SniffFile(const entry_ref *file, BNodeInfo *nodeInfo,
|
|||||||
status_t
|
status_t
|
||||||
BRoster::_SendToRunning(team_id team, int argc, const char *const *args,
|
BRoster::_SendToRunning(team_id team, int argc, const char *const *args,
|
||||||
const BList *messageList, const entry_ref *ref,
|
const BList *messageList, const entry_ref *ref,
|
||||||
bool readyToRun) const
|
bool alreadyRunning) const
|
||||||
{
|
{
|
||||||
status_t error = B_OK;
|
status_t error = B_OK;
|
||||||
// Construct a messenger to the app: We can't use the public constructor,
|
// Construct a messenger to the app: We can't use the public constructor,
|
||||||
@@ -2375,7 +2376,9 @@ BRoster::_SendToRunning(team_id team, int argc, const char *const *args,
|
|||||||
error = GetRunningAppInfo(team, &info);
|
error = GetRunningAppInfo(team, &info);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
BMessenger messenger;
|
BMessenger messenger;
|
||||||
BMessenger::Private(messenger).SetTo(team, info.port, B_PREFERRED_TOKEN);
|
BMessenger::Private(messenger).SetTo(team, info.port,
|
||||||
|
B_PREFERRED_TOKEN);
|
||||||
|
|
||||||
// send messages from the list
|
// send messages from the list
|
||||||
if (messageList) {
|
if (messageList) {
|
||||||
for (int32 i = 0;
|
for (int32 i = 0;
|
||||||
@@ -2384,22 +2387,26 @@ BRoster::_SendToRunning(team_id team, int argc, const char *const *args,
|
|||||||
messenger.SendMessage(message);
|
messenger.SendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// send B_ARGV_RECEIVED
|
|
||||||
|
// send B_ARGV_RECEIVED or B_SILENT_RELAUNCH (if already running)
|
||||||
if (args && argc > 1) {
|
if (args && argc > 1) {
|
||||||
BMessage message(B_ARGV_RECEIVED);
|
BMessage message(B_ARGV_RECEIVED);
|
||||||
message.AddInt32("argc", argc);
|
message.AddInt32("argc", argc);
|
||||||
for (int32 i = 0; i < argc; i++)
|
for (int32 i = 0; i < argc; i++)
|
||||||
message.AddString("argv", args[i]);
|
message.AddString("argv", args[i]);
|
||||||
messenger.SendMessage(&message);
|
messenger.SendMessage(&message);
|
||||||
}
|
} else if (alreadyRunning)
|
||||||
|
messenger.SendMessage(B_SILENT_RELAUNCH);
|
||||||
|
|
||||||
// send B_REFS_RECEIVED
|
// send B_REFS_RECEIVED
|
||||||
if (ref) {
|
if (ref) {
|
||||||
BMessage message(B_REFS_RECEIVED);
|
BMessage message(B_REFS_RECEIVED);
|
||||||
message.AddRef("refs", ref);
|
message.AddRef("refs", ref);
|
||||||
messenger.SendMessage(&message);
|
messenger.SendMessage(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send B_READY_TO_RUN
|
// send B_READY_TO_RUN
|
||||||
if (readyToRun)
|
if (!alreadyRunning)
|
||||||
messenger.SendMessage(B_READY_TO_RUN);
|
messenger.SendMessage(B_READY_TO_RUN);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
Reference in New Issue
Block a user