From cdb0d24957a5d77863e31d256bfd1e33b70a4064 Mon Sep 17 00:00:00 2001 From: Jule Marcoueille <julio@users.gforge.inria.fr> Date: Fri, 20 Mar 2009 20:06:39 +0000 Subject: [PATCH] =?UTF-8?q?Portalibilisation=20du=20multifenetrage=20retra?= =?UTF-8?q?vaill=C3=A9e=20pour=20utiliser=20des=20string.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/interface/interface_console.cpp | 14 ++++---------- src/interface/interface_console.hpp | 10 ++-------- src/interface/interface_graphic.cpp | 18 +++++++++--------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/interface/interface_console.cpp b/src/interface/interface_console.cpp index ed4f186f..b0f28341 100644 --- a/src/interface/interface_console.cpp +++ b/src/interface/interface_console.cpp @@ -31,14 +31,8 @@ Interface_console::Interface_console(int argc, char ** argv){ QString current_path; app = new QApplication(argc, argv);/* create the Qt application */ - current_path = QDir::currentPath(); - _run_env[0] = new char[current_path.length()+1]; - - if (!strcpy(_run_env[0], current_path.toStdString().c_str())) { - cerr << "Error : in " << __FILE__ << " at line " << __LINE__ << "." << endl; - cerr << "Reason : Copy of the current path directory failed." << endl; - exit(EXIT_FAILURE); - } + + _run_env[0] = QDir::currentPath(); _run_env[1] = argv[0]; @@ -76,7 +70,7 @@ Interface_console::~Interface_console(){ /* Qt desallocates _main_window and _render_opengl automatically */ - free(_run_env[0]); + //free(_run_env[0]); } @@ -421,6 +415,6 @@ void Interface_console::set_path_to_export(const string& path){ _path_to_export = path; } -char const* const* Interface_console::get_runenv() const{ +const QString* Interface_console::get_runenv() const{ return _run_env; } diff --git a/src/interface/interface_console.hpp b/src/interface/interface_console.hpp index e5a60c0c..d08b31a4 100644 --- a/src/interface/interface_console.hpp +++ b/src/interface/interface_console.hpp @@ -110,12 +110,6 @@ public: */ static const int _STATE_LAUNCH_GRAPHICAL_INTERFACE = 10; - /*! - * \brief The size max (hoped) for the current directory name. - * Used for opening a new window with a new trace. - */ - static const int _CURRENT_DIR_SIZE = 256; - /*! * \brief Launch an action according to the argument state value. * \arg state : an integer corresponding to a kind of action which must be executed. @@ -158,7 +152,7 @@ protected: /*! *\brief This attributes contains the launching current directory (_run_env[0]) and the first argument of the running command (_run_env[1]). */ - char* _run_env[2]; + QString _run_env[2]; /*! *\brief If a file must be opened, this attributes contains its path. @@ -271,7 +265,7 @@ protected: * \brief Get the _run_env matrix. * */ - char const* const* get_runenv() const; + const QString* get_runenv() const; /*********************************** diff --git a/src/interface/interface_graphic.cpp b/src/interface/interface_graphic.cpp index 5e77eecd..2e3a7fad 100644 --- a/src/interface/interface_graphic.cpp +++ b/src/interface/interface_graphic.cpp @@ -192,21 +192,21 @@ void Interface_graphic::on_open_triggered(){ if (!filename.isEmpty()){ - if (_is_rendering_trace == true){/* Realease the previous trace */ + if (_is_rendering_trace == true){ /* open a new process */ QStringList arguments = (QStringList() << filename); - QString program; - char const* const* run_env = _core->get_runenv(); - QString start_directory = run_env[0]; - QDir::setCurrent(start_directory); + QString* program; + const QString* run_env = _core->get_runenv(); + QDir::setCurrent(run_env[0]); + QString run_cmd = run_env[1]; - if (run_env[1][0] == '.') - program = QString(run_env[0])+QString(run_env[1]+sizeof(char)); + if (run_cmd.startsWith(".")) + program = new QString(run_env[0]+(run_cmd.remove(0,1))); else - program = QString(run_env[1]); + program = new QString(run_cmd); QProcess * new_process = new QProcess(); - new_process->startDetached(program, arguments); + new_process->startDetached(*program, arguments); } else{ opening_file(filename.toStdString()); -- GitLab