-// Initialization of the counter for the paragraph id's,
-//
-// FIXME: There should be a more intelligent way to generate and use the
-// paragraph ids per buffer instead a global static counter for all InsetText
-// in the running program.
-// However, this per-session id is used in LFUN_PARAGRAPH_GOTO to
-// switch to a different buffer, as used in the outliner for instance.
-static int paragraph_id = -1;
+//static
+int Paragraph::Private::make_id()
+{
+ // The id is unique per session across buffers because it is used in
+ // LFUN_PARAGRAPH_GOTO to switch to a different buffer, for instance in the
+ // outliner.
+ // (thread-safe)
+ static atomic_uint next_id(0);
+ return next_id++;
+}
+