mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:41:10 +02:00
Merge pull request #7379 from sethalves/fix-crashes-0
possibly fix a couple of crashes
This commit is contained in:
commit
d5bf65cc8f
3 changed files with 33 additions and 24 deletions
|
@ -212,7 +212,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
|
||||||
properties.setAccelerationChanged(false);
|
properties.setAccelerationChanged(false);
|
||||||
|
|
||||||
if (wantTerseEditLogging()) {
|
if (wantTerseEditLogging()) {
|
||||||
qCDebug(entities) << senderNode->getUUID() << "physical edits suppressed";
|
qCDebug(entities) << (senderNode ? senderNode->getUUID() : "null") << "physical edits suppressed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "SettingInterface.h"
|
#include "SettingInterface.h"
|
||||||
|
@ -25,23 +26,27 @@ namespace Setting {
|
||||||
|
|
||||||
// sync will be called in the QSettings destructor
|
// sync will be called in the QSettings destructor
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::registerHandle(Setting::Interface* handle) {
|
void Manager::registerHandle(Setting::Interface* handle) {
|
||||||
QString key = handle->getKey();
|
QString key = handle->getKey();
|
||||||
if (_handles.contains(key)) {
|
withWriteLock([&] {
|
||||||
qWarning() << "Setting::Manager::registerHandle(): Key registered more than once, overriding: " << key;
|
if (_handles.contains(key)) {
|
||||||
}
|
qWarning() << "Setting::Manager::registerHandle(): Key registered more than once, overriding: " << key;
|
||||||
_handles.insert(key, handle);
|
}
|
||||||
|
_handles.insert(key, handle);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::removeHandle(const QString& key) {
|
void Manager::removeHandle(const QString& key) {
|
||||||
_handles.remove(key);
|
withWriteLock([&] {
|
||||||
|
_handles.remove(key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::loadSetting(Interface* handle) {
|
void Manager::loadSetting(Interface* handle) {
|
||||||
handle->setVariant(value(handle->getKey()));
|
handle->setVariant(value(handle->getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::saveSetting(Interface* handle) {
|
void Manager::saveSetting(Interface* handle) {
|
||||||
if (handle->isSet()) {
|
if (handle->isSet()) {
|
||||||
setValue(handle->getKey(), handle->getVariant());
|
setValue(handle->getKey(), handle->getVariant());
|
||||||
|
@ -49,7 +54,7 @@ namespace Setting {
|
||||||
remove(handle->getKey());
|
remove(handle->getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec
|
static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec
|
||||||
void Manager::startTimer() {
|
void Manager::startTimer() {
|
||||||
if (!_saveTimer) {
|
if (!_saveTimer) {
|
||||||
|
@ -61,18 +66,20 @@ namespace Setting {
|
||||||
}
|
}
|
||||||
_saveTimer->start();
|
_saveTimer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::stopTimer() {
|
void Manager::stopTimer() {
|
||||||
if (_saveTimer) {
|
if (_saveTimer) {
|
||||||
_saveTimer->stop();
|
_saveTimer->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::saveAll() {
|
void Manager::saveAll() {
|
||||||
for (auto handle : _handles) {
|
withReadLock([&] {
|
||||||
saveSetting(handle);
|
for (auto handle : _handles) {
|
||||||
}
|
saveSetting(handle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Restart timer
|
// Restart timer
|
||||||
if (_saveTimer) {
|
if (_saveTimer) {
|
||||||
_saveTimer->start();
|
_saveTimer->start();
|
||||||
|
|
|
@ -16,29 +16,31 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "shared/ReadWriteLockable.h"
|
||||||
|
|
||||||
namespace Setting {
|
namespace Setting {
|
||||||
class Interface;
|
class Interface;
|
||||||
|
|
||||||
class Manager : public QSettings {
|
class Manager : public QSettings, public ReadWriteLockable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
~Manager();
|
~Manager();
|
||||||
void registerHandle(Interface* handle);
|
void registerHandle(Interface* handle);
|
||||||
void removeHandle(const QString& key);
|
void removeHandle(const QString& key);
|
||||||
|
|
||||||
void loadSetting(Interface* handle);
|
void loadSetting(Interface* handle);
|
||||||
void saveSetting(Interface* handle);
|
void saveSetting(Interface* handle);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startTimer();
|
void startTimer();
|
||||||
void stopTimer();
|
void stopTimer();
|
||||||
|
|
||||||
void saveAll();
|
void saveAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, Interface*> _handles;
|
QHash<QString, Interface*> _handles;
|
||||||
QPointer<QTimer> _saveTimer = nullptr;
|
QPointer<QTimer> _saveTimer = nullptr;
|
||||||
|
|
||||||
friend class Interface;
|
friend class Interface;
|
||||||
friend void cleanupPrivateInstance();
|
friend void cleanupPrivateInstance();
|
||||||
friend void setupPrivateInstance();
|
friend void setupPrivateInstance();
|
||||||
|
|
Loading…
Reference in a new issue