mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-01 05:25:55 +00:00
c1fd622c51
When a buffer is reloaded, its content may remain the same, but the memory allocation is new, so that the inset pointers in cursors are now wrong. This requires to sanitize the cursors held by the buffer views. Before the biginset branch, some full metrics computation call that is now removed probably did that as a side effect. Now we have to be more precise. To this effect, introduce WorkAreaManager::sanitizeCursors() and use it in Buffer::reload().
87 lines
1.4 KiB
C++
87 lines
1.4 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file WorkAreaManager.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Abdelrazak Younes
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "WorkAreaManager.h"
|
|
|
|
#include "BufferView.h"
|
|
#include "Cursor.h"
|
|
|
|
#include "Application.h"
|
|
#include "WorkArea.h"
|
|
|
|
|
|
namespace lyx {
|
|
namespace frontend {
|
|
|
|
void WorkAreaManager::add(WorkArea * wa)
|
|
{
|
|
work_areas_.push_back(wa);
|
|
}
|
|
|
|
|
|
void WorkAreaManager::remove(WorkArea * wa)
|
|
{
|
|
work_areas_.remove(wa);
|
|
}
|
|
|
|
|
|
void WorkAreaManager::redrawAll(bool update_metrics)
|
|
{
|
|
for (WorkArea * wa : work_areas_)
|
|
wa->scheduleRedraw(update_metrics);
|
|
}
|
|
|
|
|
|
void WorkAreaManager::closeAll()
|
|
{
|
|
while (!work_areas_.empty())
|
|
// WorkArea is de-registering itself.
|
|
(*work_areas_.begin())->close();
|
|
}
|
|
|
|
|
|
bool WorkAreaManager::unhide(Buffer * buf) const
|
|
{
|
|
if (!work_areas_.empty())
|
|
return true;
|
|
return theApp()->unhide(buf);
|
|
}
|
|
|
|
|
|
void WorkAreaManager::updateTitles()
|
|
{
|
|
for (WorkArea * wa : work_areas_)
|
|
wa->updateWindowTitle();
|
|
}
|
|
|
|
|
|
void WorkAreaManager::scheduleRedraw()
|
|
{
|
|
for (WorkArea * wa : work_areas_)
|
|
wa->scheduleRedraw(true);
|
|
}
|
|
|
|
|
|
void WorkAreaManager::sanitizeCursors()
|
|
{
|
|
for (WorkArea * wa : work_areas_) {
|
|
wa->bufferView().cursor().sanitize();
|
|
wa->bufferView().resetInlineCompletionPos();
|
|
}
|
|
}
|
|
|
|
|
|
} // namespace frontend
|
|
} // namespace lyx
|
|
|