forked from qt-creator/qt-creator
EnvironmentWidget: Devirtualize aspect() method
The RemoteLinuxEnvironmentAspectWidget subclass was overloading it, however, it was returning the subclass of EnvironmentAspect (i.e. returning RemoteLinuxEnvironmentAspect). Instead, we use the base aspect() method in RemoteLinuxEnvironmentAspectWidget subclass and we cast it into expected RemoteLinuxEnvironmentAspect class. Move some methods into protected section, as they are used only in subclass. Use qobject_cast instead of dynamic_cast inside UploadAndInstallTarPackageStep. Change-Id: Ic3119ca15d46187e0aa7b8b4013e7fc4efec4bd9 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -92,11 +92,6 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid
|
|||||||
this, &EnvironmentAspectWidget::environmentChanged);
|
this, &EnvironmentAspectWidget::environmentChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvironmentAspect *EnvironmentAspectWidget::aspect() const
|
|
||||||
{
|
|
||||||
return m_aspect;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *EnvironmentAspectWidget::additionalWidget() const
|
QWidget *EnvironmentAspectWidget::additionalWidget() const
|
||||||
{
|
{
|
||||||
return m_additionalWidget;
|
return m_additionalWidget;
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr);
|
explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr);
|
||||||
|
|
||||||
virtual EnvironmentAspect *aspect() const;
|
protected:
|
||||||
|
EnvironmentAspect *aspect() const { return m_aspect; }
|
||||||
EnvironmentWidget *envWidget() const { return m_environmentWidget; }
|
EnvironmentWidget *envWidget() const { return m_environmentWidget; }
|
||||||
|
|
||||||
QWidget *additionalWidget() const;
|
QWidget *additionalWidget() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ const QString FetchEnvButtonText
|
|||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
|
|
||||||
RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget
|
RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget
|
||||||
(RemoteLinuxEnvironmentAspect *aspect, Target *target) :
|
(RemoteLinuxEnvironmentAspect *aspect, Target *target)
|
||||||
EnvironmentAspectWidget(aspect, new QPushButton)
|
: EnvironmentAspectWidget(aspect, new QPushButton)
|
||||||
{
|
{
|
||||||
IDevice::ConstPtr device = DeviceKitAspect::device(target->kit());
|
IDevice::ConstPtr device = DeviceKitAspect::device(target->kit());
|
||||||
|
|
||||||
@@ -85,11 +85,6 @@ RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget
|
|||||||
envWidget()->setOpenTerminalFunc(openTerminalFunc);
|
envWidget()->setOpenTerminalFunc(openTerminalFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteLinuxEnvironmentAspect *RemoteLinuxEnvironmentAspectWidget::aspect() const
|
|
||||||
{
|
|
||||||
return dynamic_cast<RemoteLinuxEnvironmentAspect *>(EnvironmentAspectWidget::aspect());
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton *RemoteLinuxEnvironmentAspectWidget::fetchButton() const
|
QPushButton *RemoteLinuxEnvironmentAspectWidget::fetchButton() const
|
||||||
{
|
{
|
||||||
return qobject_cast<QPushButton *>(additionalWidget());
|
return qobject_cast<QPushButton *>(additionalWidget());
|
||||||
@@ -114,7 +109,8 @@ void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished()
|
|||||||
connect(button, &QPushButton::clicked,
|
connect(button, &QPushButton::clicked,
|
||||||
this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment);
|
this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment);
|
||||||
button->setText(FetchEnvButtonText);
|
button->setText(FetchEnvButtonText);
|
||||||
aspect()->setRemoteEnvironment(deviceEnvReader->remoteEnvironment());
|
qobject_cast<RemoteLinuxEnvironmentAspect *>(aspect())->setRemoteEnvironment(
|
||||||
|
deviceEnvReader->remoteEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError(const QString &error)
|
void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError(const QString &error)
|
||||||
|
|||||||
@@ -43,10 +43,9 @@ public:
|
|||||||
RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect,
|
RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect,
|
||||||
ProjectExplorer::Target *target);
|
ProjectExplorer::Target *target);
|
||||||
|
|
||||||
RemoteLinuxEnvironmentAspect *aspect() const override;
|
private:
|
||||||
QPushButton *fetchButton() const;
|
QPushButton *fetchButton() const;
|
||||||
|
|
||||||
private:
|
|
||||||
void fetchEnvironment();
|
void fetchEnvironment();
|
||||||
void fetchEnvironmentFinished();
|
void fetchEnvironmentFinished();
|
||||||
void fetchEnvironmentError(const QString &error);
|
void fetchEnvironmentError(const QString &error);
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bs
|
|||||||
for (BuildStep *step : deployConfiguration()->stepList()->steps()) {
|
for (BuildStep *step : deployConfiguration()->stepList()->steps()) {
|
||||||
if (step == this)
|
if (step == this)
|
||||||
break;
|
break;
|
||||||
if ((pStep = dynamic_cast<TarPackageCreationStep *>(step)))
|
if ((pStep = qobject_cast<TarPackageCreationStep *>(step)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!pStep)
|
if (!pStep)
|
||||||
|
|||||||
Reference in New Issue
Block a user