Merge pull request #1987 from sbeyer/fix-leaks

Fix a few leaks
This commit is contained in:
Kevin Ottens 2020-05-21 17:12:04 +02:00 committed by GitHub
commit 89316ced9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 21 deletions

View file

@ -51,29 +51,28 @@ void CloudProviderManager::registerSignals()
CloudProviderManager::CloudProviderManager(QObject *parent) : QObject(parent)
{
_map = new QMap<QString, CloudProviderWrapper*>();
_folder_index = 0;
g_bus_own_name (G_BUS_TYPE_SESSION, LIBCLOUDPROVIDERS_DBUS_BUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, nullptr, on_name_acquired, nullptr, this, nullptr);
}
void CloudProviderManager::slotFolderListChanged(const Folder::Map &folderMap)
{
QMapIterator<QString, CloudProviderWrapper*> i(*_map);
QMapIterator<QString, CloudProviderWrapper*> i(_map);
while (i.hasNext()) {
i.next();
if (!folderMap.contains(i.key())) {
cloud_providers_provider_exporter_remove_account(_providerExporter, i.value()->accountExporter());
delete _map->find(i.key()).value();
_map->remove(i.key());
delete _map.find(i.key()).value();
_map.remove(i.key());
}
}
Folder::MapIterator j(folderMap);
while (j.hasNext()) {
j.next();
if (!_map->contains(j.key())) {
if (!_map.contains(j.key())) {
auto *cpo = new CloudProviderWrapper(this, j.value(), _folder_index++, _providerExporter);
_map->insert(j.key(), cpo);
_map.insert(j.key(), cpo);
}
}
}

View file

@ -35,7 +35,7 @@ public slots:
void slotFolderListChanged(const Folder::Map &folderMap);
private:
QMap<QString, CloudProviderWrapper*> *_map;
QMap<QString, CloudProviderWrapper*> _map;
unsigned int _folder_index;
};

View file

@ -38,7 +38,6 @@ CloudProviderWrapper::CloudProviderWrapper(QObject *parent, Folder *folder, int
{
GMenuModel *model;
GActionGroup *action_group;
_recentlyChanged = new QList<QPair<QString, QString>>();
QString accountName = QString("Folder/%1").arg(folderId);
_cloudProvider = CLOUD_PROVIDERS_PROVIDER_EXPORTER(cloudprovider);
@ -109,11 +108,11 @@ void CloudProviderWrapper::slotUpdateProgress(const QString &folder, const Progr
if (f) {
QString fullPath = f->path() + '/' + progress._lastCompletedItem._file;
if (QFile(fullPath).exists()) {
if (_recentlyChanged->length() > 5)
_recentlyChanged->removeFirst();
_recentlyChanged->append(qMakePair(actionText, fullPath));
if (_recentlyChanged.length() > 5)
_recentlyChanged.removeFirst();
_recentlyChanged.append(qMakePair(actionText, fullPath));
} else {
_recentlyChanged->append(qMakePair(actionText, QString("")));
_recentlyChanged.append(qMakePair(actionText, QString("")));
}
}
@ -152,9 +151,9 @@ void CloudProviderWrapper::slotUpdateProgress(const QString &folder, const Progr
&& shouldShowInRecentsMenu(progress._lastCompletedItem)) {
GMenuItem* item;
g_menu_remove_all (G_MENU(_recentMenu));
if(!_recentlyChanged->isEmpty()) {
if(!_recentlyChanged.isEmpty()) {
QList<QPair<QString, QString>>::iterator i;
for (i = _recentlyChanged->begin(); i != _recentlyChanged->end(); i++) {
for (i = _recentlyChanged.begin(); i != _recentlyChanged.end(); i++) {
QString label = i->first;
QString fullPath = i->second;
item = menu_item_new(label, "cloudprovider.showfile");

View file

@ -57,7 +57,7 @@ private:
Folder *_folder;
CloudProvidersProviderExporter *_cloudProvider;
CloudProvidersAccountExporter *_cloudProviderAccount;
QList<QPair<QString, QString>> *_recentlyChanged;
QList<QPair<QString, QString>> _recentlyChanged;
bool _paused;
GMenu* _mainMenu = nullptr;
GMenu* _recentMenu = nullptr;

View file

@ -19,10 +19,9 @@
#include "tray/UserModel.h"
#include <QCursor>
#include <QDesktopServices>
#include <QGuiApplication>
#include <QQmlComponent>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QScreen>
#ifdef USE_FDO_NOTIFICATIONS
@ -50,8 +49,8 @@ Systray *Systray::instance()
Systray::Systray()
: _isOpen(false)
, _syncIsPaused(false)
, _trayEngine(new QQmlApplicationEngine(this))
{
_trayEngine = new QQmlApplicationEngine;
_trayEngine->addImportPath("qrc:/qml/theme");
_trayEngine->addImageProvider("avatars", new ImageProvider);
_trayEngine->rootContext()->setContextProperty("userModelBackend", UserModel::instance());

View file

@ -16,12 +16,10 @@
#define SYSTRAY_H
#include <QSystemTrayIcon>
#include <QQmlContext>
#include "accountmanager.h"
#include "tray/UserModel.h"
class QIcon;
class QQmlApplicationEngine;
namespace OCC {

View file

@ -1,7 +1,9 @@
// stub to prevent linker error
#include "accountmanager.h"
OCC::AccountManager *OCC::AccountManager::instance() { return static_cast<AccountManager *>(new QObject); }
Q_GLOBAL_STATIC(QObject, dummy)
OCC::AccountManager *OCC::AccountManager::instance() { return static_cast<AccountManager *>(dummy()); }
void OCC::AccountManager::save(bool) { }
void OCC::AccountManager::saveAccountState(AccountState *) { }
void OCC::AccountManager::deleteAccount(AccountState *) { }