forked from qt-creator/qt-creator
widget as a std::unique_ptr is bad
- a widget is often used as a raw pointer and in most cases the parent will take care of destructing it - here the context is also destructing the widget - so move back to QPointer and keep deleting to the context Change-Id: Ief5c4faa08d5e76f723b35d33d09fafc502c2d8a Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
d745e2fac0
commit
5d98899ffd
@@ -66,7 +66,7 @@ const char TEXTEDITOR_CONTEXT_ID[] = "QmlDesigner.TextEditorContext";
|
||||
TextEditorView::TextEditorView(QObject *parent)
|
||||
: AbstractView(parent)
|
||||
, m_widget(new TextEditorWidget(this))
|
||||
, m_textEditorContext(new Internal::TextEditorContext(m_widget.get()))
|
||||
, m_textEditorContext(new Internal::TextEditorContext(m_widget))
|
||||
{
|
||||
Core::ICore::addContextObject(m_textEditorContext);
|
||||
|
||||
@@ -89,6 +89,7 @@ TextEditorView::TextEditorView(QObject *parent)
|
||||
|
||||
TextEditorView::~TextEditorView()
|
||||
{
|
||||
// m_textEditorContext is responsible for deleting the widget
|
||||
}
|
||||
|
||||
void TextEditorView::modelAttached(Model *model)
|
||||
@@ -148,7 +149,7 @@ void TextEditorView::nodeReparented(const ModelNode &/*node*/, const NodeAbstrac
|
||||
|
||||
WidgetInfo TextEditorView::widgetInfo()
|
||||
{
|
||||
return createWidgetInfo(m_widget.get(), 0, "TextEditor", WidgetInfo::CentralPane, 0, tr("Text Editor"), DesignerWidgetFlags::IgnoreErrors);
|
||||
return createWidgetInfo(m_widget, 0, "TextEditor", WidgetInfo::CentralPane, 0, tr("Text Editor"), DesignerWidgetFlags::IgnoreErrors);
|
||||
}
|
||||
|
||||
void TextEditorView::contextHelpId(const Core::IContext::HelpIdCallback &callback) const
|
||||
|
@@ -101,7 +101,7 @@ public:
|
||||
void reformatFile();
|
||||
|
||||
private:
|
||||
std::unique_ptr<TextEditorWidget> m_widget;
|
||||
QPointer<TextEditorWidget> m_widget;
|
||||
Internal::TextEditorContext *m_textEditorContext;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user