forked from qt-creator/qt-creator
Work around crash when dragging text from tool tip
Disallow text selection for the code model tool tips because dragging the selection somewhere crashes. Task-number: QTCREATORBUG-21430 Change-Id: I3aed4e16bf429162258d2dfafaa45fff25ba700a Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -98,6 +98,7 @@ public:
|
|||||||
bool enableClickableFixits;
|
bool enableClickableFixits;
|
||||||
bool limitWidth;
|
bool limitWidth;
|
||||||
bool hideTooltipAfterLinkActivation;
|
bool hideTooltipAfterLinkActivation;
|
||||||
|
bool allowTextSelection;
|
||||||
};
|
};
|
||||||
|
|
||||||
static QWidget *create(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
static QWidget *create(const QVector<ClangBackEnd::DiagnosticContainer> &diagnostics,
|
||||||
@@ -122,7 +123,12 @@ private:
|
|||||||
auto *label = new QLabel;
|
auto *label = new QLabel;
|
||||||
label->setTextFormat(Qt::RichText);
|
label->setTextFormat(Qt::RichText);
|
||||||
label->setText(text);
|
label->setText(text);
|
||||||
|
if (m_displayHints.allowTextSelection) {
|
||||||
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
} else {
|
||||||
|
label->setTextInteractionFlags(Qt::LinksAccessibleByMouse
|
||||||
|
| Qt::LinksAccessibleByKeyboard);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_displayHints.limitWidth) {
|
if (m_displayHints.limitWidth) {
|
||||||
const int limit = widthLimit();
|
const int limit = widthLimit();
|
||||||
@@ -457,6 +463,7 @@ QWidget *ClangDiagnosticWidget::create(
|
|||||||
hints.enableClickableFixits = true;
|
hints.enableClickableFixits = true;
|
||||||
hints.limitWidth = true;
|
hints.limitWidth = true;
|
||||||
hints.hideTooltipAfterLinkActivation = true;
|
hints.hideTooltipAfterLinkActivation = true;
|
||||||
|
hints.allowTextSelection = false;
|
||||||
} else { // Info Bar
|
} else { // Info Bar
|
||||||
hints.showCategoryAndEnableOption = false;
|
hints.showCategoryAndEnableOption = false;
|
||||||
hints.showFileNameInMainDiagnostic = true;
|
hints.showFileNameInMainDiagnostic = true;
|
||||||
@@ -464,6 +471,7 @@ QWidget *ClangDiagnosticWidget::create(
|
|||||||
hints.enableClickableFixits = false;
|
hints.enableClickableFixits = false;
|
||||||
hints.limitWidth = false;
|
hints.limitWidth = false;
|
||||||
hints.hideTooltipAfterLinkActivation = false;
|
hints.hideTooltipAfterLinkActivation = false;
|
||||||
|
hints.allowTextSelection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return WidgetFromDiagnostics::create(diagnostics, hints);
|
return WidgetFromDiagnostics::create(diagnostics, hints);
|
||||||
|
Reference in New Issue
Block a user