port to C++ smart pointers where possible

wilder-5.26
Xaver Hugl 4 years ago committed by Fushan Wen
parent a8ce876a48
commit 401165921c
  1. 2
      applets/appmenu/plugin/appmenumodel.h
  2. 2
      applets/icon/iconapplet.cpp
  3. 2
      applets/icon/iconapplet.h
  4. 5
      appmenu/appmenu.cpp
  5. 20
      c_ptr.h
  6. 4
      components/shellprivate/widgetexplorer/widgetexplorer.cpp
  7. 11
      gmenu-dbusmenu-proxy/menuproxy.cpp
  8. 3
      kcms/colors/colors.h
  9. 3
      kcms/cursortheme/kcmcursortheme.h
  10. 2
      kcms/desktoptheme/kcm.h
  11. 4
      kcms/icons/main.cpp
  12. 3
      kcms/icons/main.h
  13. 6
      kcms/lookandfeel/kcm.cpp
  14. 3
      kcms/style/kcmstyle.cpp
  15. 10
      kcms/style/previewitem.cpp
  16. 5
      kcms/style/previewitem.h
  17. 4
      kioslave/desktop/tests/kio_desktop_test.cpp
  18. 20
      klipper/autotests/historymodeltest.cpp
  19. 22
      klipper/autotests/historytest.cpp
  20. 7
      klipper/klipper.cpp
  21. 1
      libnotificationmanager/notification_p.h
  22. 2
      libnotificationmanager/server_p.cpp
  23. 3
      libnotificationmanager/server_p.h
  24. 6
      libtaskmanager/declarative/pipewiresourceitem.cpp
  25. 4
      libtaskmanager/declarative/pipewiresourceitem.h
  26. 4
      libtaskmanager/declarative/screencasting.h
  27. 8
      runners/bookmarks/autotests/chrome/testchromebookmarks.cpp
  28. 3
      runners/bookmarks/autotests/chrome/testchromebookmarks.h
  29. 3
      shell/panelview.cpp
  30. 6
      shell/shellcorona.cpp
  31. 3
      shell/shellcorona.h
  32. 2
      startkde/plasma-session/startup.h
  33. 2
      startkde/startplasma-x11.cpp
  34. 4
      startkde/startplasma.cpp
  35. 2
      startkde/startplasma.h
  36. 9
      xembed-sni-proxy/fdoselectionmanager.cpp
  37. 13
      xembed-sni-proxy/sniproxy.cpp
  38. 10
      xembed-sni-proxy/xcbutils.h

@ -79,7 +79,7 @@ private:
//! window that its menu initialization may be delayed
WId m_delayedMenuWindowId = 0;
QScopedPointer<QMenu> m_searchMenu;
std::unique_ptr<QMenu> m_searchMenu;
QPointer<QMenu> m_menu;
QPointer<QAction> m_searchAction;
QList<QAction *> m_currentSearchActions;

@ -370,7 +370,7 @@ QList<QAction *> IconApplet::contextualActions()
m_openWithMenu.reset(new QMenu());
}
m_openWithMenu->clear();
m_fileItemActions->insertOpenWithActionsTo(nullptr, m_openWithMenu.data(), QStringList());
m_fileItemActions->insertOpenWithActionsTo(nullptr, m_openWithMenu.get(), QStringList());
m_openWithActions = m_openWithMenu->actions();
}

@ -87,7 +87,7 @@ private:
QAction *m_openContainingFolderAction = nullptr;
KFileItemActions *m_fileItemActions = nullptr;
QScopedPointer<QMenu> m_openWithMenu;
std::unique_ptr<QMenu> m_openWithMenu;
QPointer<KPropertiesDialog> m_configDialog;

@ -7,6 +7,7 @@
*/
#include "appmenu.h"
#include "../c_ptr.h"
#include "appmenu_dbus.h"
#include "appmenu_debug.h"
#include "appmenuadaptor.h"
@ -134,8 +135,8 @@ void AppMenuModule::slotWindowRegistered(WId id, const QString &serviceName, con
auto setWindowProperty = [c](WId id, xcb_atom_t &atom, const QByteArray &name, const QByteArray &value) {
if (atom == XCB_ATOM_NONE) {
const xcb_intern_atom_cookie_t cookie = xcb_intern_atom(c, false, name.length(), name.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> reply(xcb_intern_atom_reply(c, cookie, nullptr));
if (reply.isNull()) {
UniqueCPointer<xcb_intern_atom_reply_t> reply{xcb_intern_atom_reply(c, cookie, nullptr)};
if (!reply) {
return;
}
atom = reply->atom;

@ -0,0 +1,20 @@
/*
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: LGPL-2.1-or-later
*/
#pragma once
#include <memory>
struct CDeleter {
template<typename T>
void operator()(T *ptr)
{
if (ptr) {
free(ptr);
}
}
};
template<typename T>
using UniqueCPointer = std::unique_ptr<T, CDeleter>;

@ -58,7 +58,7 @@ public:
, filterModel(w)
, activitiesConsumer(new KActivities::Consumer())
{
QObject::connect(activitiesConsumer.data(), &Consumer::currentActivityChanged, q, [this] {
QObject::connect(activitiesConsumer.get(), &Consumer::currentActivityChanged, q, [this] {
initRunningApplets();
});
}
@ -98,7 +98,7 @@ public:
DefaultItemFilterProxyModel filterItemModel;
static QPointer<KNS3::QtQuickDialogWrapper> newStuffDialog;
QScopedPointer<KActivities::Consumer> activitiesConsumer;
std::unique_ptr<KActivities::Consumer> activitiesConsumer;
};
QPointer<KNS3::QtQuickDialogWrapper> WidgetExplorerPrivate::newStuffDialog;

@ -31,6 +31,7 @@
#endif
#include <xcb/xcb.h>
#include "../c_ptr.h"
#include "window.h"
#include <chrono>
@ -340,14 +341,14 @@ QByteArray MenuProxy::getWindowPropertyString(WId id, const QByteArray &name)
static const long MAX_PROP_SIZE = 10000;
auto propertyCookie = xcb_get_property(m_xConnection, false, id, atom, utf8StringAtom, 0, MAX_PROP_SIZE);
QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> propertyReply(xcb_get_property_reply(m_xConnection, propertyCookie, nullptr));
if (propertyReply.isNull()) {
UniqueCPointer<xcb_get_property_reply_t> propertyReply(xcb_get_property_reply(m_xConnection, propertyCookie, nullptr));
if (!propertyReply) {
qCWarning(DBUSMENUPROXY) << "XCB property reply for atom" << name << "on" << id << "was null";
return value;
}
if (propertyReply->type == utf8StringAtom && propertyReply->format == 8 && propertyReply->value_len > 0) {
const char *data = (const char *)xcb_get_property_value(propertyReply.data());
const char *data = (const char *)xcb_get_property_value(propertyReply.get());
int len = propertyReply->value_len;
if (data) {
value = QByteArray(data, data[len - 1] ? len : len - 1);
@ -378,8 +379,8 @@ xcb_atom_t MenuProxy::getAtom(const QByteArray &name)
auto atom = s_atoms.value(name, XCB_ATOM_NONE);
if (atom == XCB_ATOM_NONE) {
const xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom(m_xConnection, false, name.length(), name.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atomReply(xcb_intern_atom_reply(m_xConnection, atomCookie, nullptr));
if (!atomReply.isNull()) {
UniqueCPointer<xcb_intern_atom_reply_t> atomReply(xcb_intern_atom_reply(m_xConnection, atomCookie, nullptr));
if (atomReply) {
atom = atomReply->atom;
if (atom != XCB_ATOM_NONE) {
s_atoms.insert(name, atom);

@ -12,7 +12,6 @@
#include <QColor>
#include <QDBusPendingCallWatcher>
#include <QPointer>
#include <QScopedPointer>
#include <KSharedConfig>
@ -120,6 +119,6 @@ private:
KSharedConfigPtr m_config;
KConfigWatcher::Ptr m_configWatcher;
QScopedPointer<QTemporaryFile> m_tempInstallFile;
std::unique_ptr<QTemporaryFile> m_tempInstallFile;
QPointer<KIO::FileCopyJob> m_tempCopyJob;
};

@ -9,7 +9,6 @@
#include <KNSCore/EntryWrapper>
#include <KQuickAddons/ManagedConfigModule>
#include <QScopedPointer>
#include "cursorthemesettings.h"
@ -121,6 +120,6 @@ private:
bool m_canResize;
bool m_canConfigure;
QScopedPointer<QTemporaryFile> m_tempInstallFile;
std::unique_ptr<QTemporaryFile> m_tempInstallFile;
QPointer<KIO::FileCopyJob> m_tempCopyJob;
};

@ -84,7 +84,7 @@ private:
QHash<QString, Plasma::Theme *> m_themes;
bool m_haveThemeExplorerInstalled;
QScopedPointer<QTemporaryFile> m_tempInstallFile;
std::unique_ptr<QTemporaryFile> m_tempInstallFile;
QPointer<KIO::FileCopyJob> m_tempCopyJob;
};

@ -313,7 +313,7 @@ QVariantList IconModule::previewIcons(const QString &themeName, int size, qreal
{QStringLiteral("folder-video"), QStringLiteral("folder-videos")}};
// created on-demand as it is quite expensive to do and we don't want to do it every loop iteration either
QScopedPointer<KIconTheme> theme;
std::unique_ptr<KIconTheme> theme;
QVariantList pixmaps;
@ -327,7 +327,7 @@ QVariantList IconModule::previewIcons(const QString &themeName, int size, qreal
theme.reset(new KIconTheme(themeName));
}
pix = getBestIcon(*theme.data(), iconNames, size, dpr);
pix = getBestIcon(*theme.get(), iconNames, size, dpr);
// Inserting a pixmap even if null so we know whether we searched for it already
QPixmapCache::insert(cacheKey, pix);

@ -16,7 +16,6 @@
#include <KQuickAddons/ManagedConfigModule>
#include <QCache>
#include <QScopedPointer>
class KIconTheme;
class IconsSettings;
@ -103,6 +102,6 @@ private:
mutable QCache<QString, KIconTheme> m_kiconThemeCache;
QScopedPointer<QTemporaryFile> m_tempInstallFile;
std::unique_ptr<QTemporaryFile> m_tempInstallFile;
QPointer<KIO::FileCopyJob> m_tempCopyJob;
};

@ -358,9 +358,9 @@ void KCMLookandFeel::save()
// Test if style can be installed before updating the config.
KSharedConfigPtr conf = KSharedConfig::openConfig(package.filePath("defaults"));
KConfigGroup cg(conf, "kdeglobals");
QScopedPointer<QStyle> newStyle(QStyleFactory::create(cg.readEntry("widgetStyle", QString())));
applyFlags.setFlag(LookAndFeelManager::WidgetStyle, (!newStyle.isNull() &&
m_model->data(m_model->index(index, 0), HasWidgetStyleRole).toBool())); //Widget Style isn't in
std::unique_ptr<QStyle> newStyle(QStyleFactory::create(cg.readEntry("widgetStyle", QString())));
applyFlags.setFlag(LookAndFeelManager::WidgetStyle,
(newStyle != nullptr && m_model->data(m_model->index(index, 0), HasWidgetStyleRole).toBool())); // Widget Style isn't in
// the loop above since it has all of this extra checking too for it
}
m_lnf->setAppearanceToApply(applyFlags);

@ -33,7 +33,6 @@
#include <QQuickItem>
#include <QQuickRenderControl>
#include <QQuickWindow>
#include <QScopedPointer>
#include <QStyleFactory>
#include <QWidget>
#include <QWindow>
@ -272,7 +271,7 @@ void KCMStyle::save()
// Otherwise apps will use the default style despite something else having been written to the config
bool newStyleLoaded = false;
if (styleSettings()->widgetStyle() != m_previousStyle) {
QScopedPointer<QStyle> newStyle(QStyleFactory::create(styleSettings()->widgetStyle()));
std::unique_ptr<QStyle> newStyle(QStyleFactory::create(styleSettings()->widgetStyle()));
if (newStyle) {
newStyleLoaded = true;
m_previousStyle = styleSettings()->widgetStyle();

@ -44,7 +44,7 @@ void PreviewItem::componentComplete()
bool PreviewItem::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_widget.data()) {
if (watched == m_widget.get()) {
switch (event->type()) {
case QEvent::Show:
case QEvent::UpdateRequest:
@ -118,7 +118,7 @@ void PreviewItem::reload()
// Do not wait for this widget to close before the app closes
m_widget->setAttribute(Qt::WA_QuitOnClose, false);
m_ui.setupUi(m_widget.data());
m_ui.setupUi(m_widget.get());
// Prevent Qt from wrongly caching radio button images
QPixmapCache::clear();
@ -136,7 +136,7 @@ void PreviewItem::reload()
palette.setColor(QPalette::Inactive, role, palette.color(QPalette::Active, role));
}
setStyleRecursively(m_widget.data(), m_style.data(), palette);
setStyleRecursively(m_widget.get(), m_style.get(), palette);
m_widget->ensurePolished();
@ -183,13 +183,13 @@ void PreviewItem::sendHoverEvent(QHoverEvent *event)
QPointF pos = event->pos();
QWidget *child = m_widget->childAt(pos.toPoint());
QWidget *receiver = child ? child : m_widget.data();
QWidget *receiver = child ? child : m_widget.get();
dispatchEnterLeave(receiver, m_lastWidgetUnderMouse, mapToGlobal(event->pos()));
m_lastWidgetUnderMouse = receiver;
pos = receiver->mapFrom(m_widget.data(), pos.toPoint());
pos = receiver->mapFrom(m_widget.get(), pos.toPoint());
QMouseEvent mouseEvent(QEvent::MouseMove,
pos,

@ -9,7 +9,6 @@
#include <QPointer>
#include <QQuickPaintedItem>
#include <QScopedPointer>
#include "ui_stylepreview.h"
@ -61,8 +60,8 @@ private:
Ui::StylePreview m_ui;
QScopedPointer<QWidget> m_widget;
std::unique_ptr<QWidget> m_widget;
QPointer<QWidget> m_lastWidgetUnderMouse;
QScopedPointer<QStyle> m_style;
std::unique_ptr<QStyle> m_style;
};

@ -125,11 +125,11 @@ private Q_SLOTS:
QFETCH(QUrl, srcUrl);
QFETCH(QUrl, destUrl);
QScopedPointer<KDirLister> lister(nullptr);
std::unique_ptr<KDirLister> lister;
if (withDirListerCache) {
lister.reset(new KDirLister);
lister->openUrl(QUrl(QStringLiteral("desktop:/")));
QSignalSpy spyCompleted(lister.data(), static_cast<void (KDirLister::*)()>(&KDirLister::completed));
QSignalSpy spyCompleted(lister.get(), static_cast<void (KDirLister::*)()>(&KDirLister::completed));
spyCompleted.wait();
}

@ -26,8 +26,8 @@ private Q_SLOTS:
void HistoryModelTest::testSetMaxSize()
{
QScopedPointer<HistoryModel> history(new HistoryModel(nullptr));
QScopedPointer<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.data()));
std::unique_ptr<HistoryModel> history(new HistoryModel(nullptr));
std::unique_ptr<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.get()));
QCOMPARE(history->rowCount(), 0);
QCOMPARE(history->maxSize(), 0);
@ -64,8 +64,8 @@ void HistoryModelTest::testSetMaxSize()
void HistoryModelTest::testInsertRemove()
{
QScopedPointer<HistoryModel> history(new HistoryModel(nullptr));
QScopedPointer<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.data()));
std::unique_ptr<HistoryModel> history(new HistoryModel(nullptr));
std::unique_ptr<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.get()));
history->setMaxSize(10);
QCOMPARE(history->rowCount(), 0);
@ -165,8 +165,8 @@ void HistoryModelTest::testInsertRemove()
void HistoryModelTest::testClear()
{
QScopedPointer<HistoryModel> history(new HistoryModel(nullptr));
QScopedPointer<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.data()));
std::unique_ptr<HistoryModel> history(new HistoryModel(nullptr));
std::unique_ptr<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.get()));
history->setMaxSize(10);
QCOMPARE(history->rowCount(), 0);
@ -187,8 +187,8 @@ void HistoryModelTest::testClear()
void HistoryModelTest::testIndexOf()
{
QScopedPointer<HistoryModel> history(new HistoryModel(nullptr));
QScopedPointer<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.data()));
std::unique_ptr<HistoryModel> history(new HistoryModel(nullptr));
std::unique_ptr<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.get()));
history->setMaxSize(10);
QCOMPARE(history->rowCount(), 0);
QVERIFY(!history->indexOf(QByteArrayLiteral("whatever")).isValid());
@ -221,8 +221,8 @@ void HistoryModelTest::testType_data()
void HistoryModelTest::testType()
{
QScopedPointer<HistoryModel> history(new HistoryModel(nullptr));
QScopedPointer<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.data()));
std::unique_ptr<HistoryModel> history(new HistoryModel(nullptr));
std::unique_ptr<QAbstractItemModelTester> modelTest(new QAbstractItemModelTester(history.get()));
history->setMaxSize(10);
QCOMPARE(history->rowCount(), 0);

@ -24,9 +24,9 @@ private Q_SLOTS:
void HistoryTest::testSetMaxSize()
{
QScopedPointer<History> history(new History(nullptr));
QSignalSpy changedSpy(history.data(), &History::changed);
QSignalSpy topSpy(history.data(), &History::topChanged);
std::unique_ptr<History> history(new History(nullptr));
QSignalSpy changedSpy(history.get(), &History::changed);
QSignalSpy topSpy(history.get(), &History::topChanged);
QVERIFY(history->empty());
QCOMPARE(history->maxSize(), 0u);
QVERIFY(changedSpy.isEmpty());
@ -73,9 +73,9 @@ void HistoryTest::testSetMaxSize()
void HistoryTest::testInsertRemove()
{
QScopedPointer<History> history(new History(nullptr));
QSignalSpy topSpy(history.data(), &History::topChanged);
QSignalSpy topUserSelectedSpy(history.data(), &History::topIsUserSelectedSet);
std::unique_ptr<History> history(new History(nullptr));
QSignalSpy topSpy(history.get(), &History::topChanged);
QSignalSpy topUserSelectedSpy(history.get(), &History::topIsUserSelectedSet);
history->setMaxSize(10);
QVERIFY(history->empty());
@ -198,7 +198,7 @@ void HistoryTest::testInsertRemove()
void HistoryTest::testClear()
{
QScopedPointer<History> history(new History(nullptr));
std::unique_ptr<History> history(new History(nullptr));
history->setMaxSize(10);
QVERIFY(history->empty());
QVERIFY(!history->topIsUserSelected());
@ -216,7 +216,7 @@ void HistoryTest::testClear()
QVERIFY(history->first());
// and clear
QSignalSpy topSpy(history.data(), &History::topChanged);
QSignalSpy topSpy(history.get(), &History::topChanged);
QVERIFY(topSpy.isEmpty());
history->slotClear();
QVERIFY(history->empty());
@ -227,7 +227,7 @@ void HistoryTest::testClear()
void HistoryTest::testFind()
{
QScopedPointer<History> history(new History(nullptr));
std::unique_ptr<History> history(new History(nullptr));
history->setMaxSize(10);
QVERIFY(history->empty());
QVERIFY(!history->find(QByteArrayLiteral("whatever")));
@ -246,8 +246,8 @@ void HistoryTest::testFind()
void HistoryTest::testCycle()
{
QScopedPointer<History> history(new History(nullptr));
QSignalSpy topSpy(history.data(), &History::topChanged);
std::unique_ptr<History> history(new History(nullptr));
QSignalSpy topSpy(history.get(), &History::topChanged);
history->setMaxSize(10);
QVERIFY(!history->nextInCycle());
QVERIFY(!history->prevInCycle());

@ -38,6 +38,7 @@
#include <KWayland/Client/surface.h>
#include <KWindowSystem>
#include "../c_ptr.h"
#include "configdialog.h"
#include "history.h"
#include "historyitem.h"
@ -721,8 +722,8 @@ bool Klipper::blockFetchingNewData()
}
xcb_connection_t *c = QX11Info::connection();
const xcb_query_pointer_cookie_t cookie = xcb_query_pointer_unchecked(c, QX11Info::appRootWindow());
QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter> queryPointer(xcb_query_pointer_reply(c, cookie, nullptr));
if (queryPointer.isNull()) {
UniqueCPointer<xcb_query_pointer_reply_t> queryPointer(xcb_query_pointer_reply(c, cookie, nullptr));
if (!queryPointer) {
return false;
}
if (((queryPointer->mask & (XCB_KEY_BUT_MASK_SHIFT | XCB_KEY_BUT_MASK_BUTTON_1)) == XCB_KEY_BUT_MASK_SHIFT) // BUG: 85198
@ -989,7 +990,7 @@ protected:
}
private:
QScopedPointer<Prison::AbstractBarcode> m_barcode;
std::unique_ptr<Prison::AbstractBarcode> m_barcode;
};
void Klipper::showBarcode(const QSharedPointer<const HistoryItem> &item)

@ -10,7 +10,6 @@
#include <QDateTime>
#include <QImage>
#include <QList>
#include <QScopedPointer>
#include <QString>
#include <QUrl>

@ -67,7 +67,7 @@ ServerInfo *ServerPrivate::currentOwner() const
m_currentOwner.reset(new ServerInfo());
}
return m_currentOwner.data();
return m_currentOwner.get();
}
bool ServerPrivate::init()

@ -10,6 +10,7 @@
#include <QObject>
#include <QSet>
#include <QStringList>
#include <memory>
#include "notification.h"
@ -115,7 +116,7 @@ private:
bool m_dbusObjectValid = false;
mutable QScopedPointer<ServerInfo> m_currentOwner;
mutable std::unique_ptr<ServerInfo> m_currentOwner;
QDBusServiceWatcher *m_inhibitionWatcher = nullptr;
QDBusServiceWatcher *m_notificationWatchers = nullptr;

@ -93,7 +93,7 @@ void PipeWireSourceItem::itemChange(QQuickItem::ItemChange change, const QQuickI
void PipeWireSourceItem::releaseResources()
{
if (window()) {
window()->scheduleRenderJob(new DiscardEglPixmapRunnable(m_image, m_texture.take()), QQuickWindow::NoStage);
window()->scheduleRenderJob(new DiscardEglPixmapRunnable(m_image, m_texture.release()), QQuickWindow::NoStage);
m_image = EGL_NO_IMAGE_KHR;
}
}
@ -121,8 +121,8 @@ void PipeWireSourceItem::setNodeId(uint nodeId)
}
m_stream->setActive(isVisible() && isComponentComplete());
connect(m_stream.data(), &PipeWireSourceStream::dmabufTextureReceived, this, &PipeWireSourceItem::updateTextureDmaBuf);
connect(m_stream.data(), &PipeWireSourceStream::imageTextureReceived, this, &PipeWireSourceItem::updateTextureImage);
connect(m_stream.get(), &PipeWireSourceStream::dmabufTextureReceived, this, &PipeWireSourceItem::updateTextureDmaBuf);
connect(m_stream.get(), &PipeWireSourceStream::imageTextureReceived, this, &PipeWireSourceItem::updateTextureImage);
}
Q_EMIT nodeIdChanged(nodeId);

@ -52,8 +52,8 @@ private:
uint m_nodeId = 0;
std::function<QSGTexture *()> m_createNextTexture;
QScopedPointer<PipeWireSourceStream> m_stream;
QScopedPointer<QOpenGLTexture> m_texture;
std::unique_ptr<PipeWireSourceStream> m_stream;
std::unique_ptr<QOpenGLTexture> m_texture;
EGLImage m_image = nullptr;
bool m_needsRecreateTexture = false;

@ -42,7 +42,7 @@ Q_SIGNALS:
private:
friend class Screencasting;
QScopedPointer<ScreencastingStreamPrivate> d;
std::unique_ptr<ScreencastingStreamPrivate> d;
};
class Screencasting : public QObject
@ -73,5 +73,5 @@ Q_SIGNALS:
void sourcesChanged();
private:
QScopedPointer<ScreencastingPrivate> d;
std::unique_ptr<ScreencastingPrivate> d;
};

@ -41,7 +41,7 @@ void TestChromeBookmarks::bookmarkFinderShouldReportNoProfilesOnErrors()
void TestChromeBookmarks::itShouldFindNothingWhenPrepareIsNotCalled()
{
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.data(), this);
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.get(), this);
QCOMPARE(chrome->match("any", true).size(), 0);
}
@ -61,7 +61,7 @@ void verifyMatch(BookmarkMatch &match, const QString &title, const QString &url)
void TestChromeBookmarks::itShouldFindAllBookmarks()
{
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.data(), this);
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.get(), this);
chrome->prepare();
QList<BookmarkMatch> matches = chrome->match("any", true);
QCOMPARE(matches.size(), 3);
@ -72,7 +72,7 @@ void TestChromeBookmarks::itShouldFindAllBookmarks()
void TestChromeBookmarks::itShouldFindOnlyMatches()
{
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.data(), this);
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.get(), this);
chrome->prepare();
QList<BookmarkMatch> matches = chrome->match("other", false);
QCOMPARE(matches.size(), 1);
@ -81,7 +81,7 @@ void TestChromeBookmarks::itShouldFindOnlyMatches()
void TestChromeBookmarks::itShouldClearResultAfterCallingTeardown()
{
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.data(), this);
Chrome *chrome = new Chrome(m_findBookmarksInCurrentDirectory.get(), this);
chrome->prepare();
QCOMPARE(chrome->match("any", true).size(), 3);
chrome->teardown();

@ -10,6 +10,7 @@
#include "browsers/findprofile.h"
#include <QObject>
#include <memory>
class FakeFindProfile : public FindProfile
{
@ -47,6 +48,6 @@ private Q_SLOTS:
void itShouldFindBookmarksFromAllProfiles();
private:
QScopedPointer<FakeFindProfile> m_findBookmarksInCurrentDirectory;
std::unique_ptr<FakeFindProfile> m_findBookmarksInCurrentDirectory;
QString m_configHome;
};

@ -6,6 +6,7 @@
#include <config-plasma.h>
#include "../c_ptr.h"
#include "debug.h"
#include "panelconfigview.h"
#include "panelshadows_p.h"
@ -777,7 +778,7 @@ void PanelView::setAutoHideEnabled(bool enabled)
const QByteArray effectName = QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW");
xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, effectName.length(), effectName.constData());
QScopedPointer<xcb_intern_atom_reply_t, QScopedPointerPodDeleter> atom(xcb_intern_atom_reply(c, atomCookie, nullptr));
UniqueCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply(c, atomCookie, nullptr));
if (!atom) {
return;

@ -1681,9 +1681,9 @@ void ShellCorona::checkAddPanelAction()
} else if (!panelContainmentPlugins.isEmpty()) {
m_addPanelAction = new QAction(this);
m_addPanelsMenu.reset(new QMenu);
m_addPanelAction->setMenu(m_addPanelsMenu.data());
connect(m_addPanelsMenu.data(), &QMenu::aboutToShow, this, &ShellCorona::populateAddPanelsMenu);
connect(m_addPanelsMenu.data(), &QMenu::triggered, this, qOverload<QAction *>(&ShellCorona::addPanel));
m_addPanelAction->setMenu(m_addPanelsMenu.get());
connect(m_addPanelsMenu.get(), &QMenu::aboutToShow, this, &ShellCorona::populateAddPanelsMenu);
connect(m_addPanelsMenu.get(), &QMenu::triggered, this, qOverload<QAction *>(&ShellCorona::addPanel));
}
if (m_addPanelAction) {

@ -13,7 +13,6 @@
#include <QDBusContext>
#include <QDBusVariant>
#include <QScopedPointer>
#include <QSet>
#include <QTimer>
@ -261,7 +260,7 @@ private:
QList<Plasma::Containment *> m_waitingPanels;
QHash<QString, QString> m_activityContainmentPlugins;
QAction *m_addPanelAction;
QScopedPointer<QMenu> m_addPanelsMenu;
std::unique_ptr<QMenu> m_addPanelsMenu;
KPackage::Package m_lookAndFeelPackage;
QTimer m_waitingPanelsTimer;

@ -41,7 +41,7 @@ private:
void autoStart(int phase);
QVector<QProcess *> m_processes;
QScopedPointer<QEventLoopLocker> m_lock;
std::unique_ptr<QEventLoopLocker> m_lock;
static Startup *s_self;
};

@ -58,7 +58,7 @@ int main(int argc, char **argv)
}
setupCursor(false);
QScopedPointer<QProcess, KillBeforeDeleter> ksplash(setupKSplash());
std::unique_ptr<QProcess, KillBeforeDeleter> ksplash(setupKSplash());
runEnvironmentScripts();

@ -656,7 +656,7 @@ bool startPlasmaSession(bool wayland)
// Create .desktop files for the scripts in .config/autostart-scripts
migrateUserScriptsAutostart();
QScopedPointer<QProcess, KillBeforeDeleter> startPlasmaSession;
std::unique_ptr<QProcess, KillBeforeDeleter> startPlasmaSession;
if (!useSystemdBoot()) {
startPlasmaSession.reset(new QProcess);
qCDebug(PLASMA_STARTUP) << "Using classic boot";
@ -671,7 +671,7 @@ bool startPlasmaSession(bool wayland)
}
startPlasmaSession->setProcessChannelMode(QProcess::ForwardedChannels);
QObject::connect(startPlasmaSession.data(), &QProcess::finished, &e, [&rc](int exitCode, QProcess::ExitStatus) {
QObject::connect(startPlasmaSession.get(), &QProcess::finished, &e, [&rc](int exitCode, QProcess::ExitStatus) {
if (exitCode == 255) {
// Startup error
messageBox(QStringLiteral("startkde: Could not start plasma_session. Check your installation.\n"));

@ -41,7 +41,7 @@ void playStartupSound(QObject *parent);
void gentleTermination(QProcess *process);
struct KillBeforeDeleter {
static inline void cleanup(QProcess *pointer)
void operator()(QProcess *pointer)
{
if (pointer) {
gentleTermination(pointer);

@ -24,6 +24,7 @@
#include <xcb/xcb_atom.h>
#include <xcb/xcb_event.h>
#include "../c_ptr.h"
#include "sniproxy.h"
#include "xcbutils.h"
@ -82,10 +83,10 @@ bool FdoSelectionManager::addDamageWatch(xcb_window_t client)
xcb_damage_create(c, damageId, client, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY);
xcb_generic_error_t *error = nullptr;
QScopedPointer<xcb_get_window_attributes_reply_t, QScopedPointerPodDeleter> attr(xcb_get_window_attributes_reply(c, attribsCookie, &error));
QScopedPointer<xcb_generic_error_t, QScopedPointerPodDeleter> getAttrError(error);
UniqueCPointer<xcb_get_window_attributes_reply_t> attr(xcb_get_window_attributes_reply(c, attribsCookie, &error));
UniqueCPointer<xcb_generic_error_t> getAttrError(error);
uint32_t events = XCB_EVENT_MASK_STRUCTURE_NOTIFY;
if (!attr.isNull()) {
if (attr) {
events = events | attr->your_event_mask;
}
// if window is already gone, there is no need to handle it.
@ -95,7 +96,7 @@ bool FdoSelectionManager::addDamageWatch(xcb_window_t client)
// the event mask will not be removed again. We cannot track whether another component also needs STRUCTURE_NOTIFY (e.g. KWindowSystem).
// if we would remove the event mask again, other areas will break.
const auto changeAttrCookie = xcb_change_window_attributes_checked(c, client, XCB_CW_EVENT_MASK, &events);
QScopedPointer<xcb_generic_error_t, QScopedPointerPodDeleter> changeAttrError(xcb_request_check(c, changeAttrCookie));
UniqueCPointer<xcb_generic_error_t> changeAttrError(xcb_request_check(c, changeAttrCookie));
// if window is gone by this point, it will be caught by eventFilter, so no need to check later errors.
if (changeAttrError && changeAttrError->error_code == XCB_WINDOW) {
return false;

@ -32,6 +32,7 @@
#include "statusnotifieritemadaptor.h"
#include "statusnotifierwatcher_interface.h"
#include "../c_ptr.h"
#include "xtestsender.h"
//#define VISUAL_DEBUG
@ -169,7 +170,7 @@ SNIProxy::SNIProxy(xcb_window_t wid, QObject *parent)
// we query if the client selected button presses in the event mask
// if the client does supports that we send directly, otherwise we'll use xtest
auto waCookie = xcb_get_window_attributes(c, wid);
QScopedPointer<xcb_get_window_attributes_reply_t, QScopedPointerPodDeleter> windowAttributes(xcb_get_window_attributes_reply(c, waCookie, nullptr));
UniqueCPointer<xcb_get_window_attributes_reply_t> windowAttributes(xcb_get_window_attributes_reply(c, waCookie, nullptr));
if (windowAttributes && !(windowAttributes->all_event_masks & XCB_EVENT_MASK_BUTTON_PRESS)) {
m_injectMode = XTest;
}
@ -234,7 +235,7 @@ QSize SNIProxy::calculateClientWindowSize() const
auto c = QX11Info::connection();
auto cookie = xcb_get_geometry(c, m_windowId);
QScopedPointer<xcb_get_geometry_reply_t, QScopedPointerPodDeleter> clientGeom(xcb_get_geometry_reply(c, cookie, nullptr));
UniqueCPointer<xcb_get_geometry_reply_t> clientGeom(xcb_get_geometry_reply(c, cookie, nullptr));
QSize clientWindowSize;
if (clientGeom) {
@ -391,8 +392,8 @@ QPoint SNIProxy::calculateClickPoint() const
// at the same time make the request for rectangles (even if this request isn't needed)
xcb_shape_get_rectangles_cookie_t rectaglesCookie = xcb_shape_get_rectangles(c, m_windowId, XCB_SHAPE_SK_BOUNDING);
QScopedPointer<xcb_shape_query_extents_reply_t, QScopedPointerPodDeleter> extentsReply(xcb_shape_query_extents_reply(c, extentsCookie, nullptr));
QScopedPointer<xcb_shape_get_rectangles_reply_t, QScopedPointerPodDeleter> rectanglesReply(xcb_shape_get_rectangles_reply(c, rectaglesCookie, nullptr));
UniqueCPointer<xcb_shape_query_extents_reply_t> extentsReply(xcb_shape_query_extents_reply(c, extentsCookie, nullptr));
UniqueCPointer<xcb_shape_get_rectangles_reply_t> rectanglesReply(xcb_shape_get_rectangles_reply(c, rectaglesCookie, nullptr));
if (!extentsReply || !rectanglesReply || !extentsReply->bounding_shaped) {
return clickPoint;
@ -512,14 +513,14 @@ void SNIProxy::sendClick(uint8_t mouseButton, int x, int y)
auto c = QX11Info::connection();
auto cookieSize = xcb_get_geometry(c, m_windowId);
QScopedPointer<xcb_get_geometry_reply_t, QScopedPointerPodDeleter> clientGeom(xcb_get_geometry_reply(c, cookieSize, nullptr));
UniqueCPointer<xcb_get_geometry_reply_t> clientGeom(xcb_get_geometry_reply(c, cookieSize, nullptr));
if (!clientGeom) {
return;
}
auto cookie = xcb_query_pointer(c, m_windowId);
QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter> pointer(xcb_query_pointer_reply(c, cookie, nullptr));
UniqueCPointer<xcb_query_pointer_reply_t> pointer(xcb_query_pointer_reply(c, cookie, nullptr));
/*qCDebug(SNIPROXY) << "samescreen" << pointer->same_screen << endl
<< "root x*y" << pointer->root_x << pointer->root_y << endl
<< "win x*y" << pointer->win_x << pointer->win_y;*/

@ -15,7 +15,6 @@
#include <xcb/xcb_atom.h>
#include <xcb/xcb_event.h>
#include <QScopedPointer>
#include <QVector>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <private/qtx11extras_p.h>
@ -23,6 +22,8 @@
#include <QX11Info>
#endif
#include "../c_ptr.h"
/** XEMBED messages */
#define XEMBED_EMBEDDED_NOTIFY 0
#define XEMBED_WINDOW_ACTIVATE 1
@ -37,9 +38,6 @@ namespace Xcb
{
typedef xcb_window_t WindowId;
template<typename T>
using ScopedCPointer = QScopedPointer<T, QScopedPointerPodDeleter>;
class Atom
{
public:
@ -88,8 +86,8 @@ private:
if (m_retrieved || !m_cookie.sequence) {
return;
}
ScopedCPointer<xcb_intern_atom_reply_t> reply(xcb_intern_atom_reply(m_connection, m_cookie, nullptr));
if (!reply.isNull()) {
UniqueCPointer<xcb_intern_atom_reply_t> reply(xcb_intern_atom_reply(m_connection, m_cookie, nullptr));
if (reply) {
m_atom = reply->atom;
}
m_retrieved = true;

Loading…
Cancel
Save