ProjectExplorer: Remove indirections when accessing AppOutputPane

This intentionally keeps the lifetime (almost) identical.

Change-Id: Ic420d8c5f89eaad33e38160bb8ee26965830047f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2024-07-31 14:13:10 +02:00
parent 714cedf945
commit 255e63bebb
5 changed files with 39 additions and 28 deletions

View File

@@ -857,7 +857,7 @@ class AppOutputSettingsWidget : public Core::IOptionsPageWidget
public: public:
AppOutputSettingsWidget() AppOutputSettingsWidget()
{ {
const AppOutputSettings &settings = ProjectExplorerPlugin::appOutputSettings(); const AppOutputSettings &settings = appOutputPane().settings();
m_wrapOutputCheckBox.setText(Tr::tr("Word-wrap output")); m_wrapOutputCheckBox.setText(Tr::tr("Word-wrap output"));
m_wrapOutputCheckBox.setChecked(settings.wrapOutput); m_wrapOutputCheckBox.setChecked(settings.wrapOutput);
m_cleanOldOutputCheckBox.setText(Tr::tr("Clear old output on a new run")); m_cleanOldOutputCheckBox.setText(Tr::tr("Clear old output on a new run"));
@@ -909,7 +909,7 @@ public:
m_debugOutputModeComboBox.currentData().toInt()); m_debugOutputModeComboBox.currentData().toInt());
s.maxCharCount = m_maxCharsBox.value(); s.maxCharCount = m_maxCharsBox.value();
ProjectExplorerPlugin::setAppOutputSettings(s); appOutputPane().setSettings(s);
} }
private: private:
@@ -929,8 +929,27 @@ AppOutputSettingsPage::AppOutputSettingsPage()
setWidgetCreator([] { return new AppOutputSettingsWidget; }); setWidgetCreator([] { return new AppOutputSettingsWidget; });
} }
static QPointer<AppOutputPane> theAppOutputPane;
AppOutputPane &appOutputPane()
{
QTC_CHECK(!theAppOutputPane.isNull());
return *theAppOutputPane;
}
void setupAppOutputPane()
{
QTC_CHECK(theAppOutputPane.isNull());
theAppOutputPane = new AppOutputPane;
}
void destroyAppOutputPane()
{
QTC_CHECK(!theAppOutputPane.isNull());
delete theAppOutputPane;
}
} // namespace Internal } // namespace Internal
} // namespace ProjectExplorer } // namespace ProjectExplorer
#include "appoutputpane.moc" #include "appoutputpane.moc"

View File

@@ -157,5 +157,10 @@ public:
AppOutputSettingsPage(); AppOutputSettingsPage();
}; };
AppOutputPane &appOutputPane();
void setupAppOutputPane();
void destroyAppOutputPane();
} // namespace Internal } // namespace Internal
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -460,7 +460,7 @@ public:
class ProjectExplorerPluginPrivate : public QObject class ProjectExplorerPluginPrivate : public QObject
{ {
public: public:
ProjectExplorerPluginPrivate(); ProjectExplorerPluginPrivate() = default;
void updateContextMenuActions(Node *currentNode); void updateContextMenuActions(Node *currentNode);
void updateLocationSubMenus(); void updateLocationSubMenus();
@@ -664,8 +664,6 @@ public:
ConfigTaskHandler m_configTaskHandler{Task::compilerMissingTask(), Constants::KITS_SETTINGS_PAGE_ID}; ConfigTaskHandler m_configTaskHandler{Task::compilerMissingTask(), Constants::KITS_SETTINGS_PAGE_ID};
ProjectManager m_sessionManager; ProjectManager m_sessionManager;
AppOutputPane m_outputPane;
ProjectTree m_projectTree; ProjectTree m_projectTree;
AllProjectsFilter m_allProjectsFilter; AllProjectsFilter m_allProjectsFilter;
@@ -770,6 +768,9 @@ ProjectExplorerPlugin::~ProjectExplorerPlugin()
delete dd->m_toolChainManager; delete dd->m_toolChainManager;
delete dd; delete dd;
dd = nullptr; dd = nullptr;
destroyAppOutputPane();
m_instance = nullptr; m_instance = nullptr;
#ifdef WITH_TESTS #ifdef WITH_TESTS
@@ -821,6 +822,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
dd = new ProjectExplorerPluginPrivate; dd = new ProjectExplorerPluginPrivate;
setupAppOutputPane();
setupDesktopRunConfigurations(); setupDesktopRunConfigurations();
setupDesktopRunWorker(); setupDesktopRunWorker();
@@ -2155,7 +2158,7 @@ IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
if (dd->m_activeRunControlCount == 0) if (dd->m_activeRunControlCount == 0)
return SynchronousShutdown; return SynchronousShutdown;
dd->m_outputPane.closeTabsWithoutPrompt(); appOutputPane().closeTabsWithoutPrompt();
dd->m_shutdownWatchDogId = dd->startTimer(10 * 1000); // Make sure we shutdown *somehow* dd->m_shutdownWatchDogId = dd->startTimer(10 * 1000); // Make sure we shutdown *somehow*
return AsynchronousShutdown; return AsynchronousShutdown;
} }
@@ -2459,7 +2462,7 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl)
void ProjectExplorerPlugin::showOutputPaneForRunControl(RunControl *runControl) void ProjectExplorerPlugin::showOutputPaneForRunControl(RunControl *runControl)
{ {
dd->m_outputPane.showOutputPaneForRunControl(runControl); appOutputPane().showOutputPaneForRunControl(runControl);
} }
QList<std::pair<FilePath, FilePath>> ProjectExplorerPlugin::renameFiles( QList<std::pair<FilePath, FilePath>> ProjectExplorerPlugin::renameFiles(
@@ -2494,7 +2497,7 @@ bool ProjectExplorerPlugin::renameFile(const Utils::FilePath &source, const Util
void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl) void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl)
{ {
m_outputPane.prepareRunControlStart(runControl); appOutputPane().prepareRunControlStart(runControl);
connect(runControl, &QObject::destroyed, this, &ProjectExplorerPluginPrivate::checkForShutdown, connect(runControl, &QObject::destroyed, this, &ProjectExplorerPluginPrivate::checkForShutdown,
Qt::QueuedConnection); Qt::QueuedConnection);
++m_activeRunControlCount; ++m_activeRunControlCount;
@@ -2714,8 +2717,6 @@ bool ProjectExplorerPlugin::saveModifiedFiles()
return true; return true;
} }
ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() {}
void ProjectExplorerPluginPrivate::extendFolderNavigationWidgetFactory() void ProjectExplorerPluginPrivate::extendFolderNavigationWidgetFactory()
{ {
auto folderNavigationWidgetFactory = FolderNavigationWidgetFactory::instance(); auto folderNavigationWidgetFactory = FolderNavigationWidgetFactory::instance();
@@ -2905,7 +2906,7 @@ bool ProjectExplorerPlugin::coreAboutToClose()
if (box.clickedButton() != closeAnyway) if (box.clickedButton() != closeAnyway)
return false; return false;
} }
return dd->m_outputPane.aboutToClose(); return appOutputPane().aboutToClose();
} }
void ProjectExplorerPlugin::handleCommandLineArguments(const QStringList &arguments) void ProjectExplorerPlugin::handleCommandLineArguments(const QStringList &arguments)
@@ -2991,7 +2992,7 @@ void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc,
QList<RunControl *> ProjectExplorerPlugin::allRunControls() QList<RunControl *> ProjectExplorerPlugin::allRunControls()
{ {
return dd->m_outputPane.allRunControls(); return appOutputPane().allRunControls();
} }
void ProjectExplorerPluginPrivate::projectAdded(Project *pro) void ProjectExplorerPluginPrivate::projectAdded(Project *pro)
@@ -3997,16 +3998,6 @@ void ProjectExplorerPluginPrivate::handleSetStartupProject()
setStartupProject(ProjectTree::currentProject()); setStartupProject(ProjectTree::currentProject());
} }
void ProjectExplorerPlugin::setAppOutputSettings(const AppOutputSettings &settings)
{
dd->m_outputPane.setSettings(settings);
}
const AppOutputSettings &ProjectExplorerPlugin::appOutputSettings()
{
return dd->m_outputPane.settings();
}
void ProjectExplorerPlugin::setCustomParsers(const QList<CustomParserSettings> &settings) void ProjectExplorerPlugin::setCustomParsers(const QList<CustomParserSettings> &settings)
{ {
if (dd->m_customParsers != settings) { if (dd->m_customParsers != settings) {

View File

@@ -33,7 +33,6 @@ class RunControl;
class RunConfiguration; class RunConfiguration;
namespace Internal { namespace Internal {
class AppOutputSettings;
class MiniProjectTargetSelector; class MiniProjectTargetSelector;
} }
@@ -116,9 +115,6 @@ public:
bool delayedInitialize() override; bool delayedInitialize() override;
ShutdownFlag aboutToShutdown() override; ShutdownFlag aboutToShutdown() override;
static void setAppOutputSettings(const Internal::AppOutputSettings &settings);
static const Internal::AppOutputSettings &appOutputSettings();
static void setCustomParsers(const QList<CustomParserSettings> &settings); static void setCustomParsers(const QList<CustomParserSettings> &settings);
static void addCustomParser(const CustomParserSettings &settings); static void addCustomParser(const CustomParserSettings &settings);
static void removeCustomParser(Utils::Id id); static void removeCustomParser(Utils::Id id);

View File

@@ -1281,7 +1281,7 @@ public:
static QProcess::ProcessChannelMode defaultProcessChannelMode() static QProcess::ProcessChannelMode defaultProcessChannelMode()
{ {
return ProjectExplorerPlugin::appOutputSettings().mergeChannels return appOutputPane().settings().mergeChannels
? QProcess::MergedChannels : QProcess::SeparateChannels; ? QProcess::MergedChannels : QProcess::SeparateChannels;
} }