mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
More LibraryFactory bug fixes. This thing needs to be rethought.
This commit is contained in:
parent
1deb6cf153
commit
b8f7861917
@ -58,19 +58,7 @@ LibraryFactory& LibraryFactory::Instance() {
|
||||
};
|
||||
|
||||
LibraryFactory::LibraryFactory() {
|
||||
auto prefs = Preferences::ForComponent(prefs::components::Libraries);
|
||||
std::vector<std::string> libraries;
|
||||
prefs->GetKeys(libraries);
|
||||
|
||||
for (size_t i = 0; i < libraries.size(); i++) {
|
||||
std::string name = libraries.at(i);
|
||||
int id = prefs->GetInt(name);
|
||||
this->AddLibrary(id, LibraryType::Local, name);
|
||||
}
|
||||
|
||||
if (this->libraries.empty()) {
|
||||
this->CreateLibrary("Local Library", LibraryType::Local);
|
||||
}
|
||||
this->CreateLibrary("Local Library", LibraryType::Local);
|
||||
}
|
||||
|
||||
LibraryFactory::~LibraryFactory() {
|
||||
@ -129,7 +117,10 @@ ILibraryPtr LibraryFactory::CreateLibrary(const std::string& name, LibraryType t
|
||||
}
|
||||
|
||||
if (existingId != -1) {
|
||||
return this->GetLibrary(existingId);
|
||||
auto library = this->GetLibrary(existingId);
|
||||
if (!library) {
|
||||
return this->AddLibrary(existingId, type, name);
|
||||
}
|
||||
}
|
||||
|
||||
++nextId; /* unique */
|
||||
|
Loading…
x
Reference in New Issue
Block a user