forked from qt-creator/qt-creator
Remove ToolBarWidgetFactoryInterface from WidgetInfo
Since it is sometimes created with new but never used, it leaked memory. Change-Id: I5adfb71f9c773be37c1cefc619236bad9f34aad1 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -207,7 +207,6 @@ void ConnectionView::importsChanged(const QList<Import> & /*addedImports*/, cons
|
|||||||
WidgetInfo ConnectionView::widgetInfo()
|
WidgetInfo ConnectionView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(m_connectionViewWidget.data(),
|
return createWidgetInfo(m_connectionViewWidget.data(),
|
||||||
new WidgetInfo::ToolBarWidgetDefaultFactory<ConnectionViewWidget>(connectionViewWidget()),
|
|
||||||
QLatin1String("ConnectionView"),
|
QLatin1String("ConnectionView"),
|
||||||
WidgetInfo::LeftPane,
|
WidgetInfo::LeftPane,
|
||||||
0,
|
0,
|
||||||
|
@@ -70,7 +70,7 @@ bool CurveEditorView::hasWidget() const
|
|||||||
WidgetInfo CurveEditorView::widgetInfo()
|
WidgetInfo CurveEditorView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(
|
return createWidgetInfo(
|
||||||
m_editor, nullptr, "CurveEditorId", WidgetInfo::BottomPane, 0, tr("CurveEditor"));
|
m_editor, "CurveEditorId", WidgetInfo::BottomPane, 0, tr("CurveEditor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveEditorView::modelAttached(Model *model)
|
void CurveEditorView::modelAttached(Model *model)
|
||||||
|
@@ -355,7 +355,7 @@ void DebugView::rewriterEndTransaction()
|
|||||||
|
|
||||||
WidgetInfo DebugView::widgetInfo()
|
WidgetInfo DebugView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(m_debugViewWidget.data(), nullptr, QStringLiteral("DebugView"), WidgetInfo::LeftPane, 0, tr("Debug View"));
|
return createWidgetInfo(m_debugViewWidget.data(), QStringLiteral("DebugView"), WidgetInfo::LeftPane, 0, tr("Debug View"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DebugView::hasWidget() const
|
bool DebugView::hasWidget() const
|
||||||
|
@@ -83,7 +83,7 @@ WidgetInfo Edit3DView::widgetInfo()
|
|||||||
if (!m_edit3DWidget)
|
if (!m_edit3DWidget)
|
||||||
createEdit3DWidget();
|
createEdit3DWidget();
|
||||||
|
|
||||||
return createWidgetInfo(m_edit3DWidget.data(), nullptr, "Editor3D", WidgetInfo::CentralPane, 0, tr("3D Editor"), DesignerWidgetFlags::IgnoreErrors);
|
return createWidgetInfo(m_edit3DWidget.data(), "Editor3D", WidgetInfo::CentralPane, 0, tr("3D Editor"), DesignerWidgetFlags::IgnoreErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
Edit3DWidget *Edit3DView::edit3DWidget() const
|
Edit3DWidget *Edit3DView::edit3DWidget() const
|
||||||
|
@@ -361,7 +361,7 @@ WidgetInfo FormEditorView::widgetInfo()
|
|||||||
if (!m_formEditorWidget)
|
if (!m_formEditorWidget)
|
||||||
createFormEditorWidget();
|
createFormEditorWidget();
|
||||||
|
|
||||||
return createWidgetInfo(m_formEditorWidget.data(), nullptr, "FormEditor", WidgetInfo::CentralPane, 0, tr("Form Editor"), DesignerWidgetFlags::IgnoreErrors);
|
return createWidgetInfo(m_formEditorWidget.data(), "FormEditor", WidgetInfo::CentralPane, 0, tr("Form Editor"), DesignerWidgetFlags::IgnoreErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
FormEditorWidget *FormEditorView::formEditorWidget()
|
FormEditorWidget *FormEditorView::formEditorWidget()
|
||||||
|
@@ -104,7 +104,6 @@ WidgetInfo ItemLibraryView::widgetInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return createWidgetInfo(m_widget.data(),
|
return createWidgetInfo(m_widget.data(),
|
||||||
new WidgetInfo::ToolBarWidgetDefaultFactory<ItemLibraryWidget>(m_widget.data()),
|
|
||||||
QStringLiteral("Library"),
|
QStringLiteral("Library"),
|
||||||
WidgetInfo::LeftPane,
|
WidgetInfo::LeftPane,
|
||||||
0,
|
0,
|
||||||
|
@@ -132,7 +132,6 @@ WidgetInfo NavigatorView::widgetInfo()
|
|||||||
setupWidget();
|
setupWidget();
|
||||||
|
|
||||||
return createWidgetInfo(m_widget.data(),
|
return createWidgetInfo(m_widget.data(),
|
||||||
new WidgetInfo::ToolBarWidgetDefaultFactory<NavigatorWidget>(m_widget.data()),
|
|
||||||
QStringLiteral("Navigator"),
|
QStringLiteral("Navigator"),
|
||||||
WidgetInfo::LeftPane,
|
WidgetInfo::LeftPane,
|
||||||
0,
|
0,
|
||||||
|
@@ -795,7 +795,7 @@ bool PropertyEditorView::hasWidget() const
|
|||||||
|
|
||||||
WidgetInfo PropertyEditorView::widgetInfo()
|
WidgetInfo PropertyEditorView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(m_stackedWidget, nullptr, QStringLiteral("Properties"), WidgetInfo::RightPane, 0, tr("Properties"));
|
return createWidgetInfo(m_stackedWidget, QStringLiteral("Properties"), WidgetInfo::RightPane, 0, tr("Properties"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyEditorView::currentStateChanged(const ModelNode &node)
|
void PropertyEditorView::currentStateChanged(const ModelNode &node)
|
||||||
|
@@ -77,7 +77,7 @@ WidgetInfo StatesEditorView::widgetInfo()
|
|||||||
if (!m_statesEditorWidget)
|
if (!m_statesEditorWidget)
|
||||||
m_statesEditorWidget = new StatesEditorWidget(this, m_statesEditorModel.data());
|
m_statesEditorWidget = new StatesEditorWidget(this, m_statesEditorModel.data());
|
||||||
|
|
||||||
return createWidgetInfo(m_statesEditorWidget.data(), nullptr, QLatin1String("StatesEditor"), WidgetInfo::BottomPane, 0, tr("States"));
|
return createWidgetInfo(m_statesEditorWidget.data(), QLatin1String("StatesEditor"), WidgetInfo::BottomPane, 0, tr("States"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)
|
void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)
|
||||||
|
@@ -149,7 +149,7 @@ void TextEditorView::nodeReparented(const ModelNode &/*node*/, const NodeAbstrac
|
|||||||
|
|
||||||
WidgetInfo TextEditorView::widgetInfo()
|
WidgetInfo TextEditorView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(m_widget, nullptr, "TextEditor", WidgetInfo::CentralPane, 0, tr("Text Editor"), DesignerWidgetFlags::IgnoreErrors);
|
return createWidgetInfo(m_widget, "TextEditor", WidgetInfo::CentralPane, 0, tr("Text Editor"), DesignerWidgetFlags::IgnoreErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEditorView::contextHelp(const Core::IContext::HelpCallback &callback) const
|
void TextEditorView::contextHelp(const Core::IContext::HelpCallback &callback) const
|
||||||
|
@@ -669,7 +669,6 @@ TimelineWidget *TimelineView::createWidget()
|
|||||||
WidgetInfo TimelineView::widgetInfo()
|
WidgetInfo TimelineView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(createWidget(),
|
return createWidgetInfo(createWidget(),
|
||||||
nullptr,
|
|
||||||
QStringLiteral("Timelines"),
|
QStringLiteral("Timelines"),
|
||||||
WidgetInfo::BottomPane,
|
WidgetInfo::BottomPane,
|
||||||
0,
|
0,
|
||||||
|
@@ -323,7 +323,6 @@ TransitionEditorWidget *TransitionEditorView::createWidget()
|
|||||||
WidgetInfo TransitionEditorView::widgetInfo()
|
WidgetInfo TransitionEditorView::widgetInfo()
|
||||||
{
|
{
|
||||||
return createWidgetInfo(createWidget(),
|
return createWidgetInfo(createWidget(),
|
||||||
nullptr,
|
|
||||||
"TransitionEditor",
|
"TransitionEditor",
|
||||||
WidgetInfo::BottomPane,
|
WidgetInfo::BottomPane,
|
||||||
0,
|
0,
|
||||||
|
@@ -70,30 +70,6 @@ enum DesignerWidgetFlags {
|
|||||||
class WidgetInfo {
|
class WidgetInfo {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class ToolBarWidgetFactoryInterface {
|
|
||||||
public:
|
|
||||||
ToolBarWidgetFactoryInterface() = default;
|
|
||||||
|
|
||||||
virtual QList<QToolButton*> createToolBarWidgets() = 0;
|
|
||||||
|
|
||||||
virtual ~ToolBarWidgetFactoryInterface() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
class ToolBarWidgetDefaultFactory : public ToolBarWidgetFactoryInterface {
|
|
||||||
public:
|
|
||||||
ToolBarWidgetDefaultFactory(T *t ) : m_t(t)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QList<QToolButton*> createToolBarWidgets() override
|
|
||||||
{
|
|
||||||
return m_t->createToolBarWidgets();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T * m_t;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum PlacementHint {
|
enum PlacementHint {
|
||||||
NoPane,
|
NoPane,
|
||||||
LeftPane,
|
LeftPane,
|
||||||
@@ -108,7 +84,6 @@ public:
|
|||||||
QWidget *widget = nullptr;
|
QWidget *widget = nullptr;
|
||||||
int placementPriority;
|
int placementPriority;
|
||||||
PlacementHint placementHint;
|
PlacementHint placementHint;
|
||||||
ToolBarWidgetFactoryInterface *toolBarWidgetFactory = nullptr;
|
|
||||||
DesignerWidgetFlags widgetFlags = DesignerWidgetFlags::DisableOnError;
|
DesignerWidgetFlags widgetFlags = DesignerWidgetFlags::DisableOnError;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -311,7 +286,6 @@ protected:
|
|||||||
void setModel(Model * model);
|
void setModel(Model * model);
|
||||||
void removeModel();
|
void removeModel();
|
||||||
static WidgetInfo createWidgetInfo(QWidget *widget = nullptr,
|
static WidgetInfo createWidgetInfo(QWidget *widget = nullptr,
|
||||||
WidgetInfo::ToolBarWidgetFactoryInterface *toolBarWidgetFactory = nullptr,
|
|
||||||
const QString &uniqueId = QString(),
|
const QString &uniqueId = QString(),
|
||||||
WidgetInfo::PlacementHint placementHint = WidgetInfo::NoPane,
|
WidgetInfo::PlacementHint placementHint = WidgetInfo::NoPane,
|
||||||
int placementPriority = 0,
|
int placementPriority = 0,
|
||||||
|
@@ -129,7 +129,6 @@ void AbstractView::removeModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
WidgetInfo AbstractView::createWidgetInfo(QWidget *widget,
|
WidgetInfo AbstractView::createWidgetInfo(QWidget *widget,
|
||||||
WidgetInfo::ToolBarWidgetFactoryInterface *toolBarWidgetFactory,
|
|
||||||
const QString &uniqueId,
|
const QString &uniqueId,
|
||||||
WidgetInfo::PlacementHint placementHint,
|
WidgetInfo::PlacementHint placementHint,
|
||||||
int placementPriority,
|
int placementPriority,
|
||||||
@@ -139,7 +138,6 @@ WidgetInfo AbstractView::createWidgetInfo(QWidget *widget,
|
|||||||
WidgetInfo widgetInfo;
|
WidgetInfo widgetInfo;
|
||||||
|
|
||||||
widgetInfo.widget = widget;
|
widgetInfo.widget = widget;
|
||||||
widgetInfo.toolBarWidgetFactory = toolBarWidgetFactory;
|
|
||||||
widgetInfo.uniqueId = uniqueId;
|
widgetInfo.uniqueId = uniqueId;
|
||||||
widgetInfo.placementHint = placementHint;
|
widgetInfo.placementHint = placementHint;
|
||||||
widgetInfo.placementPriority = placementPriority;
|
widgetInfo.placementPriority = placementPriority;
|
||||||
|
@@ -110,37 +110,6 @@ QList<QToolButton *> ItemLibrarySideBarItem::createToolBarWidgets()
|
|||||||
return qobject_cast<ItemLibraryWidget*>(widget())->createToolBarWidgets();
|
return qobject_cast<ItemLibraryWidget*>(widget())->createToolBarWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
class DesignerSideBarItem : public Core::SideBarItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit DesignerSideBarItem(QWidget *widget, WidgetInfo::ToolBarWidgetFactoryInterface *createToolBarWidgets, const QString &id);
|
|
||||||
~DesignerSideBarItem() override;
|
|
||||||
|
|
||||||
QList<QToolButton *> createToolBarWidgets() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
WidgetInfo::ToolBarWidgetFactoryInterface *m_toolBarWidgetFactory;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
DesignerSideBarItem::DesignerSideBarItem(QWidget *widget, WidgetInfo::ToolBarWidgetFactoryInterface *toolBarWidgetFactory, const QString &id)
|
|
||||||
: Core::SideBarItem(widget, id) , m_toolBarWidgetFactory(toolBarWidgetFactory)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DesignerSideBarItem::~DesignerSideBarItem()
|
|
||||||
{
|
|
||||||
delete m_toolBarWidgetFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QToolButton *> DesignerSideBarItem::createToolBarWidgets()
|
|
||||||
{
|
|
||||||
if (m_toolBarWidgetFactory)
|
|
||||||
return m_toolBarWidgetFactory->createToolBarWidgets();
|
|
||||||
|
|
||||||
return QList<QToolButton *>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------- DesignModeWidget
|
// ---------- DesignModeWidget
|
||||||
DesignModeWidget::DesignModeWidget()
|
DesignModeWidget::DesignModeWidget()
|
||||||
: m_toolBar(new Core::EditorToolBar(this))
|
: m_toolBar(new Core::EditorToolBar(this))
|
||||||
|
Reference in New Issue
Block a user