mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Fix possible memleaks occuring when passing nonexistent dirs to console library creator. (#132)
This commit is contained in:
parent
868843df37
commit
41ccef1060
@ -12,21 +12,21 @@ ConsoleUILibraryCreator::ConsoleUILibraryCreator(QObject *parent)
|
|||||||
|
|
||||||
void ConsoleUILibraryCreator::createLibrary(const QString &name, const QString &path)
|
void ConsoleUILibraryCreator::createLibrary(const QString &name, const QString &path)
|
||||||
{
|
{
|
||||||
QEventLoop eventLoop;
|
|
||||||
LibraryCreator *libraryCreator = new LibraryCreator();
|
|
||||||
|
|
||||||
QDir pathDir(path);
|
QDir pathDir(path);
|
||||||
if (!pathDir.exists()) {
|
if (!pathDir.exists()) {
|
||||||
std::cout << "Directory not found." << std::endl;
|
std::cout << "Directory not found." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
LibraryCreator *libraryCreator = new LibraryCreator();
|
||||||
QString cleanPath = QDir::cleanPath(pathDir.absolutePath());
|
QString cleanPath = QDir::cleanPath(pathDir.absolutePath());
|
||||||
|
|
||||||
YACReaderLibraries yacreaderLibraries;
|
YACReaderLibraries yacreaderLibraries;
|
||||||
yacreaderLibraries.load();
|
yacreaderLibraries.load();
|
||||||
if (yacreaderLibraries.contains(name)) {
|
if (yacreaderLibraries.contains(name)) {
|
||||||
std::cout << "A Library named \"" << name.toUtf8().constData() << "\" already exists in database." << std::endl;
|
std::cout << "A Library named \"" << name.toUtf8().constData() << "\" already exists in database." << std::endl;
|
||||||
|
delete libraryCreator;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ void ConsoleUILibraryCreator::createLibrary(const QString &name, const QString &
|
|||||||
|
|
||||||
void ConsoleUILibraryCreator::updateLibrary(const QString &path)
|
void ConsoleUILibraryCreator::updateLibrary(const QString &path)
|
||||||
{
|
{
|
||||||
QEventLoop eventLoop;
|
|
||||||
LibraryCreator *libraryCreator = new LibraryCreator();
|
|
||||||
|
|
||||||
QDir pathDir(path);
|
QDir pathDir(path);
|
||||||
if (!pathDir.exists()) {
|
if (!pathDir.exists()) {
|
||||||
std::cout << "Directory not found." << std::endl;
|
std::cout << "Directory not found." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
LibraryCreator *libraryCreator = new LibraryCreator();
|
||||||
QString cleanPath = QDir::cleanPath(pathDir.absolutePath());
|
QString cleanPath = QDir::cleanPath(pathDir.absolutePath());
|
||||||
|
|
||||||
libraryCreator->updateLibrary(cleanPath, QDir::cleanPath(pathDir.absolutePath() + "/.yacreaderlibrary"));
|
libraryCreator->updateLibrary(cleanPath, QDir::cleanPath(pathDir.absolutePath() + "/.yacreaderlibrary"));
|
||||||
|
Loading…
Reference in New Issue
Block a user