mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-13 06:20:28 +00:00
* fix another crash due to the redraw opti-/minimization during
completion. We have to show and hide the popup asynchronously with a singleshot timer. Otherwise it might trigger accesses to the coord cache although the metrics have not been done yet. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23424 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a4b2404cb1
commit
b4466b63f6
@ -171,7 +171,7 @@ private:
|
|||||||
|
|
||||||
GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
|
GuiCompleter::GuiCompleter(GuiWorkArea * gui, QObject * parent)
|
||||||
: QCompleter(parent), gui_(gui), updateLock_(0),
|
: QCompleter(parent), gui_(gui), updateLock_(0),
|
||||||
inlineVisible_(false)
|
inlineVisible_(false), popupVisible_(false)
|
||||||
{
|
{
|
||||||
// Setup the completion popup
|
// Setup the completion popup
|
||||||
setModel(new GuiCompletionModel(this, 0));
|
setModel(new GuiCompletionModel(this, 0));
|
||||||
@ -260,7 +260,7 @@ bool GuiCompleter::completionAvailable() const
|
|||||||
|
|
||||||
bool GuiCompleter::popupVisible() const
|
bool GuiCompleter::popupVisible() const
|
||||||
{
|
{
|
||||||
return popup()->isVisible();
|
return popupVisible_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -392,9 +392,28 @@ void GuiCompleter::updatePopup(Cursor & cur)
|
|||||||
if (!cur.inset().completionSupported(cur))
|
if (!cur.inset().completionSupported(cur))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (completionCount() == 0)
|
popupVisible_ = true;
|
||||||
|
|
||||||
|
if (completionCount() == 0) {
|
||||||
|
QTimer::singleShot(0, popup(), SLOT(hide()));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// show asynchronously to avoid lookups before the metrics
|
||||||
|
// have been computed. This can happen because we might be in
|
||||||
|
// the middle of a dispatch.
|
||||||
|
QTimer::singleShot(0, this, SLOT(asyncCompletePopup()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiCompleter::asyncCompletePopup()
|
||||||
|
{
|
||||||
|
Cursor cur = gui_->bufferView().cursor();
|
||||||
|
if (!cur.inset().completionSupported(cur)) {
|
||||||
|
popupVisible_ = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get dimensions of completion prefix
|
// get dimensions of completion prefix
|
||||||
Dimension dim;
|
Dimension dim;
|
||||||
int x;
|
int x;
|
||||||
@ -504,6 +523,8 @@ void GuiCompleter::showPopup(Cursor & cur)
|
|||||||
|
|
||||||
void GuiCompleter::hidePopup(Cursor & cur)
|
void GuiCompleter::hidePopup(Cursor & cur)
|
||||||
{
|
{
|
||||||
|
popupVisible_ = false;
|
||||||
|
|
||||||
// hide popup asynchronously because we might be here inside of
|
// hide popup asynchronously because we might be here inside of
|
||||||
// LFUN dispatchers. Hiding a popup can trigger a focus event on the
|
// LFUN dispatchers. Hiding a popup can trigger a focus event on the
|
||||||
// workarea which then redisplays the cursor. But the metrics are not
|
// workarea which then redisplays the cursor. But the metrics are not
|
||||||
@ -533,6 +554,9 @@ void GuiCompleter::hideInline(Cursor & cur)
|
|||||||
gui_->bufferView().setInlineCompletion(cur, DocIterator(), docstring());
|
gui_->bufferView().setInlineCompletion(cur, DocIterator(), docstring());
|
||||||
inlineVisible_ = false;
|
inlineVisible_ = false;
|
||||||
|
|
||||||
|
if (inline_timer_.isActive())
|
||||||
|
inline_timer_.stop();
|
||||||
|
|
||||||
if (!popupVisible())
|
if (!popupVisible())
|
||||||
setModel(new GuiCompletionModel(this, 0));
|
setModel(new GuiCompletionModel(this, 0));
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,8 @@ private Q_SLOTS:
|
|||||||
void popupHighlighted(const QString & completion);
|
void popupHighlighted(const QString & completion);
|
||||||
///
|
///
|
||||||
void updateAvailability();
|
void updateAvailability();
|
||||||
|
///
|
||||||
|
void asyncCompletePopup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
@ -128,6 +130,8 @@ private:
|
|||||||
/// in addition to know whether the completion is to be kept visible.
|
/// in addition to know whether the completion is to be kept visible.
|
||||||
bool inlineVisible_;
|
bool inlineVisible_;
|
||||||
///
|
///
|
||||||
|
bool popupVisible_;
|
||||||
|
///
|
||||||
RtlItemDelegate * rtlItemDelegate_;
|
RtlItemDelegate * rtlItemDelegate_;
|
||||||
}; // GuiCompleter
|
}; // GuiCompleter
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user