port most uses of the reset(new ...) pattern to std::make_unique

master
Xaver Hugl 1 year ago
parent 267dd543f2
commit 74f10d0cdf

@ -95,15 +95,15 @@ WaylandTestApplication::~WaylandTestApplication()
void WaylandTestApplication::createVirtualInputDevices()
{
m_virtualKeyboard.reset(new Test::VirtualInputDevice());
m_virtualKeyboard = std::make_unique<Test::VirtualInputDevice>();
m_virtualKeyboard->setName(QStringLiteral("Virtual Keyboard 1"));
m_virtualKeyboard->setKeyboard(true);
m_virtualPointer.reset(new Test::VirtualInputDevice());
m_virtualPointer = std::make_unique<Test::VirtualInputDevice>();
m_virtualPointer->setName(QStringLiteral("Virtual Pointer 1"));
m_virtualPointer->setPointer(true);
m_virtualTouch.reset(new Test::VirtualInputDevice());
m_virtualTouch = std::make_unique<Test::VirtualInputDevice>();
m_virtualTouch->setName(QStringLiteral("Virtual Touch 1"));
m_virtualTouch->setTouch(true);

@ -233,8 +233,8 @@ void TestXdgShellWindowRules::createTestWindow(ClientFlags flags)
Test::XdgToplevelDecorationV1 *decoration = Test::createXdgToplevelDecorationV1(m_shellSurface.get(), m_shellSurface.get());
// Add signal watchers
m_toplevelConfigureRequestedSpy.reset(new QSignalSpy(m_shellSurface.get(), &Test::XdgToplevel::configureRequested));
m_surfaceConfigureRequestedSpy.reset(new QSignalSpy(m_shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested));
m_toplevelConfigureRequestedSpy = std::make_unique<QSignalSpy>(m_shellSurface.get(), &Test::XdgToplevel::configureRequested);
m_surfaceConfigureRequestedSpy = std::make_unique<QSignalSpy>(m_shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
m_shellSurface->set_app_id(QStringLiteral("org.kde.foo"));
decoration->set_mode(decorationMode);

@ -622,7 +622,7 @@ DebugConsole::DebugConsole()
connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, [this](int index) {
// delay creation of input event filter until the tab is selected
if (index == 2 && !m_inputFilter) {
m_inputFilter.reset(new DebugConsoleFilter(m_ui->inputTextEdit));
m_inputFilter = std::make_unique<DebugConsoleFilter>(m_ui->inputTextEdit);
input()->installInputEventSpy(m_inputFilter.get());
}
if (index == 5) {

@ -64,7 +64,7 @@ KWinWrapper::KWinWrapper(QObject *parent)
}
if (qApp->arguments().contains(QLatin1String("--xwayland"))) {
m_xwlSocket.reset(new KWin::XwaylandSocket(KWin::XwaylandSocket::OperationMode::TransferFdsOnExec));
m_xwlSocket = std::make_unique<KWin::XwaylandSocket>(KWin::XwaylandSocket::OperationMode::TransferFdsOnExec);
if (!m_xwlSocket->isValid()) {
qCWarning(KWIN_WRAPPER) << "Failed to create Xwayland connection sockets";
m_xwlSocket.reset();

@ -677,7 +677,7 @@ std::unique_ptr<ShaderManager> ShaderManager::s_shaderManager;
ShaderManager *ShaderManager::instance()
{
if (!s_shaderManager) {
s_shaderManager.reset(new ShaderManager());
s_shaderManager = std::make_unique<ShaderManager>();
}
return s_shaderManager.get();
}

@ -102,7 +102,7 @@ void OffscreenData::maybeRender(EffectWindow *window)
}
m_texture->setFilter(GL_LINEAR);
m_texture->setWrapMode(GL_CLAMP_TO_EDGE);
m_fbo.reset(new GLFramebuffer(m_texture.get()));
m_fbo = std::make_unique<GLFramebuffer>(m_texture.get());
m_isDirty = true;
}

@ -108,13 +108,13 @@ OffscreenQuickView::OffscreenQuickView(QObject *parent, ExportMode exportMode)
d->m_view->setFormat(format);
auto shareContext = QOpenGLContext::globalShareContext();
d->m_glcontext.reset(new QOpenGLContext);
d->m_glcontext = std::make_unique<QOpenGLContext>();
d->m_glcontext->setShareContext(shareContext);
d->m_glcontext->setFormat(format);
d->m_glcontext->create();
// and the offscreen surface
d->m_offscreenSurface.reset(new QOffscreenSurface);
d->m_offscreenSurface = std::make_unique<QOffscreenSurface>();
d->m_offscreenSurface->setFormat(d->m_glcontext->format());
d->m_offscreenSurface->create();
@ -217,7 +217,7 @@ void OffscreenQuickView::update()
const QSize nativeSize = d->m_view->size() * d->m_view->effectiveDevicePixelRatio();
if (!d->m_fbo || d->m_fbo->size() != nativeSize) {
d->m_textureExport.reset(nullptr);
d->m_fbo.reset(new QOpenGLFramebufferObject(nativeSize, QOpenGLFramebufferObject::CombinedDepthStencil));
d->m_fbo = std::make_unique<QOpenGLFramebufferObject>(nativeSize, QOpenGLFramebufferObject::CombinedDepthStencil);
if (!d->m_fbo->isValid()) {
d->m_fbo.reset();
d->m_glcontext->doneCurrent();
@ -542,7 +542,7 @@ void OffscreenQuickScene::setSource(const QUrl &source)
void OffscreenQuickScene::setSource(const QUrl &source, const QVariantMap &initialProperties)
{
if (!d->qmlComponent) {
d->qmlComponent.reset(new QQmlComponent(effects->qmlEngine()));
d->qmlComponent = std::make_unique<QQmlComponent>(effects->qmlEngine());
}
d->qmlComponent->loadUrl(source);

@ -437,7 +437,7 @@ void QuickSceneEffect::startInternal()
}
if (!d->qmlComponent) {
d->qmlComponent.reset(new QQmlComponent(effects->qmlEngine()));
d->qmlComponent = std::make_unique<QQmlComponent>(effects->qmlEngine());
d->qmlComponent->loadUrl(d->source);
if (d->qmlComponent->isError()) {
qWarning().nospace() << "Failed to load " << d->source << ": " << d->qmlComponent->errors();

@ -251,7 +251,7 @@ void ApplicationX11::performStartup()
{
crashChecking();
owner.reset(new KWinSelectionOwner());
owner = std::make_unique<KWinSelectionOwner>();
connect(owner.get(), &KSelectionOwner::failedToClaimOwnership, [] {
fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").toLocal8Bit().constData(), stderr);
::exit(1);

@ -115,7 +115,7 @@ RootInfo *RootInfo::create()
| NET::ActionChangeDesktop
| NET::ActionClose;
s_self.reset(new RootInfo(supportWindow, "KWin", properties, types, states, properties2, actions));
s_self = std::make_unique<RootInfo>(supportWindow, "KWin", properties, types, states, properties2, actions);
return s_self.get();
}

@ -31,6 +31,8 @@ class RootInfo : public NETRootInfo
public:
static RootInfo *create();
static void destroy();
RootInfo(xcb_window_t w, const char *name, NET::Properties properties, NET::WindowTypes types,
NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr = -1);
void setActiveClient(Window *client);
@ -47,8 +49,6 @@ protected:
void changeShowingDesktop(bool showing) override;
private:
RootInfo(xcb_window_t w, const char *name, NET::Properties properties, NET::WindowTypes types,
NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr = -1);
static std::unique_ptr<RootInfo> s_self;
friend RootInfo *rootInfo();

@ -160,7 +160,7 @@ void OnScreenNotification::ensureQmlContext()
if (m_qmlContext) {
return;
}
m_qmlContext.reset(new QQmlContext(m_qmlEngine));
m_qmlContext = std::make_unique<QQmlContext>(m_qmlEngine);
m_qmlContext->setContextProperty(QStringLiteral("osd"), this);
}
@ -171,7 +171,7 @@ void OnScreenNotification::ensureQmlComponent()
if (m_qmlComponent) {
return;
}
m_qmlComponent.reset(new QQmlComponent(m_qmlEngine));
m_qmlComponent = std::make_unique<QQmlComponent>(m_qmlEngine);
const QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
m_config->group(QStringLiteral("OnScreenNotification")).readEntry("QmlPath", QStringLiteral("kwin/onscreennotification/plasma/main.qml")));
if (fileName.isEmpty()) {
@ -189,7 +189,7 @@ void OnScreenNotification::createInputSpy()
{
Q_ASSERT(!m_spy);
if (auto w = qobject_cast<QQuickWindow *>(m_mainItem.get())) {
m_spy.reset(new OnScreenNotificationInputEventSpy(this));
m_spy = std::make_unique<OnScreenNotificationInputEventSpy>(this);
input()->installInputEventSpy(m_spy.get());
if (!m_animation) {
m_animation = new QPropertyAnimation(w, "opacity", this);

@ -102,7 +102,7 @@ bool BasicEGLSurfaceTextureWayland::loadDmabufTexture(GraphicsBuffer *buffer)
return false;
}
m_texture.reset(new GLTexture(GL_TEXTURE_2D));
m_texture = std::make_unique<GLTexture>(GL_TEXTURE_2D);
m_texture->setSize(buffer->size());
m_texture->create();
m_texture->setWrapMode(GL_CLAMP_TO_EDGE);

@ -85,7 +85,7 @@ void Helper::ref()
{
m_refCount++;
if (m_refCount == 1) {
m_engine.reset(new QQmlEngine);
m_engine = std::make_unique<QQmlEngine>();
init();
}
}
@ -117,7 +117,7 @@ QQmlComponent *Helper::component(const QString &themeName)
while (paths.hasPrevious()) {
m_engine->addImportPath(paths.previous());
}
m_svgComponent.reset(new QQmlComponent(m_engine.get()));
m_svgComponent = std::make_unique<QQmlComponent>(m_engine.get());
m_svgComponent->loadUrl(QUrl(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/aurorae/aurorae.qml"))));
}
// verify that the theme exists

@ -82,7 +82,7 @@ void RegionScreenCastSource::ensureTexture()
if (!m_renderedTexture) {
return;
}
m_target.reset(new GLFramebuffer(m_renderedTexture.get()));
m_target = std::make_unique<GLFramebuffer>(m_renderedTexture.get());
const auto allOutputs = workspace()->outputs();
for (auto output : allOutputs) {
if (output->geometry().intersects(m_region)) {

@ -246,7 +246,7 @@ void ScreenShotEffect::takeScreenShot(ScreenShotWindowData *screenshot)
}
offscreenTexture->setFilter(GL_LINEAR);
offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
target.reset(new GLFramebuffer(offscreenTexture.get()));
target = std::make_unique<GLFramebuffer>(offscreenTexture.get());
validTarget = target->valid();
}
if (validTarget) {

@ -89,7 +89,7 @@ void ScreenTransformEffect::addScreen(EffectScreen *screen)
m_states.remove(screen);
return;
}
state.m_prev.framebuffer.reset(new GLFramebuffer(state.m_prev.texture.get()));
state.m_prev.framebuffer = std::make_unique<GLFramebuffer>(state.m_prev.texture.get());
// Rendering the current scene into a texture
GLFramebuffer::pushFramebuffer(state.m_prev.framebuffer.get());
@ -202,7 +202,7 @@ void ScreenTransformEffect::paintScreen(const RenderTarget &renderTarget, const
m_states.remove(screen);
return;
}
it->m_current.framebuffer.reset(new GLFramebuffer(it->m_current.texture.get()));
it->m_current.framebuffer = std::make_unique<GLFramebuffer>(it->m_current.texture.get());
}
RenderTarget fboRenderTarget(it->m_current.framebuffer.get());

@ -264,7 +264,7 @@ void StartupFeedbackEffect::gotNewStartup(const QString &id, const QIcon &icon)
Startup &startup = m_startups[id];
startup.icon = icon;
startup.expiredTimer.reset(new QTimer());
startup.expiredTimer = std::make_unique<QTimer>();
// Stop the animation if the startup doesn't finish within reasonable interval.
connect(startup.expiredTimer.get(), &QTimer::timeout, this, [this, id]() {
gotRemoveStartup(id);

@ -386,7 +386,7 @@ void WindowThumbnailItem::updateOffscreenTexture()
}
m_offscreenTexture->setFilter(GL_LINEAR);
m_offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE);
m_offscreenTarget.reset(new GLFramebuffer(m_offscreenTexture.get()));
m_offscreenTarget = std::make_unique<GLFramebuffer>(m_offscreenTexture.get());
}
RenderTarget offscreenRenderTarget(m_offscreenTarget.get());

@ -1198,7 +1198,7 @@ bool TabBox::establishTabBoxGrab()
if (Workspace::self()->activeWindow() != nullptr) {
Workspace::self()->activeWindow()->updateMouseGrab();
}
m_x11EventFilter.reset(new X11Filter);
m_x11EventFilter = std::make_unique<X11Filter>();
return true;
}

@ -286,10 +286,10 @@ void TabBoxHandlerPrivate::show()
#ifndef KWIN_UNIT_TEST
if (!m_qmlContext) {
qmlRegisterType<SwitcherItem>("org.kde.kwin", 3, 0, "TabBoxSwitcher");
m_qmlContext.reset(new QQmlContext(Scripting::self()->qmlEngine()));
m_qmlContext = std::make_unique<QQmlContext>(Scripting::self()->qmlEngine());
}
if (!m_qmlComponent) {
m_qmlComponent.reset(new QQmlComponent(Scripting::self()->qmlEngine()));
m_qmlComponent = std::make_unique<QQmlComponent>(Scripting::self()->qmlEngine());
}
auto findMainItem = [this](const QMap<QString, QObject *> &tabBoxes) -> QObject * {
auto it = tabBoxes.constFind(config.layoutName());

@ -58,7 +58,7 @@ TileManager::TileManager(Output *parent)
, m_output(parent)
, m_tileModel(new TileModel(this))
{
m_saveTimer.reset(new QTimer(this));
m_saveTimer = std::make_unique<QTimer>(this);
m_saveTimer->setSingleShot(true);
m_saveTimer->setInterval(2000);
connect(m_saveTimer.get(), &QTimer::timeout, this, &TileManager::saveSettings);

@ -1612,7 +1612,7 @@ void Workspace::slotWindowToDesktopDown()
void Workspace::slotKillWindow()
{
if (!m_windowKiller) {
m_windowKiller.reset(new KillWindow());
m_windowKiller = std::make_unique<KillWindow>();
}
m_windowKiller->start();
}

@ -156,7 +156,7 @@ UdevDevice::Ptr Udev::deviceFromSyspath(const char *syspath)
qCWarning(KWIN_CORE) << "failed to retrieve device for" << syspath << strerror(errno);
return {};
}
return UdevDevice::Ptr(new UdevDevice(dev));
return std::make_unique<UdevDevice>(dev);
}
std::unique_ptr<UdevMonitor> Udev::monitor()
@ -288,11 +288,7 @@ UdevDevice::Ptr UdevMonitor::getDevice()
return UdevDevice::Ptr();
}
auto dev = udev_monitor_receive_device(m_monitor);
if (!dev) {
return {};
}
return UdevDevice::Ptr(new UdevDevice(dev));
return dev ? std::make_unique<UdevDevice>(dev) : nullptr;
}
}

@ -322,7 +322,7 @@ void LinuxDmaBufV1ClientBufferIntegration::setSupportedFormatsWithModifiers(cons
}
d->supportedModifiers = set;
d->mainDevice = tranches.first().device;
d->table.reset(new LinuxDmaBufV1FormatTable(set));
d->table = std::make_unique<LinuxDmaBufV1FormatTable>(set);
d->defaultFeedback->setTranches(tranches);
}
}

@ -307,27 +307,26 @@ void Workspace::initializeX11()
// first initialize the extensions
Xcb::Extensions::self();
m_colorMapper.reset(new ColorMapper(this));
m_colorMapper = std::make_unique<ColorMapper>(this);
connect(this, &Workspace::windowActivated, m_colorMapper.get(), &ColorMapper::update);
// Call this before XSelectInput() on the root window
m_startup.reset(new KStartupInfo(
KStartupInfo::DisableKWinModule | KStartupInfo::AnnounceSilenceChanges, this));
m_startup = std::make_unique<KStartupInfo>(KStartupInfo::DisableKWinModule | KStartupInfo::AnnounceSilenceChanges, this);
// Select windowmanager privileges
selectWmInputEventMask();
if (kwinApp()->operationMode() == Application::OperationModeX11) {
m_wasUserInteractionFilter.reset(new WasUserInteractionX11Filter);
m_movingClientFilter.reset(new MovingClientX11Filter);
m_wasUserInteractionFilter = std::make_unique<WasUserInteractionX11Filter>();
m_movingClientFilter = std::make_unique<MovingClientX11Filter>();
}
if (Xcb::Extensions::self()->isSyncAvailable()) {
m_syncAlarmFilter.reset(new SyncAlarmX11Filter);
m_syncAlarmFilter = std::make_unique<SyncAlarmX11Filter>();
}
kwinApp()->updateXTime(); // Needed for proper initialization of user_time in Client ctor
const uint32_t nullFocusValues[] = {true};
m_nullFocus.reset(new Xcb::Window(QRect(-1, -1, 1, 1), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, nullFocusValues));
m_nullFocus = std::make_unique<Xcb::Window>(QRect(-1, -1, 1, 1), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, nullFocusValues);
m_nullFocus->map();
RootInfo *rootInfo = RootInfo::create();

@ -1361,7 +1361,7 @@ void X11Window::maybeCreateX11DecorationRenderer()
return;
}
if (!Compositor::compositing() && decoratedClient()) {
m_decorationRenderer.reset(new X11DecorationRenderer(decoratedClient()));
m_decorationRenderer = std::make_unique<X11DecorationRenderer>(decoratedClient());
decoration()->update();
}
}

@ -108,7 +108,7 @@ QString XdgActivationV1Integration::requestToken(bool isPrivileged, SurfaceInter
if (showNotify) {
activation = waylandServer()->plasmaActivationFeedback()->createActivation(appId);
}
m_currentActivationToken.reset(new ActivationToken{newToken, isPrivileged, surface, serial, seat, appId, showNotify, std::move(activation)});
m_currentActivationToken = std::make_unique<ActivationToken>(ActivationToken{newToken, isPrivileged, surface, serial, seat, appId, showNotify, std::move(activation)});
if (showNotify) {
Q_EMIT effects->startupAdded(m_currentActivationToken->token, icon);
}

@ -42,14 +42,14 @@ private:
struct ActivationToken
{
const QString token;
const bool isPrivileged;
const QPointer<const KWaylandServer::SurfaceInterface> surface;
const uint serial;
const KWaylandServer::SeatInterface *seat;
const QString applicationId;
const bool showNotify;
const std::unique_ptr<KWaylandServer::PlasmaWindowActivationInterface> activation;
QString token;
bool isPrivileged;
QPointer<const KWaylandServer::SurfaceInterface> surface;
uint serial;
KWaylandServer::SeatInterface *seat;
QString applicationId;
bool showNotify;
std::unique_ptr<KWaylandServer::PlasmaWindowActivationInterface> activation;
};
std::unique_ptr<ActivationToken> m_currentActivationToken;
};

@ -309,7 +309,7 @@ void Xwayland::handleXwaylandReady()
qCInfo(KWIN_XWL) << "Xwayland server started on display" << m_launcher->displayName();
// create selection owner for WM_S0 - magic X display number expected by XWayland
m_selectionOwner.reset(new KSelectionOwner("WM_S0", kwinApp()->x11Connection(), kwinApp()->x11RootWindow()));
m_selectionOwner = std::make_unique<KSelectionOwner>("WM_S0", kwinApp()->x11Connection(), kwinApp()->x11RootWindow());
connect(m_selectionOwner.get(), &KSelectionOwner::lostOwnership,
this, &Xwayland::handleSelectionLostOwnership);
connect(m_selectionOwner.get(), &KSelectionOwner::claimedOwnership,
@ -347,7 +347,7 @@ void Xwayland::refreshEavesdropping()
}
if (enabled) {
m_inputSpy.reset(new XwaylandInputSpy);
m_inputSpy = std::make_unique<XwaylandInputSpy>();
input()->installInputEventSpy(m_inputSpy.get());
m_inputSpy->setMode(options->xwaylandEavesdrops());
} else {

@ -80,7 +80,7 @@ void XwaylandLauncher::enable()
if (!m_listenFds.isEmpty()) {
Q_ASSERT(!m_displayName.isEmpty());
} else {
m_socket.reset(new XwaylandSocket(XwaylandSocket::OperationMode::CloseFdsOnExec));
m_socket = std::make_unique<XwaylandSocket>(XwaylandSocket::OperationMode::CloseFdsOnExec);
if (!m_socket->isValid()) {
qFatal("Failed to establish X11 socket");
}

Loading…
Cancel
Save