Qt: Handle invalid libraries

This commit is contained in:
Vicki Pfau 2017-02-11 15:45:08 -08:00
parent 50defa2ecd
commit 012f0a3329
1 changed files with 9 additions and 2 deletions

View File

@ -89,7 +89,12 @@ LibraryModel::LibraryModel(const QString& path, QObject* parent)
m_library->ref();
} else {
m_library = new LibraryHandle(mLibraryLoad(path.toUtf8().constData()), path);
s_handles[path] = m_library;
if (m_library->library) {
s_handles[path] = m_library;
} else {
delete m_library;
m_library = new LibraryHandle(mLibraryCreateEmpty());
}
}
} else {
m_library = new LibraryHandle(mLibraryCreateEmpty());
@ -280,7 +285,9 @@ LibraryModel::LibraryHandle::LibraryHandle(mLibrary* lib, const QString& p)
LibraryModel::LibraryHandle::~LibraryHandle() {
m_loaderThread.quit();
m_loaderThread.wait();
mLibraryDestroy(library);
if (library) {
mLibraryDestroy(library);
}
}
void LibraryModel::LibraryHandle::ref() {