mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Avoid crash when selecting long text
In some (not yet understood) situations, the paragraph metrics cache is empty in generateSyntheticMouseEvent(). We just avoid a crash in this case, but there is probably an underlying problem that deserves being fixed. Fixes bug #10324.
This commit is contained in:
parent
c5e53637c2
commit
4efb129ccb
@ -94,6 +94,8 @@ public:
|
||||
bool redoParagraph(pit_type const pit);
|
||||
/// Clear cache of paragraph metrics
|
||||
void clear() { par_metrics_.clear(); }
|
||||
/// Is cache of paragraph metrics empty ?
|
||||
bool empty() const { return par_metrics_.empty(); }
|
||||
|
||||
///
|
||||
int ascent() const { return dim_.asc; }
|
||||
|
@ -1004,12 +1004,18 @@ void GuiWorkArea::generateSyntheticMouseEvent()
|
||||
|
||||
// In which paragraph do we have to set the cursor ?
|
||||
Cursor & cur = d->buffer_view_->cursor();
|
||||
// FIXME: we don't know howto handle math.
|
||||
// FIXME: we don't know how to handle math.
|
||||
Text * text = cur.text();
|
||||
if (!text)
|
||||
return;
|
||||
TextMetrics const & tm = d->buffer_view_->textMetrics(text);
|
||||
|
||||
// Quit gracefully if there are no metrics, since otherwise next
|
||||
// line would crash (bug #10324).
|
||||
// This situation seems related to a (not yet understood) timing problem.
|
||||
if (tm.empty())
|
||||
return;
|
||||
|
||||
pair<pit_type, const ParagraphMetrics *> pp = up ? tm.first() : tm.last();
|
||||
ParagraphMetrics const & pm = *pp.second;
|
||||
pit_type const pit = pp.first;
|
||||
|
Loading…
Reference in New Issue
Block a user