From 6b5289825e18f158eb180aa048a11bc95bdf1812 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 17 Dec 2006 21:52:40 +0000 Subject: [PATCH] Don't use a global variable for avoiding removal of the system temp dir * src/support/package.h (Package::system_temp_dir): new, return the system temp dir. * src/support/package.C.in (Package::Package): record the system temp dir. * src/lyx_main.C (LyX::prepareExit): don't remove the temporary directory if it is the same as the system temp dir, meaning that the lyx_tmpdir has not yet been created. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16318 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/lyx_main.C | 6 +----- src/support/package.C.in | 3 ++- src/support/package.h | 14 +++++++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/lyx_main.C b/src/lyx_main.C index 2f50c17ad6..980582e901 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -110,9 +110,6 @@ bool use_gui = true; namespace { -/// Don't try to remove the temporary directory if it has not been created -bool remove_tmpdir = false; - // Filled with the command line arguments "foo" of "-sysdir foo" or // "-userdir foo". string cl_system_support; @@ -422,7 +419,7 @@ void LyX::prepareExit() pimpl_->buffer_list_.closeAll(); // do any other cleanup procedures now - if (remove_tmpdir) { + if (package().temp_dir() != package().system_temp_dir()) { lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl; @@ -856,7 +853,6 @@ bool LyX::init() // trying again but simply exit. return false; } - remove_tmpdir = true; if (lyxerr.debugging(Debug::INIT)) { lyxerr << "LyX tmp dir: `" << package().temp_dir() << '\'' << endl; diff --git a/src/support/package.C.in b/src/support/package.C.in index 6b81cf13ff..ef5bcfe599 100644 --- a/src/support/package.C.in +++ b/src/support/package.C.in @@ -124,7 +124,8 @@ Package::Package(string const & command_line_arg0, : explicit_user_support_dir_(false) { home_dir_ = get_home_dir(); - temp_dir_ = get_temp_dir(); + system_temp_dir_ = get_temp_dir(); + temp_dir_ = system_temp_dir_; document_dir_ = get_document_dir(home_dir_); string const abs_binary = abs_path_from_binary_name(command_line_arg0); diff --git a/src/support/package.h b/src/support/package.h index 6b70605c56..69d11c6f76 100644 --- a/src/support/package.h +++ b/src/support/package.h @@ -104,8 +104,13 @@ public: */ std::string & document_dir() const; - /** The path to the temporary directory. + /** The path to the system temporary directory. * (Eg /tmp on *nix.) + */ + std::string const & system_temp_dir() const; + + /** The path to the temporary directory used by LyX. + * (Eg /tmp/lyx_tmpdir800nBI1z9 on *nix.) * Can be reset by LyXRC. */ std::string & temp_dir() const; @@ -129,6 +134,7 @@ private: std::string locale_dir_; mutable std::string document_dir_; mutable std::string temp_dir_; + std::string system_temp_dir_; std::string home_dir_; std::string configure_command_; bool explicit_user_support_dir_; @@ -186,6 +192,12 @@ std::string & Package::temp_dir() const return temp_dir_; } +inline +std::string const & Package::system_temp_dir() const +{ + return system_temp_dir_; +} + inline std::string const & Package::home_dir() const { -- 2.39.5