4874066423
There are a few benefits to using smart pointers from the standard library: - std::unique_ptr has move semantics. With move semantics, transfer of ownership can be properly expressed - std::shared_ptr is more efficient than QSharedPointer - more developers are used to them, making contributions for newcomers easier We're also already using a mix of both; because Qt shared pointers provide no benefits, porting to standard smart pointers improves consistency in the code base. Because of that, this commit ports most of the uses of QSharedPointer to std::shared_ptr, and some uses of QScopedPointer to std::unique_ptr
27 lines
424 B
C++
27 lines
424 B
C++
/*
|
|
SPDX-FileCopyrightText: 2022 MBition GmbH
|
|
SPDX-FileContributor: Kai Uwe Broulik <kai_uwe.broulik@mbition.io>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
class QQmlEngine;
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
class SharedQmlEngine
|
|
{
|
|
public:
|
|
using Ptr = std::shared_ptr<QQmlEngine>;
|
|
static Ptr engine();
|
|
|
|
private:
|
|
static std::weak_ptr<QQmlEngine> s_engine;
|
|
};
|
|
|
|
} // namespace KWin
|