]> git.lyx.org Git - lyx.git/commitdiff
Avoid crash when InsetBibitem::updateCommand shows a dialog
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 2 Jul 2024 12:49:34 +0000 (14:49 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 2 Jul 2024 12:54:20 +0000 (14:54 +0200)
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.

src/insets/InsetBibitem.cpp

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