Merge pull request #3124 from aws-lumberyard-dev/Atom/guthadam/ATOM-16242_fix_python_terminal_help_crash
AtomTools: Fix python terminal help crash ATOM-16242
This commit is contained in:
+40
-1
@@ -6,7 +6,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Description : For listing available script commands with their descriptions
|
||||
|
||||
#include "ScriptHelpDialog.h"
|
||||
@@ -23,6 +22,7 @@
|
||||
|
||||
// AzToolsFramework
|
||||
#include <AzToolsFramework/API/EditorPythonConsoleBus.h> // for EditorPythonConsoleInterface
|
||||
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
|
||||
|
||||
AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
|
||||
#include <AzToolsFramework/PythonTerminal/ui_ScriptHelpDialog.h>
|
||||
@@ -313,6 +313,45 @@ namespace AzToolsFramework
|
||||
connect(ui->tableView, &ScriptTableView::doubleClicked, this, &CScriptHelpDialog::OnDoubleClick);
|
||||
}
|
||||
|
||||
CScriptHelpDialog* CScriptHelpDialog::GetInstance()
|
||||
{
|
||||
static CScriptHelpDialog* pInstance = nullptr;
|
||||
if (!pInstance)
|
||||
{
|
||||
QMainWindow* mainWindow = GetMainWindowOfCurrentApplication();
|
||||
if (!mainWindow)
|
||||
{
|
||||
AZ_Assert(false, "Failed to find MainWindow.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget* parentWidget = mainWindow->window()
|
||||
? mainWindow->window()
|
||||
: mainWindow; // MainWindow might have a WindowDecorationWrapper parent. Makes a difference on macOS.
|
||||
pInstance = new CScriptHelpDialog(parentWidget);
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
QMainWindow* CScriptHelpDialog::GetMainWindowOfCurrentApplication()
|
||||
{
|
||||
QWidget* mainWindowWidget = nullptr;
|
||||
EditorWindowRequestBus::BroadcastResult(mainWindowWidget, &EditorWindowRequests::GetAppMainWindow);
|
||||
if (QMainWindow* mainWindow = qobject_cast<QMainWindow*>(mainWindowWidget))
|
||||
{
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
for (QWidget* topLevelWidget : qApp->topLevelWidgets())
|
||||
{
|
||||
if (QMainWindow* mainWindow = qobject_cast<QMainWindow*>(topLevelWidget))
|
||||
{
|
||||
return mainWindow;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CScriptHelpDialog::OnDoubleClick(const QModelIndex& index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
|
||||
@@ -132,43 +132,13 @@ namespace AzToolsFramework
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static CScriptHelpDialog* GetInstance()
|
||||
{
|
||||
static CScriptHelpDialog* pInstance = nullptr;
|
||||
if (!pInstance)
|
||||
{
|
||||
QMainWindow* mainWindow = GetMainWindowOfCurrentApplication();
|
||||
if (!mainWindow)
|
||||
{
|
||||
AZ_Assert(false, "Failed to find MainWindow.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget* parentWidget = mainWindow->window() ? mainWindow->window() : mainWindow; // MainWindow might have a WindowDecorationWrapper parent. Makes a difference on macOS.
|
||||
pInstance = new CScriptHelpDialog(parentWidget);
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
static CScriptHelpDialog* GetInstance();
|
||||
private Q_SLOTS:
|
||||
void OnDoubleClick(const QModelIndex&);
|
||||
|
||||
private:
|
||||
static QMainWindow* GetMainWindowOfCurrentApplication()
|
||||
{
|
||||
QMainWindow* mainWindow = nullptr;
|
||||
for (QWidget* w : qApp->topLevelWidgets())
|
||||
{
|
||||
mainWindow = qobject_cast<QMainWindow*>(w);
|
||||
if (mainWindow)
|
||||
{
|
||||
return mainWindow;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
explicit CScriptHelpDialog(QWidget* parent = nullptr);
|
||||
static QMainWindow* GetMainWindowOfCurrentApplication();
|
||||
QScopedPointer<Ui::ScriptDialog> ui;
|
||||
};
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
Reference in New Issue
Block a user