Clean up: shortening comment, adding if/else braces. Thanks Axel\!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30725 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -245,31 +245,12 @@ StyledEditApp::RefsReceived(BMessage *message)
|
|||||||
void
|
void
|
||||||
StyledEditApp::ArgvReceived(int32 argc, char* argv[])
|
StyledEditApp::ArgvReceived(int32 argc, char* argv[])
|
||||||
{
|
{
|
||||||
// StyledEdit has the "single launch" flag set in its
|
// If StyledEdit is already running and gets invoked again
|
||||||
// resources. This means that while StyledEdit is running,
|
// we need to account for a possible mismatch in current
|
||||||
// additional StyledEdit invocations will not result in a
|
// working directory. The paths of the new arguments are
|
||||||
// new process but re-use the existing one, calling the
|
// relative to the cwd of the invocation, if they are not
|
||||||
// hook methods of the BApplication subclass: ArgvReceived(),
|
// absolute. This cwd we find as a string named "cwd" in
|
||||||
// RefsReceived() or MessageReceived(B_SILENT_RELAUNCH),
|
// the BLooper's current message.
|
||||||
// depending on the nature of the invocation.
|
|
||||||
|
|
||||||
// An implication of this relevant to ArgvReceived() is
|
|
||||||
// that the running application might have a current
|
|
||||||
// working directory different from the one of a later
|
|
||||||
// invocation. Arguments received from the later invocation,
|
|
||||||
// if having relative paths, will be incorrect when
|
|
||||||
// interpreted as relative to the current working directory.
|
|
||||||
|
|
||||||
// BApplication's ArgvReceived() method does not supply
|
|
||||||
// the cwd of the invocation, but the BMessage by which
|
|
||||||
// the arguments get communicated to the BApplication
|
|
||||||
// supplies a cwd string. So we ask the BApplication,
|
|
||||||
// to show the current message - the one that triggered
|
|
||||||
// the ArgvReceived() hook method - extract the cwd
|
|
||||||
// string from it and patch any relative paths in argv.
|
|
||||||
|
|
||||||
// This does not take into account --option handling
|
|
||||||
// and how to avoid prepending a path to such arguments
|
|
||||||
|
|
||||||
const char* cwd = "";
|
const char* cwd = "";
|
||||||
BMessage* message = CurrentMessage();
|
BMessage* message = CurrentMessage();
|
||||||
@@ -281,11 +262,12 @@ StyledEditApp::ArgvReceived(int32 argc, char* argv[])
|
|||||||
|
|
||||||
for (int i = 1 ; (i < argc) ; i++) {
|
for (int i = 1 ; (i < argc) ; i++) {
|
||||||
BPath path;
|
BPath path;
|
||||||
if (argv[i][0] == '/')
|
if (argv[i][0] == '/') {
|
||||||
path.SetTo(argv[i]);
|
path.SetTo(argv[i]);
|
||||||
else
|
} else {
|
||||||
path.SetTo(cwd, argv[i]);
|
path.SetTo(cwd, argv[i]);
|
||||||
// patch relative paths only
|
// patch relative paths only
|
||||||
|
}
|
||||||
|
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
get_ref_for_path(path.Path(), &ref);
|
get_ref_for_path(path.Path(), &ref);
|
||||||
|
|||||||
Reference in New Issue
Block a user