#include "support/docstream.h"
#include "support/gettext.h"
#include "support/lstrings.h"
+#include "support/mutex.h"
using namespace std;
using namespace lyx::support;
int InsetBibitem::key_counter = 0;
+static Mutex counter_mutex;
docstring const key_prefix = from_ascii("key-");
: InsetCommand(buf, p)
{
buffer().invalidateBibinfoCache();
- if (getParam("key").empty())
+ if (getParam("key").empty()) {
+ Mutex::Locker lock(&counter_mutex);
setParam("key", key_prefix + convert<docstring>(++key_counter));
+ }
}
if (prefixIs(getParam("key"), key_prefix)) {
int const key = convert<int>(getParam("key").substr(key_prefix.length()));
+ Mutex::Locker lock(&counter_mutex);
key_counter = max(key_counter, key);
}
}
#include "support/lassert.h"
#include "support/lstrings.h" // contains
#include "support/lyxalgo.h"
+#include "support/mutex.h"
#include "support/bind.h"
docstring const uniqueID()
{
static unsigned int seed = 1000;
+ static Mutex mutex;
+ Mutex::Locker lock(&mutex);
return "file" + convert<docstring>(++seed);
}