Files
o3de/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/main.cpp
T
Guthrie Adams 4b3ce6738f AtomTools: fix multiple material editor processes launching
Atom tools launch or check for the existence of a local server in order to prevent multiple application processes from running. These checks were being done far too late, after initialization and asset processing, leaving time for multiple processes to start before the server or checks. Zombie processes could start and run indefinitely without user interaction because the event loop was being entered despite the request to exit the application early.

These changes launch the server and checks immediately after the application object is constructed and exit before any other work is done if the application will not be run.

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
2021-08-18 17:41:15 -05:00

52 lines
1.7 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzQtComponents/Components/GlobalEventFilter.h>
#include <AzQtComponents/Components/StyledDockWidget.h>
#include <AzQtComponents/Components/O3DEStylesheet.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzQtComponents/Utilities/HandleDpiAwareness.h>
#include <AzQtComponents/Components/WindowDecorationWrapper.h>
#include <AzQtComponents/Application/AzQtApplication.h>
#include <QtWidgets/QApplication>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <Source/ShaderManagementConsoleApplication.h>
int main(int argc, char** argv)
{
AzQtComponents::AzQtApplication::InitializeDpiScaling();
ShaderManagementConsole::ShaderManagementConsoleApplication app(&argc, &argv);
if (!app.LaunchLocalServer())
{
return 0;
}
app.installEventFilter(new AzQtComponents::GlobalEventFilter(&app));
AZ::IO::FixedMaxPath engineRootPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
AzQtComponents::StyleManager styleManager(&app);
styleManager.initialize(&app, engineRootPath);
app.Start(AZ::ComponentApplication::Descriptor{});
app.exec();
app.Stop();
return 0;
}