Moved global vector inside PythonBindings
Signed-off-by: AMZN-Phil <pconroy@amazon.com>
This commit is contained in:
@@ -62,7 +62,6 @@ namespace Platform
|
||||
namespace RedirectOutput
|
||||
{
|
||||
using RedirectOutputFunc = AZStd::function<void(const char*)>;
|
||||
AZStd::vector<AZStd::string> pythonErrorStrings;
|
||||
|
||||
struct RedirectOutput
|
||||
{
|
||||
@@ -220,7 +219,7 @@ namespace RedirectOutput
|
||||
{
|
||||
lastPythonError.erase(errorPrefix, lengthOfErrorPrefix);
|
||||
}
|
||||
pythonErrorStrings.push_back(lastPythonError);
|
||||
O3DE::ProjectManager::PythonBindingsInterface::Get()->AddErrorString(lastPythonError);
|
||||
|
||||
AZ_TracePrintf("Python", msg);
|
||||
});
|
||||
@@ -388,7 +387,7 @@ namespace O3DE::ProjectManager
|
||||
pybind11::gil_scoped_release release;
|
||||
pybind11::gil_scoped_acquire acquire;
|
||||
|
||||
RedirectOutput::pythonErrorStrings.clear();
|
||||
ClearErrorStrings();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1325,9 +1324,20 @@ namespace O3DE::ProjectManager
|
||||
|
||||
AZStd::pair<AZStd::string, AZStd::string> PythonBindings::GetSimpleDetailedErrorPair()
|
||||
{
|
||||
AZStd::string detailedString = RedirectOutput::pythonErrorStrings.size() == 1 ? "" : AZStd::accumulate(
|
||||
RedirectOutput::pythonErrorStrings.begin(), RedirectOutput::pythonErrorStrings.end(), AZStd::string(""));
|
||||
AZStd::string detailedString = m_pythonErrorStrings.size() == 1
|
||||
? ""
|
||||
: AZStd::accumulate(m_pythonErrorStrings.begin(), m_pythonErrorStrings.end(), AZStd::string(""));
|
||||
|
||||
return AZStd::pair<AZStd::string, AZStd::string>(RedirectOutput::pythonErrorStrings.front(), detailedString);
|
||||
return AZStd::pair<AZStd::string, AZStd::string>(m_pythonErrorStrings.front(), detailedString);
|
||||
}
|
||||
|
||||
void PythonBindings::AddErrorString(AZStd::string errorString)
|
||||
{
|
||||
m_pythonErrorStrings.push_back(errorString);
|
||||
}
|
||||
|
||||
void PythonBindings::ClearErrorStrings()
|
||||
{
|
||||
m_pythonErrorStrings.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace O3DE::ProjectManager
|
||||
void CancelDownload() override;
|
||||
bool IsGemUpdateAvaliable(const QString& gemName, const QString& lastUpdated) override;
|
||||
|
||||
void AddErrorString(AZStd::string errorString) override;
|
||||
void ClearErrorStrings() override;
|
||||
|
||||
private:
|
||||
AZ_DISABLE_COPY_MOVE(PythonBindings);
|
||||
|
||||
@@ -104,5 +107,6 @@ namespace O3DE::ProjectManager
|
||||
pybind11::handle m_pathlib;
|
||||
|
||||
bool m_requestCancelDownload = false;
|
||||
AZStd::vector<AZStd::string> m_pythonErrorStrings;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -252,6 +252,17 @@ namespace O3DE::ProjectManager
|
||||
* @return true if update is avaliable, false if not.
|
||||
*/
|
||||
virtual bool IsGemUpdateAvaliable(const QString& gemName, const QString& lastUpdated) = 0;
|
||||
|
||||
/**
|
||||
* Add an error string to be returned when the current python call is complete.
|
||||
* @param The error string to be displayed.
|
||||
*/
|
||||
virtual void AddErrorString(AZStd::string errorString) = 0;
|
||||
|
||||
/**
|
||||
* Clears the current list of error strings.
|
||||
*/
|
||||
virtual void ClearErrorStrings() = 0;
|
||||
};
|
||||
|
||||
using PythonBindingsInterface = AZ::Interface<IPythonBindings>;
|
||||
|
||||
Reference in New Issue
Block a user