forked from qt-creator/qt-creator
TextEditor: use modern approach to delete TextEditorWidgetPrivate
Try to tackle the crash at destruction: https://the-qt-company-00.sentry.io/issues/5315538277 https://the-qt-company-00.sentry.io/issues/5312380342 https://the-qt-company-00.sentry.io/issues/5237253338 Pick-to: qds/4.5 Change-Id: Id4436bf5adc0c725f9b5538480619ed99428413f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1262,15 +1262,15 @@ TextEditorWidget::TextEditorWidget(QWidget *parent)
|
|||||||
{
|
{
|
||||||
// "Needed", as the creation below triggers ChildEvents that are
|
// "Needed", as the creation below triggers ChildEvents that are
|
||||||
// passed to this object's event() which uses 'd'.
|
// passed to this object's event() which uses 'd'.
|
||||||
d = nullptr;
|
d = std::make_unique<Internal::TextEditorWidgetPrivate>(this);
|
||||||
d = new TextEditorWidgetPrivate(this);
|
|
||||||
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
setLayoutDirection(Qt::LeftToRight);
|
setLayoutDirection(Qt::LeftToRight);
|
||||||
viewport()->setMouseTracking(true);
|
viewport()->setMouseTracking(true);
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextEditorWidget::~TextEditorWidget() = default;
|
||||||
|
|
||||||
void TextEditorWidget::setTextDocument(const QSharedPointer<TextDocument> &doc)
|
void TextEditorWidget::setTextDocument(const QSharedPointer<TextDocument> &doc)
|
||||||
{
|
{
|
||||||
d->setDocument(doc);
|
d->setDocument(doc);
|
||||||
@@ -1449,12 +1449,6 @@ void TextEditorWidgetPrivate::setDocument(const QSharedPointer<TextDocument> &do
|
|||||||
setupFromDefinition(currentDefinition());
|
setupFromDefinition(currentDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditorWidget::~TextEditorWidget()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
d = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextEditorWidget::print(QPrinter *printer)
|
void TextEditorWidget::print(QPrinter *printer)
|
||||||
{
|
{
|
||||||
const bool oldFullPage = printer->fullPage();
|
const bool oldFullPage = printer->fullPage();
|
||||||
@@ -5796,7 +5790,7 @@ void TextEditorWidgetPrivate::paintRevisionMarker(QPainter &painter,
|
|||||||
|
|
||||||
void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
|
void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e)
|
||||||
{
|
{
|
||||||
ExtraAreaPaintEventData data(this, d);
|
ExtraAreaPaintEventData data(this, d.get());
|
||||||
QTC_ASSERT(data.documentLayout, return);
|
QTC_ASSERT(data.documentLayout, return);
|
||||||
|
|
||||||
QPainter painter(d->m_extraArea);
|
QPainter painter(d->m_extraArea);
|
||||||
@@ -9402,7 +9396,7 @@ void TextEditorWidget::setupGenericHighlighter()
|
|||||||
setLineSeparatorsAllowed(true);
|
setLineSeparatorsAllowed(true);
|
||||||
|
|
||||||
connect(textDocument(), &IDocument::filePathChanged,
|
connect(textDocument(), &IDocument::filePathChanged,
|
||||||
d, &TextEditorWidgetPrivate::reconfigure);
|
d.get(), &TextEditorWidgetPrivate::reconfigure);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@@ -637,7 +637,7 @@ protected:
|
|||||||
virtual void slotCodeStyleSettingsChanged(const QVariant &); // Used in CppEditor
|
virtual void slotCodeStyleSettingsChanged(const QVariant &); // Used in CppEditor
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internal::TextEditorWidgetPrivate *d;
|
std::unique_ptr<Internal::TextEditorWidgetPrivate> d;
|
||||||
friend class BaseTextEditor;
|
friend class BaseTextEditor;
|
||||||
friend class TextEditorFactory;
|
friend class TextEditorFactory;
|
||||||
friend class Internal::TextEditorFactoryPrivate;
|
friend class Internal::TextEditorFactoryPrivate;
|
||||||
|
Reference in New Issue
Block a user