On Fri, Dec 15, 2006 at 05:17:53PM +0100, Georg Baum wrote:
> Abdelrazak Younes wrote:
>
> > Georg Baum wrote:
> >> Abdelrazak Younes wrote:
> >>
> >>> I created a Singletons class explicitely to avoid that, please use it.
> >>
> >> Not in this case IMHO. This should be kept private to the file,
> >
> > Technically speaking the Singletons class is private to the file.
>
> Ah sorry, I mixed that up.
What about the attached patch? This is the solution suggested by Angus.
--
Enrico
Index: src/support/package.h
===================================================================
--- src/support/package.h (revision 16274)
+++ src/support/package.h (working copy)
@@ -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_;
@@ -187,6 +193,12 @@ std::string & Package::temp_dir() const
}
inline
+std::string const & Package::system_temp_dir() const
+{
+ return system_temp_dir_;
+}
+
+inline
std::string const & Package::home_dir() const
{
return home_dir_;
Index: src/support/package.C.in
===================================================================
--- src/support/package.C.in (revision 16274)
+++ src/support/package.C.in (working copy)
@@ -124,7 +124,8 @@ Package::Package(string const & command_
: 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);
Index: src/lyx_main.C
===================================================================
--- src/lyx_main.C (revision 16274)
+++ src/lyx_main.C (working copy)
@@ -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;
@@ -857,7 +854,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;