-// FIXME THREAD
-// There could easily be a conflict here, with the export process
-// setting this one way, and a View>Source process (possbily for
-// another Buffer) resetting it.
-static int open_encoding_ = none;
-static int cjk_inherited_ = 0;
-Language const * prev_env_language_ = 0;
+
+struct OutputState
+{
+ OutputState() : open_encoding_(none), cjk_inherited_(0),
+ prev_env_language_(0), open_polyglossia_lang_("")
+ {
+ }
+ OpenEncoding open_encoding_;
+ int cjk_inherited_;
+ Language const * prev_env_language_;
+ string open_polyglossia_lang_;
+};
+
+
+OutputState * getOutputState()
+{
+ // FIXME An instance of OutputState should be kept around for each export
+ // instead of using local thread storage
+ static QThreadStorage<OutputState *> outputstate;
+ if (!outputstate.hasLocalData())
+ outputstate.setLocalData(new OutputState);
+ return outputstate.localData();
+}