mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Simplify WorkArea (de-)registering: now done at WorkArea construction and destruction.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20665 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f0402e69c6
commit
fce745f111
@ -18,6 +18,7 @@
|
|||||||
#include "frontends/Application.h"
|
#include "frontends/Application.h"
|
||||||
#include "frontends/FontMetrics.h"
|
#include "frontends/FontMetrics.h"
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
|
#include "frontends/WorkAreaManager.h"
|
||||||
|
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
@ -68,6 +69,7 @@ WorkArea::WorkArea(Buffer & buffer, LyXView & lv)
|
|||||||
: buffer_view_(new BufferView(buffer)), lyx_view_(&lv),
|
: buffer_view_(new BufferView(buffer)), lyx_view_(&lv),
|
||||||
cursor_visible_(false), cursor_timeout_(400)
|
cursor_visible_(false), cursor_timeout_(400)
|
||||||
{
|
{
|
||||||
|
buffer.workAreaManager().add(this);
|
||||||
// Setup the signals
|
// Setup the signals
|
||||||
timecon = cursor_timeout_.timeout
|
timecon = cursor_timeout_.timeout
|
||||||
.connect(boost::bind(&WorkArea::toggleCursor, this));
|
.connect(boost::bind(&WorkArea::toggleCursor, this));
|
||||||
@ -78,6 +80,7 @@ WorkArea::WorkArea(Buffer & buffer, LyXView & lv)
|
|||||||
|
|
||||||
WorkArea::~WorkArea()
|
WorkArea::~WorkArea()
|
||||||
{
|
{
|
||||||
|
buffer_view_->buffer().workAreaManager().remove(this);
|
||||||
delete buffer_view_;
|
delete buffer_view_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
using std::list;
|
using std::list;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
extern bool quitting;
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
void WorkAreaManager::add(WorkArea * wa)
|
void WorkAreaManager::add(WorkArea * wa)
|
||||||
@ -44,13 +47,12 @@ void WorkAreaManager::redrawAll()
|
|||||||
|
|
||||||
void WorkAreaManager::closeAll()
|
void WorkAreaManager::closeAll()
|
||||||
{
|
{
|
||||||
for (list<WorkArea *>::iterator it = work_areas_.begin();
|
if (quitting)
|
||||||
it != work_areas_.end(); ) {
|
return;
|
||||||
(*it)->close();
|
|
||||||
if (work_areas_.empty())
|
while (!work_areas_.empty())
|
||||||
break;
|
// WorkArea is de-registering itself.
|
||||||
++it;
|
(*work_areas_.begin())->close();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "frontends/Gui.h"
|
#include "frontends/Gui.h"
|
||||||
#include "frontends/WorkArea.h"
|
#include "frontends/WorkArea.h"
|
||||||
#include "frontends/WorkAreaManager.h"
|
|
||||||
|
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/convert.h"
|
#include "support/convert.h"
|
||||||
@ -298,8 +297,6 @@ void GuiViewBase::close()
|
|||||||
for (int i = 0; i != d.tab_widget_->count(); ++i) {
|
for (int i = 0; i != d.tab_widget_->count(); ++i) {
|
||||||
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
|
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(d.tab_widget_->widget(i));
|
||||||
BOOST_ASSERT(wa);
|
BOOST_ASSERT(wa);
|
||||||
Buffer & buffer = wa->bufferView().buffer();
|
|
||||||
buffer.workAreaManager().remove(wa);
|
|
||||||
d.tab_widget_->removeTab(i);
|
d.tab_widget_->removeTab(i);
|
||||||
delete wa;
|
delete wa;
|
||||||
}
|
}
|
||||||
@ -867,8 +864,6 @@ WorkArea * GuiViewBase::addWorkArea(Buffer & buffer)
|
|||||||
d.stack_widget_->setCurrentWidget(d.tab_widget_);
|
d.stack_widget_->setCurrentWidget(d.tab_widget_);
|
||||||
// Hide tabbar if there's only one tab.
|
// Hide tabbar if there's only one tab.
|
||||||
d.tab_widget_->showBar(d.tab_widget_->count() > 1);
|
d.tab_widget_->showBar(d.tab_widget_->count() > 1);
|
||||||
///
|
|
||||||
buffer.workAreaManager().add(wa);
|
|
||||||
return wa;
|
return wa;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,9 +914,6 @@ void GuiViewBase::removeWorkArea(WorkArea * work_area)
|
|||||||
disconnectBufferView();
|
disconnectBufferView();
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer & buffer = work_area->bufferView().buffer();
|
|
||||||
buffer.workAreaManager().remove(work_area);
|
|
||||||
|
|
||||||
// removing a work area often results from closing a file so
|
// removing a work area often results from closing a file so
|
||||||
// update the toc in any case.
|
// update the toc in any case.
|
||||||
updateToc();
|
updateToc();
|
||||||
|
Loading…
Reference in New Issue
Block a user