]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibitem.cpp
Some things did not need to be mutable after all
[lyx.git] / src / insets / InsetBibitem.cpp
index 4f263e99decf7c02b72cdc5a65c48620ae61dc71..d0a28e73fe964d02965d168b1b6829fa78f51096 100644 (file)
@@ -41,6 +41,7 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
+#include "support/mutex.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -48,8 +49,8 @@ using namespace lyx::support;
 namespace lyx {
 
 
-// FIXME THREAD
 int InsetBibitem::key_counter = 0;
+static Mutex counter_mutex;
 docstring const key_prefix = from_ascii("key-");
 
 
@@ -57,8 +58,10 @@ InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p)
        : 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));
+       }
 }
 
 
@@ -196,6 +199,7 @@ void InsetBibitem::read(Lexer & lex)
 
        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);
        }
 }