Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'avoid_empty_path_warning' into 'master'
[lipstick] Avoid watching an empty directory. Fixes JB#52486

See merge request mer-core/lipstick!170
  • Loading branch information
pvuorela committed Dec 14, 2020
2 parents 67507f8 + c2574f7 commit f97e9c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/components/launcherwatchermodel.cpp
Expand Up @@ -50,7 +50,9 @@ void LauncherWatcherModel::setFilePaths(const QStringList &paths)
m_fileSystemWatcher.removePath(directory);
}

m_fileSystemWatcher.addPaths(directories);
if (directories.length() > 0) {
m_fileSystemWatcher.addPaths(directories);
}

emit filePathsChanged();
}
Expand Down
17 changes: 12 additions & 5 deletions src/notifications/categorydefinitionstore.cpp
Expand Up @@ -16,18 +16,25 @@
#include "categorydefinitionstore.h"
#include <QFileInfo>
#include <QDir>
#include <QDebug>

//! The file extension for the category definition files
static const char *FILE_EXTENSION = ".conf";

//! The maximum size of the category definition file
static const uint FILE_MAX_SIZE = 32768;

CategoryDefinitionStore::CategoryDefinitionStore(const QString &categoryDefinitionsPath, uint maxStoredCategoryDefinitions, QObject *parent) :
QObject(parent),
m_categoryDefinitionsPath(categoryDefinitionsPath),
m_maxStoredCategoryDefinitions(maxStoredCategoryDefinitions)
CategoryDefinitionStore::CategoryDefinitionStore(const QString &categoryDefinitionsPath,
uint maxStoredCategoryDefinitions, QObject *parent)
: QObject(parent),
m_categoryDefinitionsPath(categoryDefinitionsPath),
m_maxStoredCategoryDefinitions(maxStoredCategoryDefinitions)
{
if (m_categoryDefinitionsPath.isEmpty()) {
qWarning() << "CategoryDefinitionStore instantiated without a path";
return;
}

if (!this->m_categoryDefinitionsPath.endsWith('/')) {
this->m_categoryDefinitionsPath.append('/');
}
Expand All @@ -43,7 +50,7 @@ void CategoryDefinitionStore::updateCategoryDefinitionFileList()
{
QDir categoryDefinitionsDir(m_categoryDefinitionsPath);

if(categoryDefinitionsDir.exists()) {
if (categoryDefinitionsDir.exists()) {
QStringList filter("*" + QString(FILE_EXTENSION));

QSet<QString> files = categoryDefinitionsDir.entryList(filter, QDir::Files).toSet();
Expand Down
3 changes: 2 additions & 1 deletion src/notifications/categorydefinitionstore.h
Expand Up @@ -44,7 +44,8 @@ class CategoryDefinitionStore : public QObject
* \param categoryDefinitionsPath The path where the different category definitions are defined
* \param maxStoredCategoryDefinitions The maximum number of category definitions to keep in memory
*/
explicit CategoryDefinitionStore(const QString &categoryDefinitionsPath, uint maxStoredCategoryDefinitions = 100, QObject *parent = 0);
explicit CategoryDefinitionStore(const QString &categoryDefinitionsPath, uint maxStoredCategoryDefinitions = 100,
QObject *parent = 0);

/*!
* Tests if the \a category definition exists in the system.
Expand Down

0 comments on commit f97e9c8

Please sign in to comment.