mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Make DocFileName::mangledFileName() threadsafe
This commit is contained in:
parent
50929b5b8a
commit
0de4bc224a
@ -17,6 +17,7 @@
|
|||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
#include "support/mutex.h"
|
||||||
#include "support/qstring_helpers.h"
|
#include "support/qstring_helpers.h"
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
#include "support/Package.h"
|
#include "support/Package.h"
|
||||||
@ -910,13 +911,15 @@ string DocFileName::outputFileName(string const & path) const
|
|||||||
|
|
||||||
string DocFileName::mangledFileName(string const & dir) const
|
string DocFileName::mangledFileName(string const & dir) const
|
||||||
{
|
{
|
||||||
// FIXME THREAD
|
|
||||||
// Concurrent access to these variables is possible.
|
// Concurrent access to these variables is possible.
|
||||||
|
|
||||||
// We need to make sure that every DocFileName instance for a given
|
// We need to make sure that every DocFileName instance for a given
|
||||||
// filename returns the same mangled name.
|
// filename returns the same mangled name.
|
||||||
typedef map<string, string> MangledMap;
|
typedef map<string, string> MangledMap;
|
||||||
static MangledMap mangledNames;
|
static MangledMap mangledNames;
|
||||||
|
static Mutex mangledMutex;
|
||||||
|
// this locks both access to mangledNames and counter below
|
||||||
|
Mutex::Locker lock(&mangledMutex);
|
||||||
MangledMap::const_iterator const it = mangledNames.find(absFileName());
|
MangledMap::const_iterator const it = mangledNames.find(absFileName());
|
||||||
if (it != mangledNames.end())
|
if (it != mangledNames.end())
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
@ -942,7 +945,6 @@ string DocFileName::mangledFileName(string const & dir) const
|
|||||||
// Add the extension back on
|
// Add the extension back on
|
||||||
mname = support::changeExtension(mname, getExtension(name));
|
mname = support::changeExtension(mname, getExtension(name));
|
||||||
|
|
||||||
// FIXME THREAD
|
|
||||||
// Prepend a counter to the filename. This is necessary to make
|
// Prepend a counter to the filename. This is necessary to make
|
||||||
// the mangled name unique.
|
// the mangled name unique.
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user