]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibitem.cpp
The last commit was, uhh, not what I intended.
[lyx.git] / src / insets / InsetBibitem.cpp
index 3978c60df861257961c435a79f473c4efbf9011f..1f5b9159483bd406a7d73a692cb7505d727b89c3 100644 (file)
 
 #include "frontends/alert.h"
 
-#include "support/lstrings.h"
+#include "support/convert.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
-#include "support/convert.h"
+#include "support/lstrings.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -45,14 +45,23 @@ int InsetBibitem::key_counter = 0;
 docstring const key_prefix = from_ascii("key-");
 
 
-InsetBibitem::InsetBibitem(InsetCommandParams const & p)
+InsetBibitem::InsetBibitem(Buffer const & buf, InsetCommandParams const & p)
        : InsetCommand(p, "bibitem")
 {
+       Inset::setBuffer(const_cast<Buffer &>(buf));
+       buffer_->invalidateBibinfoCache();
        if (getParam("key").empty())
                setParam("key", key_prefix + convert<docstring>(++key_counter));
 }
 
 
+InsetBibitem::~InsetBibitem()
+{
+       if (isBufferValid())
+               buffer_->invalidateBibinfoCache();
+}
+
+
 void InsetBibitem::initView()
 {
        updateCommand(getParam("key"));
@@ -107,12 +116,14 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
                        cur.noUpdate();
                        break;
                }
-               docstring old_key = params()["key"];
+               docstring const & old_key = params()["key"];
                setParam("label", p["label"]);
-               updateCommand(p["key"]);
-               if (params()["key"] != old_key)
+               if (p["key"] != old_key) {
+                       updateCommand(p["key"]);
                        cur.bv().buffer().changeRefsIfUnique(old_key,
                                params()["key"], CITE_CODE);
+               }
+               buffer_->invalidateBibinfoCache();
                break;
        }