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:
AppOutputSettingsWidget()
{
const AppOutputSettings &settings = ProjectExplorerPlugin::appOutputSettings();
const AppOutputSettings &settings = appOutputPane().settings();
m_wrapOutputCheckBox.setText(Tr::tr("Word-wrap output"));
m_wrapOutputCheckBox.setChecked(settings.wrapOutput);
m_cleanOldOutputCheckBox.setText(Tr::tr("Clear old output on a new run"));
@@ -909,7 +909,7 @@ public:
m_debugOutputModeComboBox.currentData().toInt());
s.maxCharCount = m_maxCharsBox.value();
ProjectExplorerPlugin::setAppOutputSettings(s);
appOutputPane().setSettings(s);
}
private:
@@ -929,8 +929,27 @@ AppOutputSettingsPage::AppOutputSettingsPage()
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 ProjectExplorer
#include "appoutputpane.moc"

View File

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

View File

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

View File

@@ -33,7 +33,6 @@ class RunControl;
class RunConfiguration;
namespace Internal {
class AppOutputSettings;
class MiniProjectTargetSelector;
}
@@ -116,9 +115,6 @@ public:
bool delayedInitialize() 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 addCustomParser(const CustomParserSettings &settings);
static void removeCustomParser(Utils::Id id);

View File

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