Revert "Don't store args as std::string"

This reverts commit 8482575d1f.

There is weird thing happened if we tried to store raw "argv" on Linux.
This commit is contained in:
Cheng Zhao 2015-03-29 19:53:47 +08:00
parent 9f30933d3a
commit d9c22396ea
4 changed files with 31 additions and 16 deletions

View file

@ -155,7 +155,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
content::ContentMainParams params(&delegate);
params.instance = instance;
params.sandbox_info = &sandbox_info;
atom::AtomCommandLine::Init(argc, const_cast<const char**>(argv));
atom::AtomCommandLine::Init(argc, argv);
return content::ContentMain(params);
}

View file

@ -6,15 +6,13 @@
namespace atom {
// static
std::vector<const char*> AtomCommandLine::argv_;
// static
void AtomCommandLine::Init(int argc, const char* argv[]) {
argv_.reserve(argc);
for (int i = 0; i < argc; ++i) {
argv_.push_back(argv[i]);
void AtomCommandLine::Init(int argc,
const char* const* argv) {
for (int i = 0; i < argc; ++i) {
argv_.push_back(argv[i]);
}
}
}
std::vector<std::string> AtomCommandLine::argv_;
} // namespace atom

View file

@ -5,22 +5,22 @@
#ifndef ATOM_APP_ATOM_MAIN_ARGS_H_
#define ATOM_APP_ATOM_MAIN_ARGS_H_
#include <string>
#include <vector>
#include "base/logging.h"
namespace atom {
// Singleton to remember the original "argc" and "argv".
class AtomCommandLine {
public:
static void Init(int argc, const char* argv[]);
static std::vector<const char*> argv() { return argv_; }
static void Init(int argc, const char* const* argv);
static std::vector<std::string> argv() { return argv_; }
private:
static std::vector<const char*> argv_;
static std::vector<std::string> argv_;
DISALLOW_IMPLICIT_CONSTRUCTORS(AtomCommandLine);
DISALLOW_COPY_AND_ASSIGN(AtomCommandLine);
};
} // namespace atom