diff options
author | Svetlana Abramenkova <sabramenkova@luxoft.com> | 2019-06-24 18:55:04 +0300 |
---|---|---|
committer | Svetlana Abramenkova <sabramenkova@luxoft.com> | 2019-06-24 18:55:04 +0300 |
commit | 16a1aaea94d637f7f7e0718d3b43219cbeaad923 (patch) | |
tree | 66a487baeae2ac1fe68bd910cd2be145111f01bf | |
parent | d9db143d646cc6050cbfffee69acc614c8f9c110 (diff) |
fix vtable issue
Change-Id: I7eabc33fec9b6452b4f8ccbe5230340ba775a27f
Reviewed-by: Nikolay Zamotaev <nzamotaev@luxoft.com>
-rw-r--r-- | src/livenodeengine.cpp | 65 | ||||
-rw-r--r-- | src/livenodeengine.h | 2 | ||||
-rw-r--r-- | src/overlay.cpp | 87 | ||||
-rw-r--r-- | src/overlay.h | 62 | ||||
-rw-r--r-- | src/src.pri | 2 |
5 files changed, 152 insertions, 66 deletions
diff --git a/src/livenodeengine.cpp b/src/livenodeengine.cpp index cc2667b..6426fb2 100644 --- a/src/livenodeengine.cpp +++ b/src/livenodeengine.cpp @@ -48,11 +48,6 @@ #define DEBUG if (0) qDebug() #endif -namespace { -const char *const OVERLAY_PATH_PREFIX = "qml-live-overlay--"; -const char OVERLAY_PATH_SEPARATOR = '-'; -} - /*! * \class LiveNodeEngine * \brief The LiveNodeEngine class instantiates QML components in cooperation with LiveHubEngine. @@ -93,66 +88,6 @@ const char OVERLAY_PATH_SEPARATOR = '-'; * \sa {QML Live Runtime} */ -// Overlay uses temporary directory to allow parallel execution -class Overlay : public QObject -{ - Q_OBJECT - -public: - Overlay(const QString &basePath, QObject *parent) - : QObject(parent) - , m_basePath(basePath) - , m_overlay(overlayTemplatePath()) - { - if (!m_overlay.isValid()) -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) - qFatal("Failed to create overlay directory: %s", qPrintable(m_overlay.errorString())); -#else - qFatal("Failed to create overlay directory"); -#endif - - } - - ~Overlay() - { - } - - QDir overlay() const { return m_overlay.path(); } - - QString reserve(const LiveDocument &document) - { - QWriteLocker locker(&m_lock); - - QString overlayingPath = document.absoluteFilePathIn(m_overlay.path()); - m_mappings.insert(document.absoluteFilePathIn(m_basePath), overlayingPath); - return overlayingPath; - } - - QString map(const QString &file) const - { - QReadLocker locker(&m_lock); - - return m_mappings.value(file, file); - } - -private: - static QString overlayTemplatePath() - { - QSettings settings; - QString overlayTemplatePath = QDir::tempPath() + QDir::separator() + QLatin1String(OVERLAY_PATH_PREFIX); - if (!settings.organizationName().isEmpty()) // See QCoreApplication::organizationName's docs - overlayTemplatePath += settings.organizationName() + QLatin1Char(OVERLAY_PATH_SEPARATOR); - overlayTemplatePath += settings.applicationName(); - return overlayTemplatePath; - } - -private: - mutable QReadWriteLock m_lock; - QHash<QString, QString> m_mappings; - QString m_basePath; - QTemporaryDir m_overlay; -}; - class OverlayUrlInterceptor : public QObject, public QQmlAbstractUrlInterceptor { Q_OBJECT diff --git a/src/livenodeengine.h b/src/livenodeengine.h index c19fb9a..bc73457 100644 --- a/src/livenodeengine.h +++ b/src/livenodeengine.h @@ -38,10 +38,10 @@ #include "contentadapterinterface.h" #include "livedocument.h" #include "qmllive_global.h" +#include "overlay.h" class LiveRuntime; class ContentPluginFactory; -class Overlay; class OverlayUrlInterceptor; class QMLLIVESHARED_EXPORT LiveNodeEngine : public QObject diff --git a/src/overlay.cpp b/src/overlay.cpp new file mode 100644 index 0000000..92f890c --- /dev/null +++ b/src/overlay.cpp @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Jolla Ltd +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QML Live tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#include "overlay.h" + +namespace { +const char *const OVERLAY_PATH_PREFIX = "qml-live-overlay--"; +const char OVERLAY_PATH_SEPARATOR = '-'; +} + +Overlay::Overlay(const QString &basePath, QObject *parent) : QObject(parent) + , m_basePath(basePath) + , m_overlay(overlayTemplatePath()) +{ + if (!m_overlay.isValid()) +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + qFatal("Failed to create overlay directory: %s", qPrintable(m_overlay.errorString())); +#else + qFatal("Failed to create overlay directory"); +#endif + +} + +Overlay::~Overlay() +{ + +} + +QDir Overlay::overlay() const +{ + return m_overlay.path(); +} + +QString Overlay::reserve(const LiveDocument &document) +{ + QWriteLocker locker(&m_lock); + QString overlayingPath = document.absoluteFilePathIn(m_overlay.path()); + m_mappings.insert(document.absoluteFilePathIn(m_basePath), overlayingPath); + return overlayingPath; +} + +QString Overlay::map(const QString &file) const +{ + QReadLocker locker(&m_lock); + return m_mappings.value(file, file); +} + +QString Overlay::overlayTemplatePath() +{ + QSettings settings; + QString overlayTemplatePath = QDir::tempPath() + QDir::separator() + QLatin1String(OVERLAY_PATH_PREFIX); + + if (!settings.organizationName().isEmpty()) // See QCoreApplication::organizationName's docs + overlayTemplatePath += settings.organizationName() + QLatin1Char(OVERLAY_PATH_SEPARATOR); + + overlayTemplatePath += settings.applicationName(); + return overlayTemplatePath; +} diff --git a/src/overlay.h b/src/overlay.h new file mode 100644 index 0000000..92f609a --- /dev/null +++ b/src/overlay.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Jolla Ltd +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QML Live tool. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +#ifndef OVERLAY_H +#define OVERLAY_H + +#include <QObject> +#include "qmllive_global.h" +#include "livedocument.h" + +// Overlay uses temporary directory to allow parallel execution +class QMLLIVESHARED_EXPORT Overlay : public QObject +{ + Q_OBJECT +public: + Overlay(const QString &basePath, QObject *parent); + ~Overlay(); + + QString reserve(const LiveDocument &document); + QDir overlay() const; + QString map(const QString &file) const; + +private: + static QString overlayTemplatePath(); + +private: + mutable QReadWriteLock m_lock; + QHash<QString, QString> m_mappings; + QString m_basePath; + QTemporaryDir m_overlay; +}; + +#endif // OVERLAY_H diff --git a/src/src.pri b/src/src.pri index 38504b4..2a4c648 100644 --- a/src/src.pri +++ b/src/src.pri @@ -7,6 +7,7 @@ INCLUDEPATH += $${PWD} DEFINES += NO_LIBRSYNC SOURCES += \ + $$PWD/overlay.cpp \ $$PWD/watcher.cpp \ $$PWD/livedocument.cpp \ $$PWD/livehubengine.cpp \ @@ -38,6 +39,7 @@ public_headers += \ $$PWD/projectmanager.h HEADERS += \ + $$PWD/overlay.h \ $$public_headers \ $$PWD/qmllive_version.h \ $$PWD/watcher.h \ |