From 26e8409172ead4b32cdf766501b2f8d07d823314 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 23 May 2008 10:54:34 +0000 Subject: [PATCH] simplify GuiApplication::unregisterView(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24905 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiApplication.cpp | 16 +++------------- src/frontends/qt4/GuiApplication.h | 2 +- src/frontends/qt4/GuiView.cpp | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 874ee04e02..44896ed08c 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -982,20 +982,10 @@ void GuiApplication::commitData(QSessionManager & sm) } -bool GuiApplication::unregisterView(int id) +void GuiApplication::unregisterView(GuiView * gv) { - LASSERT(d->views_.find(id) != d->views_.end(), /**/); - LASSERT(d->views_[id], /**/); - - map::iterator it; - for (it = d->views_.begin(); it != d->views_.end(); ++it) { - if (it->first == id) { - d->views_.erase(id); - break; - } - } - - return true; + LASSERT(d->views_[gv->id()] == gv, /**/); + d->views_.erase(gv->id()); } diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 97b6c4622a..7249631d27 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -112,7 +112,7 @@ public: /// return a suitable monospaced font name. QString const typewriterFontName(); /// - bool unregisterView(int id); + void unregisterView(GuiView * gv); /// GuiView & view(int id) const; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 63bd54ec63..3856e76280 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -458,7 +458,7 @@ void GuiView::closeEvent(QCloseEvent * close_event) it->second->saveSession(); } - guiApp->unregisterView(id_); + guiApp->unregisterView(this); close_event->accept(); }