From 3aa9a863430e04319ddfe1e91fdca3b583c0021e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Tue, 12 May 2009 20:01:38 +0000 Subject: [PATCH] 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 --- src/apps/stylededit/StyledEditApp.cpp | 36 +++++++-------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/apps/stylededit/StyledEditApp.cpp b/src/apps/stylededit/StyledEditApp.cpp index e294990b34..756e46ae76 100644 --- a/src/apps/stylededit/StyledEditApp.cpp +++ b/src/apps/stylededit/StyledEditApp.cpp @@ -245,31 +245,12 @@ StyledEditApp::RefsReceived(BMessage *message) void StyledEditApp::ArgvReceived(int32 argc, char* argv[]) { - // StyledEdit has the "single launch" flag set in its - // resources. This means that while StyledEdit is running, - // additional StyledEdit invocations will not result in a - // new process but re-use the existing one, calling the - // hook methods of the BApplication subclass: ArgvReceived(), - // RefsReceived() or MessageReceived(B_SILENT_RELAUNCH), - // 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 + // If StyledEdit is already running and gets invoked again + // we need to account for a possible mismatch in current + // working directory. The paths of the new arguments are + // relative to the cwd of the invocation, if they are not + // absolute. This cwd we find as a string named "cwd" in + // the BLooper's current message. const char* cwd = ""; BMessage* message = CurrentMessage(); @@ -281,11 +262,12 @@ StyledEditApp::ArgvReceived(int32 argc, char* argv[]) for (int i = 1 ; (i < argc) ; i++) { BPath path; - if (argv[i][0] == '/') + if (argv[i][0] == '/') { path.SetTo(argv[i]); - else + } else { path.SetTo(cwd, argv[i]); // patch relative paths only + } entry_ref ref; get_ref_for_path(path.Path(), &ref);