mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:34:07 +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);
|
||||
|
||||
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
|
||||
//
|
||||
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
|
||||
#include "SettingInterface.h"
|
||||
|
@ -25,23 +26,27 @@ namespace Setting {
|
|||
|
||||
// sync will be called in the QSettings destructor
|
||||
}
|
||||
|
||||
|
||||
void Manager::registerHandle(Setting::Interface* handle) {
|
||||
QString key = handle->getKey();
|
||||
if (_handles.contains(key)) {
|
||||
qWarning() << "Setting::Manager::registerHandle(): Key registered more than once, overriding: " << key;
|
||||
}
|
||||
_handles.insert(key, handle);
|
||||
withWriteLock([&] {
|
||||
if (_handles.contains(key)) {
|
||||
qWarning() << "Setting::Manager::registerHandle(): Key registered more than once, overriding: " << key;
|
||||
}
|
||||
_handles.insert(key, handle);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Manager::removeHandle(const QString& key) {
|
||||
_handles.remove(key);
|
||||
withWriteLock([&] {
|
||||
_handles.remove(key);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void Manager::loadSetting(Interface* handle) {
|
||||
handle->setVariant(value(handle->getKey()));
|
||||
}
|
||||
|
||||
|
||||
void Manager::saveSetting(Interface* handle) {
|
||||
if (handle->isSet()) {
|
||||
setValue(handle->getKey(), handle->getVariant());
|
||||
|
@ -49,7 +54,7 @@ namespace Setting {
|
|||
remove(handle->getKey());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const int SAVE_INTERVAL_MSEC = 5 * 1000; // 5 sec
|
||||
void Manager::startTimer() {
|
||||
if (!_saveTimer) {
|
||||
|
@ -61,18 +66,20 @@ namespace Setting {
|
|||
}
|
||||
_saveTimer->start();
|
||||
}
|
||||
|
||||
|
||||
void Manager::stopTimer() {
|
||||
if (_saveTimer) {
|
||||
_saveTimer->stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Manager::saveAll() {
|
||||
for (auto handle : _handles) {
|
||||
saveSetting(handle);
|
||||
}
|
||||
|
||||
withReadLock([&] {
|
||||
for (auto handle : _handles) {
|
||||
saveSetting(handle);
|
||||
}
|
||||
});
|
||||
|
||||
// Restart timer
|
||||
if (_saveTimer) {
|
||||
_saveTimer->start();
|
||||
|
|
|
@ -16,29 +16,31 @@
|
|||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
|
||||
#include "shared/ReadWriteLockable.h"
|
||||
|
||||
namespace Setting {
|
||||
class Interface;
|
||||
|
||||
class Manager : public QSettings {
|
||||
|
||||
class Manager : public QSettings, public ReadWriteLockable {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
~Manager();
|
||||
void registerHandle(Interface* handle);
|
||||
void removeHandle(const QString& key);
|
||||
|
||||
|
||||
void loadSetting(Interface* handle);
|
||||
void saveSetting(Interface* handle);
|
||||
|
||||
|
||||
private slots:
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
|
||||
|
||||
void saveAll();
|
||||
|
||||
|
||||
private:
|
||||
QHash<QString, Interface*> _handles;
|
||||
QPointer<QTimer> _saveTimer = nullptr;
|
||||
|
||||
|
||||
friend class Interface;
|
||||
friend void cleanupPrivateInstance();
|
||||
friend void setupPrivateInstance();
|
||||
|
|
Loading…
Reference in a new issue