From d8028397b2c0a802f2e3213cfca1b3dce83ce17a Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Thu, 18 Sep 2003 10:39:09 +0000 Subject: [PATCH] Don't build a dialog prior to hiding it... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7785 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/ChangeLog | 7 +++++++ src/frontends/Dialogs.C | 27 +++++++++++++++------------ src/frontends/Dialogs.h | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 913046688b..c0a0f7a7a6 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,10 @@ +2003-09-18 Angus Leeming + + * Dialogs.[Ch] (find): renamed as find_or_build. + (update, hideSlot): don't call find_or_build to find the requested dialog. + Instead, search dialogs_, the list of already constructed dialogs. If it + ain't found, do nothing. + 2003-09-16 Angus Leeming * screen.C: add #include "LColor.h". diff --git a/src/frontends/Dialogs.C b/src/frontends/Dialogs.C index e2c57741d0..04d404fe44 100644 --- a/src/frontends/Dialogs.C +++ b/src/frontends/Dialogs.C @@ -75,7 +75,7 @@ Dialogs::Dialogs(LyXView & lyxview) } -Dialog * Dialogs::find(string const & name) +Dialog * Dialogs::find_or_build(string const & name) { if (!isValidName(name)) return 0; @@ -83,18 +83,17 @@ Dialog * Dialogs::find(string const & name) std::map::iterator it = dialogs_.find(name); - if (it == dialogs_.end()) { - dialogs_[name] = DialogPtr(build(name)); - return dialogs_[name].get(); - } + if (it != dialogs_.end()) + return it->second.get(); - return it->second.get(); + dialogs_[name] = DialogPtr(build(name)); + return dialogs_[name].get(); } void Dialogs::show(string const & name, string const & data) { - Dialog * dialog = find(name); + Dialog * dialog = find_or_build(name); if (!dialog) return; @@ -105,7 +104,7 @@ void Dialogs::show(string const & name, string const & data) void Dialogs::show(string const & name, string const & data, InsetBase * inset) { - Dialog * dialog = find(name); + Dialog * dialog = find_or_build(name); if (!dialog) return; @@ -127,10 +126,12 @@ bool Dialogs::visible(string const & name) const void Dialogs::update(string const & name, string const & data) { - Dialog * dialog = find(name); - if (!dialog) + std::map::const_iterator it = + dialogs_.find(name); + if (it == dialogs_.end()) return; + Dialog * const dialog = it->second.get(); if (dialog->isVisible()) dialog->update(data); } @@ -138,13 +139,15 @@ void Dialogs::update(string const & name, string const & data) void Dialogs::hideSlot(string const & name, InsetBase * inset) { - Dialog * dialog = find(name); - if (!dialog) + std::map::const_iterator it = + dialogs_.find(name); + if (it == dialogs_.end()) return; if (inset && inset != getOpenInset(name)) return; + Dialog * const dialog = it->second.get(); if (dialog->isVisible()) dialog->hide(); open_insets_[name] = 0; diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 1caf3d49e2..6e5d8ee9f8 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -132,7 +132,7 @@ private: /// bool isValidName(string const & name) const; /// - Dialog * find(string const & name); + Dialog * find_or_build(string const & name); /// Dialog * build(string const & name); -- 2.39.2