mod: convert remaining manual render locks to RAII RenderLock
Replace xSemaphoreTake/Give(renderingMutex) with scoped RenderLock in EpubReaderActivity popup rendering (bookmark added/removed, dictionary cache deleted). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -477,10 +477,11 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
BookmarkStore::addBookmark(epub->getCachePath(), currentSpineIndex, page, snippet);
|
BookmarkStore::addBookmark(epub->getCachePath(), currentSpineIndex, page, snippet);
|
||||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
{
|
||||||
|
RenderLock lock(*this);
|
||||||
GUI.drawPopup(renderer, tr(STR_BOOKMARK_ADDED));
|
GUI.drawPopup(renderer, tr(STR_BOOKMARK_ADDED));
|
||||||
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
||||||
xSemaphoreGive(renderingMutex);
|
}
|
||||||
vTaskDelay(750 / portTICK_PERIOD_MS);
|
vTaskDelay(750 / portTICK_PERIOD_MS);
|
||||||
// Exit the menu and return to reading — the bookmark indicator will show on re-render,
|
// Exit the menu and return to reading — the bookmark indicator will show on re-render,
|
||||||
// and next menu open will reflect the updated state.
|
// and next menu open will reflect the updated state.
|
||||||
@@ -492,10 +493,11 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
|
|||||||
case EpubReaderMenuActivity::MenuAction::REMOVE_BOOKMARK: {
|
case EpubReaderMenuActivity::MenuAction::REMOVE_BOOKMARK: {
|
||||||
const int page = section ? section->currentPage : 0;
|
const int page = section ? section->currentPage : 0;
|
||||||
BookmarkStore::removeBookmark(epub->getCachePath(), currentSpineIndex, page);
|
BookmarkStore::removeBookmark(epub->getCachePath(), currentSpineIndex, page);
|
||||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
{
|
||||||
|
RenderLock lock(*this);
|
||||||
GUI.drawPopup(renderer, tr(STR_BOOKMARK_REMOVED));
|
GUI.drawPopup(renderer, tr(STR_BOOKMARK_REMOVED));
|
||||||
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
||||||
xSemaphoreGive(renderingMutex);
|
}
|
||||||
vTaskDelay(750 / portTICK_PERIOD_MS);
|
vTaskDelay(750 / portTICK_PERIOD_MS);
|
||||||
exitActivity();
|
exitActivity();
|
||||||
pagesUntilFullRefresh = 1;
|
pagesUntilFullRefresh = 1;
|
||||||
@@ -564,15 +566,17 @@ void EpubReaderActivity::onReaderMenuConfirm(EpubReaderMenuActivity::MenuAction
|
|||||||
case EpubReaderMenuActivity::MenuAction::DELETE_DICT_CACHE: {
|
case EpubReaderMenuActivity::MenuAction::DELETE_DICT_CACHE: {
|
||||||
if (Dictionary::cacheExists()) {
|
if (Dictionary::cacheExists()) {
|
||||||
Dictionary::deleteCache();
|
Dictionary::deleteCache();
|
||||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
{
|
||||||
|
RenderLock lock(*this);
|
||||||
GUI.drawPopup(renderer, tr(STR_DICT_CACHE_DELETED));
|
GUI.drawPopup(renderer, tr(STR_DICT_CACHE_DELETED));
|
||||||
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
||||||
xSemaphoreGive(renderingMutex);
|
}
|
||||||
} else {
|
} else {
|
||||||
xSemaphoreTake(renderingMutex, portMAX_DELAY);
|
{
|
||||||
|
RenderLock lock(*this);
|
||||||
GUI.drawPopup(renderer, tr(STR_NO_CACHE_TO_DELETE));
|
GUI.drawPopup(renderer, tr(STR_NO_CACHE_TO_DELETE));
|
||||||
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
renderer.displayBuffer(HalDisplay::FAST_REFRESH);
|
||||||
xSemaphoreGive(renderingMutex);
|
}
|
||||||
}
|
}
|
||||||
vTaskDelay(1500 / portTICK_PERIOD_MS);
|
vTaskDelay(1500 / portTICK_PERIOD_MS);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user