Indirect access from ContentManagerModel to ContentManager (via
KiwixApp) contained a race condition that could lead to a crash.
Here is the call chain:
- In KiwixApp::init() the KiwixApp::mp_manager data member is initialized
as follows:
mp_manager = new ContentManager(&m_library, mp_downloader);
- ContentManager's constructor creates the model and the view:
mp_view = new ContentManagerView();
managerModel = new ContentManagerModel(this);
updateModel();
auto treeView = mp_view->getView();
treeView->setModel(managerModel);
treeView->show();
- This starts a cascade of asynchronous events that will eventually
result in ContentManagerModel::sort() being executed. The latter has
to call ContentManager::sortBy() and if it does so indirectly via
`KiwixApp::getContentManager()` before the constructor of
ContentManager has completed (and KiwixApp::mp_manager has been
assigned to) a crash is imminent.
This commit eliminates that issue.
- made the download ring a little darker so that it doesn't become
invisible when highlighted
- changed the background color of the button for the Open/Download actions
(drawn in the last column) from white to transparent so that it
doesn't look ugly on the highlighted line.
Now ContentManagerModel returns for 0th column an icon object that can
be painted by `QStyledItemDelegate::paint()` correctly (albeit in a
slightly less indented position).
As a side-effect of this minor improvement of the design, the thumbnail
column is included in highlighting on mouse hover.
Refactored existing file static function makeHttpUrl to a member function that retrieves the remote library url from the request manager. Will be used for implementing the preview functionality.
Created a ON-OFF action for Bookmark and added in Edit Menu Actions. Assigned shortcut Ctrl + D, which the Donation shortcut is now Ctrl + SHIFT + D. Action disabled for non-Zim tabs
Now that `Library::getArchive()` never returns a null pointer the check
that was added a few commits ago as a fix for a particular manifestation
of a general problem is no longer needed.
Before this change a non-existent download directory would result in
"The system doesn't have enough storage available" error. Trying to save
files to non-writable directory resulted in the download seemingly being
stuck (but this is just a special case of not properly handling the download
error status returned by Aria).
`kiwix::Library::getArchiveById()` returns a `nullptr` when it turns out
that the ZIM file doesn't exist. That function was added in PR #536 and was
never documented, but that is no justification for us to let the
application crash.