mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
Merge pull request #1995 from ZappoMan/scriptfixes
Fix crash on shutdown with multiple scripts and other scripting improvements
This commit is contained in:
commit
04cda4c2b6
6 changed files with 46 additions and 4 deletions
|
@ -3984,6 +3984,32 @@ void Application::saveScripts() {
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::stopAllScripts() {
|
||||||
|
// stops all current running scripts
|
||||||
|
QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();
|
||||||
|
foreach (QAction* scriptAction, scriptActions) {
|
||||||
|
scriptAction->activate(QAction::Trigger);
|
||||||
|
qDebug() << "stopping script..." << scriptAction->text();
|
||||||
|
}
|
||||||
|
_activeScripts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::reloadAllScripts() {
|
||||||
|
// remember all the current scripts so we can reload them
|
||||||
|
QStringList reloadList = _activeScripts;
|
||||||
|
// reloads all current running scripts
|
||||||
|
QList<QAction*> scriptActions = Menu::getInstance()->getActiveScriptsMenu()->actions();
|
||||||
|
foreach (QAction* scriptAction, scriptActions) {
|
||||||
|
scriptAction->activate(QAction::Trigger);
|
||||||
|
qDebug() << "stopping script..." << scriptAction->text();
|
||||||
|
}
|
||||||
|
_activeScripts.clear();
|
||||||
|
foreach (QString scriptName, reloadList){
|
||||||
|
qDebug() << "reloading script..." << scriptName;
|
||||||
|
loadScript(scriptName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::removeScriptName(const QString& fileNameString) {
|
void Application::removeScriptName(const QString& fileNameString) {
|
||||||
_activeScripts.removeOne(fileNameString);
|
_activeScripts.removeOne(fileNameString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,8 @@ public slots:
|
||||||
void loadDialog();
|
void loadDialog();
|
||||||
void toggleLogDialog();
|
void toggleLogDialog();
|
||||||
void initAvatarAndViewFrustum();
|
void initAvatarAndViewFrustum();
|
||||||
|
void stopAllScripts();
|
||||||
|
void reloadAllScripts();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void timer();
|
void timer();
|
||||||
|
|
|
@ -93,6 +93,8 @@ Menu::Menu() :
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Scripts");
|
addDisabledActionAndSeparator(fileMenu, "Scripts");
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, appInstance, SLOT(loadDialog()));
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::LoadScript, Qt::CTRL | Qt::Key_O, appInstance, SLOT(loadDialog()));
|
||||||
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::StopAllScripts, 0, appInstance, SLOT(stopAllScripts()));
|
||||||
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::ReloadAllScripts, 0, appInstance, SLOT(reloadAllScripts()));
|
||||||
_activeScriptsMenu = fileMenu->addMenu("Running Scripts");
|
_activeScriptsMenu = fileMenu->addMenu("Running Scripts");
|
||||||
|
|
||||||
addDisabledActionAndSeparator(fileMenu, "Voxels");
|
addDisabledActionAndSeparator(fileMenu, "Voxels");
|
||||||
|
|
|
@ -243,8 +243,10 @@ namespace MenuOption {
|
||||||
const QString PasteVoxels = "Paste";
|
const QString PasteVoxels = "Paste";
|
||||||
const QString PasteToVoxel = "Paste to Voxel...";
|
const QString PasteToVoxel = "Paste to Voxel...";
|
||||||
const QString PipelineWarnings = "Show Render Pipeline Warnings";
|
const QString PipelineWarnings = "Show Render Pipeline Warnings";
|
||||||
|
const QString PlaySlaps = "Play Slaps";
|
||||||
const QString Preferences = "Preferences...";
|
const QString Preferences = "Preferences...";
|
||||||
const QString RandomizeVoxelColors = "Randomize Voxel TRUE Colors";
|
const QString RandomizeVoxelColors = "Randomize Voxel TRUE Colors";
|
||||||
|
const QString ReloadAllScripts = "Reload All Scripts";
|
||||||
const QString ResetAvatarSize = "Reset Avatar Size";
|
const QString ResetAvatarSize = "Reset Avatar Size";
|
||||||
const QString ResetSwatchColors = "Reset Swatch Colors";
|
const QString ResetSwatchColors = "Reset Swatch Colors";
|
||||||
const QString RunTimingTests = "Run Timing Tests";
|
const QString RunTimingTests = "Run Timing Tests";
|
||||||
|
@ -253,11 +255,10 @@ namespace MenuOption {
|
||||||
const QString SettingsExport = "Export Settings";
|
const QString SettingsExport = "Export Settings";
|
||||||
const QString ShowAllLocalVoxels = "Show All Local Voxels";
|
const QString ShowAllLocalVoxels = "Show All Local Voxels";
|
||||||
const QString ShowTrueColors = "Show TRUE Colors";
|
const QString ShowTrueColors = "Show TRUE Colors";
|
||||||
const QString VoxelDrumming = "Voxel Drumming";
|
|
||||||
const QString PlaySlaps = "Play Slaps";
|
|
||||||
const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
|
const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
|
||||||
const QString Stars = "Stars";
|
const QString Stars = "Stars";
|
||||||
const QString Stats = "Stats";
|
const QString Stats = "Stats";
|
||||||
|
const QString StopAllScripts = "Stop All Scripts";
|
||||||
const QString TestPing = "Test Ping";
|
const QString TestPing = "Test Ping";
|
||||||
const QString TreeStats = "Calculate Tree Stats";
|
const QString TreeStats = "Calculate Tree Stats";
|
||||||
const QString TransmitterDrive = "Transmitter Drive";
|
const QString TransmitterDrive = "Transmitter Drive";
|
||||||
|
@ -268,6 +269,7 @@ namespace MenuOption {
|
||||||
const QString VoxelAddMode = "Add Voxel Mode";
|
const QString VoxelAddMode = "Add Voxel Mode";
|
||||||
const QString VoxelColorMode = "Color Voxel Mode";
|
const QString VoxelColorMode = "Color Voxel Mode";
|
||||||
const QString VoxelDeleteMode = "Delete Voxel Mode";
|
const QString VoxelDeleteMode = "Delete Voxel Mode";
|
||||||
|
const QString VoxelDrumming = "Voxel Drumming";
|
||||||
const QString VoxelGetColorMode = "Get Color Mode";
|
const QString VoxelGetColorMode = "Get Color Mode";
|
||||||
const QString VoxelMode = "Cycle Voxel Mode";
|
const QString VoxelMode = "Cycle Voxel Mode";
|
||||||
const QString VoxelPaintColor = "Voxel Paint Color";
|
const QString VoxelPaintColor = "Voxel Paint Color";
|
||||||
|
|
|
@ -11,13 +11,19 @@
|
||||||
#include "OctreeScriptingInterface.h"
|
#include "OctreeScriptingInterface.h"
|
||||||
|
|
||||||
OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packetSender,
|
OctreeScriptingInterface::OctreeScriptingInterface(OctreeEditPacketSender* packetSender,
|
||||||
JurisdictionListener* jurisdictionListener)
|
JurisdictionListener* jurisdictionListener) :
|
||||||
|
_packetSender(NULL),
|
||||||
|
_jurisdictionListener(NULL),
|
||||||
|
_managedPacketSender(false),
|
||||||
|
_managedJurisdictionListener(false),
|
||||||
|
_initialized(false)
|
||||||
{
|
{
|
||||||
setPacketSender(packetSender);
|
setPacketSender(packetSender);
|
||||||
setJurisdictionListener(jurisdictionListener);
|
setJurisdictionListener(jurisdictionListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
OctreeScriptingInterface::~OctreeScriptingInterface() {
|
OctreeScriptingInterface::~OctreeScriptingInterface() {
|
||||||
|
qDebug() << "OctreeScriptingInterface::~OctreeScriptingInterface() this=" << this;
|
||||||
cleanupManagedObjects();
|
cleanupManagedObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +51,9 @@ void OctreeScriptingInterface::setJurisdictionListener(JurisdictionListener* jur
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeScriptingInterface::init() {
|
void OctreeScriptingInterface::init() {
|
||||||
|
if (_initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_jurisdictionListener) {
|
if (_jurisdictionListener) {
|
||||||
_managedJurisdictionListener = false;
|
_managedJurisdictionListener = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,5 +73,5 @@ void OctreeScriptingInterface::init() {
|
||||||
if (QCoreApplication::instance()) {
|
if (QCoreApplication::instance()) {
|
||||||
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(cleanupManagedObjects()));
|
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(cleanupManagedObjects()));
|
||||||
}
|
}
|
||||||
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ protected:
|
||||||
JurisdictionListener* _jurisdictionListener;
|
JurisdictionListener* _jurisdictionListener;
|
||||||
bool _managedPacketSender;
|
bool _managedPacketSender;
|
||||||
bool _managedJurisdictionListener;
|
bool _managedJurisdictionListener;
|
||||||
|
bool _initialized;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__OctreeScriptingInterface__) */
|
#endif /* defined(__hifi__OctreeScriptingInterface__) */
|
||||||
|
|
Loading…
Reference in a new issue