Hi, this issue is bugging me for years, but it passed some triggering frustration point today...
Not sure whether you experienced it but sometimes you try to insert new figure at the cursor position and the figure gets pasted elsewhere in the document, it does not happen always so one tends to get confused and think he had the cursor wrong or whatever. To reliably reproduce the issue you need to: 1. click on some other graphics inset and cancel the dialog 2. put the cursor elsewhere in document and insert new graphics via menu->insert 3. the graphics is inserted at the position of figure at step 1, not on the cursor position The underlying problem is that we fill up edited insets into cache when editing inset is triggered, but this cache is never cleared up for dialogs unassociated with some inset - thus when graphics dialog is open for completely new image the old cache is used. To solve this we need to trigger cache update for each dialog show. Patch attached, it can be made more concise without BufferView.cpp part, but it will be less visible that we rely on stuffing cache with null inset pointers for each dialog type (the rest of code is fine with both solutions as far as I could see). Unless there are objections I want to have this in both master and branch. It however touches sensitive part of the code, so please review the patch. Pavel
diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 95024f5bb6..e2648a151c 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1264,7 +1264,10 @@ Inset * BufferView::editedInset(string const & name) const void BufferView::editInset(string const & name, Inset * inset) { - d->edited_insets_[name] = inset; + if (inset) + d->edited_insets_[name] = inset; + else + d->edited_insets_.erase(name); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 9d5f5dca6a..4c87499a4d 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -4623,7 +4623,7 @@ void GuiView::doShowDialog(QString const & qname, QString const & qdata, if (dialog) { bool const visible = dialog->isVisibleView(); dialog->showData(sdata); - if (inset && currentBufferView()) + if (currentBufferView()) currentBufferView()->editInset(name, inset); // We only set the focus to the new dialog if it was not yet // visible in order not to change the existing previous behaviour