mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:18:52 +02:00
Fix double delete on shutdown
This commit is contained in:
parent
673de7f3e6
commit
c53c0ec53f
4 changed files with 21 additions and 22 deletions
|
@ -1027,10 +1027,7 @@ void Application::initializeUi() {
|
||||||
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
|
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {
|
||||||
QString name = inputPlugin->getName();
|
QString name = inputPlugin->getName();
|
||||||
if (name == KeyboardMouseDevice::NAME) {
|
if (name == KeyboardMouseDevice::NAME) {
|
||||||
auto kbm = static_cast<KeyboardMouseDevice*>(inputPlugin.data());
|
_keyboardMouseDevice = std::dynamic_pointer_cast<KeyboardMouseDevice>(inputPlugin);
|
||||||
// FIXME incredibly evil.... _keyboardMouseDevice is now owned by
|
|
||||||
// both a QSharedPointer and a std::shared_ptr
|
|
||||||
_keyboardMouseDevice = std::shared_ptr<KeyboardMouseDevice>(kbm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateInputModes();
|
updateInputModes();
|
||||||
|
@ -4645,7 +4642,7 @@ DisplayPlugin* Application::getActiveDisplayPlugin() {
|
||||||
updateDisplayMode();
|
updateDisplayMode();
|
||||||
Q_ASSERT(_displayPlugin);
|
Q_ASSERT(_displayPlugin);
|
||||||
}
|
}
|
||||||
return _displayPlugin.data();
|
return _displayPlugin.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DisplayPlugin* Application::getActiveDisplayPlugin() const {
|
const DisplayPlugin* Application::getActiveDisplayPlugin() const {
|
||||||
|
@ -4685,10 +4682,10 @@ void Application::updateDisplayMode() {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
foreach(auto displayPlugin, displayPlugins) {
|
foreach(auto displayPlugin, displayPlugins) {
|
||||||
addDisplayPluginToMenu(displayPlugin, first);
|
addDisplayPluginToMenu(displayPlugin, first);
|
||||||
QObject::connect(displayPlugin.data(), &DisplayPlugin::requestRender, [this] {
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, [this] {
|
||||||
paintGL();
|
paintGL();
|
||||||
});
|
});
|
||||||
QObject::connect(displayPlugin.data(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
|
QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) {
|
||||||
resizeGL();
|
resizeGL();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4814,12 +4811,14 @@ void Application::updateInputModes() {
|
||||||
foreach(auto inputPlugin, inputPlugins) {
|
foreach(auto inputPlugin, inputPlugins) {
|
||||||
QString name = inputPlugin->getName();
|
QString name = inputPlugin->getName();
|
||||||
QAction* action = menu->getActionForOption(name);
|
QAction* action = menu->getActionForOption(name);
|
||||||
if (action->isChecked() && !_activeInputPlugins.contains(inputPlugin)) {
|
|
||||||
_activeInputPlugins.append(inputPlugin);
|
auto it = std::find(std::begin(_activeInputPlugins), std::end(_activeInputPlugins), inputPlugin);
|
||||||
newInputPlugins.append(inputPlugin);
|
if (action->isChecked() && it == std::end(_activeInputPlugins)) {
|
||||||
} else if (!action->isChecked() && _activeInputPlugins.contains(inputPlugin)) {
|
_activeInputPlugins.push_back(inputPlugin);
|
||||||
_activeInputPlugins.removeOne(inputPlugin);
|
newInputPlugins.push_back(inputPlugin);
|
||||||
removedInputPlugins.append(inputPlugin);
|
} else if (!action->isChecked() && it != std::end(_activeInputPlugins)) {
|
||||||
|
_activeInputPlugins.erase(it);
|
||||||
|
removedInputPlugins.push_back(inputPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QList>
|
#include <vector>
|
||||||
#include <QVector>
|
#include <memory>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
class DisplayPlugin;
|
class DisplayPlugin;
|
||||||
class InputPlugin;
|
class InputPlugin;
|
||||||
|
@ -17,8 +16,8 @@ class Plugin;
|
||||||
class PluginContainer;
|
class PluginContainer;
|
||||||
class PluginManager;
|
class PluginManager;
|
||||||
|
|
||||||
using DisplayPluginPointer = QSharedPointer<DisplayPlugin>;
|
using DisplayPluginPointer = std::shared_ptr<DisplayPlugin>;
|
||||||
using DisplayPluginList = QVector<DisplayPluginPointer>;
|
using DisplayPluginList = std::vector<DisplayPluginPointer>;
|
||||||
using InputPluginPointer = QSharedPointer<InputPlugin>;
|
using InputPluginPointer = std::shared_ptr<InputPlugin>;
|
||||||
using InputPluginList = QVector<InputPluginPointer>;
|
using InputPluginList = std::vector<InputPluginPointer>;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include "Forward.h"
|
#include "Forward.h"
|
||||||
|
|
||||||
class PluginManager : public QObject {
|
class PluginManager : public QObject {
|
||||||
|
|
|
@ -132,8 +132,7 @@ int main(int argc, char** argv) {
|
||||||
inputPlugin->activate();
|
inputPlugin->activate();
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
if (name == KeyboardMouseDevice::NAME) {
|
if (name == KeyboardMouseDevice::NAME) {
|
||||||
auto keyboardMouseDevice = static_cast<KeyboardMouseDevice*>(inputPlugin.data()); // TODO: this seems super hacky
|
userInputMapper->registerDevice(std::dynamic_pointer_cast<KeyboardMouseDevice>(inputPlugin));
|
||||||
userInputMapper->registerDevice(std::shared_ptr<InputDevice>(keyboardMouseDevice));
|
|
||||||
}
|
}
|
||||||
inputPlugin->pluginUpdate(0, false);
|
inputPlugin->pluginUpdate(0, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue