From f5418aa263bfc56fb8bae0ee6d9085484a62208f Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 28 Nov 2019 18:22:03 +0100 Subject: [PATCH] GUI: Fix a couple cases where a null lineedit completer could cause a crash --- src/qtgui/ssearch_w.cpp | 83 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/src/qtgui/ssearch_w.cpp b/src/qtgui/ssearch_w.cpp index 8cfd16ed..33b077f6 100644 --- a/src/qtgui/ssearch_w.cpp +++ b/src/qtgui/ssearch_w.cpp @@ -77,7 +77,7 @@ int RclCompleterModel::rowCount(const QModelIndex &) const QVariant RclCompleterModel::data(const QModelIndex &index, int role) const { LOGDEB1("RclCompleterModel::data: row: " << index.row() << " role " << - role << "\n"); + role << "\n"); if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::DecorationRole) { return QVariant(); @@ -216,7 +216,7 @@ void SSearch::onCompleterShown() LOGDEB0("SSearch::onCompleterShown: no completer\n"); return; } - QAbstractItemView *popup = queryText->completer()->popup(); + QAbstractItemView *popup = completer->popup(); if (!popup) { LOGDEB0("SSearch::onCompleterShown: no popup\n"); return; @@ -320,7 +320,8 @@ void SSearch::onCompletionActivated(const QString& text) void SSearch::onHistoryClicked() { - if (m_completermodel) { + if (m_completermodel) { + queryText->setCompleter(m_completer); m_completermodel->onPartialWord(SST_LANG, "", ""); queryText->completer()->complete(); } @@ -373,42 +374,42 @@ void SSearch::searchTypeChanged(int typ) switch (typ) { case SST_LANG: queryText->setToolTip( - // Do not modify the text here, test with the - // sshelp/qhelp.html file and a browser, then use - // sshelp/helphtmltoc.sh to turn to code and insert here -tr("") + -tr("

Query language cheat-sheet. In doubt: click Show Query. ") + -tr("You should really look at the manual (F1)

") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("") + -tr("
WhatExamples
Andone two   one AND two   one && two
Orone OR two   one || two
Complex boolean. OR has priority, use parentheses ") + -tr("where needed(one AND two) OR three
Not-term
Phrase\"pride and prejudice\"
Ordered proximity (slack=1)\"pride prejudice\"o1
Unordered proximity (slack=1)\"prejudice pride\"po1
Unordered prox. (default slack=10)\"prejudice pride\"p
No stem expansion: capitalizeFloor
Field-specificauthor:austen  title:prejudice
AND inside field (no order)author:jane,austen
OR inside fieldauthor:austen/bronte
Field namestitle/subject/caption  author/from
recipient/to  filename  ext
Directory path filterdir:/home/me  dir:doc
MIME type filtermime:text/plain mime:video/*
Date intervalsdate:2018-01-01/2018-31-12
") + -tr("date:2018  date:2018-01-01/P12M
Sizesize>100k size<1M
") + // Do not modify the text here, test with the + // sshelp/qhelp.html file and a browser, then use + // sshelp/helphtmltoc.sh to turn to code and insert here + tr("") + + tr("

Query language cheat-sheet. In doubt: click Show Query. ") + + tr("You should really look at the manual (F1)

") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("") + + tr("
WhatExamples
Andone two   one AND two   one && two
Orone OR two   one || two
Complex boolean. OR has priority, use parentheses ") + + tr("where needed(one AND two) OR three
Not-term
Phrase\"pride and prejudice\"
Ordered proximity (slack=1)\"pride prejudice\"o1
Unordered proximity (slack=1)\"prejudice pride\"po1
Unordered prox. (default slack=10)\"prejudice pride\"p
No stem expansion: capitalizeFloor
Field-specificauthor:austen  title:prejudice
AND inside field (no order)author:jane,austen
OR inside fieldauthor:austen/bronte
Field namestitle/subject/caption  author/from
recipient/to  filename  ext
Directory path filterdir:/home/me  dir:doc
MIME type filtermime:text/plain mime:video/*
Date intervalsdate:2018-01-01/2018-31-12
") + + tr("date:2018  date:2018-01-01/P12M
Sizesize>100k size<1M
") ); break; case SST_FNM: @@ -423,7 +424,7 @@ tr("") void SSearch::startSimpleSearch() { - if (queryText->completer()->popup()->isVisible()) { + if (queryText->completer() && queryText->completer()->popup()->isVisible()) { return; } string u8 = qs2u8s(queryText->text()); @@ -446,7 +447,7 @@ void SSearch::startSimpleSearch() if (prefs.historysize >= 0) { for (int i = (int)prefs.ssearchHistory.count(); i > prefs.historysize; i--) { - prefs.ssearchHistory.removeLast(); + prefs.ssearchHistory.removeLast(); } } }