Avoid crash when InsetBibitem::updateCommand shows a dialog

This is one of the places where a dialog is shown (indicating that
some bibtems have been renamed) while the metrics are not up to date.
Then a draw operation can be triggered too early and a crash can ensue.

Use ad-hoc solution for this case and use Buffer::setBusy(). The
Alert::warning helper cannot really do that since it doe snot know the
current buffer.
This commit is contained in:
Jean-Marc Lasgouttes 2024-07-02 14:49:34 +02:00
parent 574db22025
commit c84c59eaec

View File

@ -95,9 +95,11 @@ void InsetBibitem::updateCommand(docstring const & new_key, bool)
++i; ++i;
key = new_key + '-' + convert<docstring>(i); key = new_key + '-' + convert<docstring>(i);
} }
buffer().setBusy(true);
frontend::Alert::warning(_("Keys must be unique!"), frontend::Alert::warning(_("Keys must be unique!"),
bformat(_("The key %1$s already exists,\n" bformat(_("The key %1$s already exists,\n"
"it will be changed to %2$s."), new_key, key)); "it will be changed to %2$s."), new_key, key));
buffer().setBusy(false);
} }
setParam("key", key); setParam("key", key);
buffer().invalidateBibinfoCache(); buffer().invalidateBibinfoCache();