mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #642 from kiwix/deadlock_in_Library_writeBookmarksToFile
This commit is contained in:
commit
27414f7731
|
@ -274,11 +274,8 @@ bool Library::writeToFile(const std::string& path) const
|
||||||
bool Library::writeBookmarksToFile(const std::string& path) const
|
bool Library::writeBookmarksToFile(const std::string& path) const
|
||||||
{
|
{
|
||||||
LibXMLDumper dumper(this);
|
LibXMLDumper dumper(this);
|
||||||
std::string xml;
|
// NOTE: LibXMLDumper::dumpLibXMLBookmark uses Library in a thread-safe way
|
||||||
{
|
const std::string xml = dumper.dumpLibXMLBookmark();
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
|
||||||
xml = dumper.dumpLibXMLBookmark();
|
|
||||||
};
|
|
||||||
return writeTextFile(path, xml);
|
return writeTextFile(path, xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ void LibXMLDumper::handleBookmark(Bookmark bookmark, pugi::xml_node root_node) {
|
||||||
auto book_node = entry_node.append_child("book");
|
auto book_node = entry_node.append_child("book");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto book = library->getBookById(bookmark.getBookId());
|
auto book = library->getBookByIdThreadSafe(bookmark.getBookId());
|
||||||
ADD_TEXT_ENTRY(book_node, "id", book.getId());
|
ADD_TEXT_ENTRY(book_node, "id", book.getId());
|
||||||
ADD_TEXT_ENTRY(book_node, "title", book.getTitle());
|
ADD_TEXT_ENTRY(book_node, "title", book.getTitle());
|
||||||
ADD_TEXT_ENTRY(book_node, "language", book.getLanguage());
|
ADD_TEXT_ENTRY(book_node, "language", book.getLanguage());
|
||||||
|
|
Loading…
Reference in New Issue