MCPcopy Create free account
hub / github.com/KDE/okular / requestDone

Method requestDone

core/document.cpp:5518–5596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5516}
5517
5518void DocumentPrivate::requestDone(PixmapRequest *req)
5519{
5520 if (!req) {
5521 return;
5522 }
5523
5524 if (!m_generator || m_closingLoop) {
5525 m_pixmapRequestsMutex.lock();
5526 m_executingPixmapRequests.remove(req);
5527 m_pixmapRequestsMutex.unlock();
5528
5529 delete req;
5530 req = nullptr;
5531
5532 if (m_closingLoop) {
5533 m_closingLoop->exit();
5534 }
5535 return;
5536 }
5537
5538#ifndef NDEBUG
5539 if (!m_generator->canGeneratePixmap()) {
5540 qCDebug(OkularCoreDebug) << "requestDone with generator not in READY state.";
5541 }
5542#endif
5543
5544 if (!req->shouldAbortRender()) {
5545 // [MEM] 1.1 find and remove a previous entry for the same page and id
5546 auto it = std::ranges::find_if(m_allocatedPixmaps, [&](AllocatedPixmap *const p) { //
5547 return p->page == req->pageNumber() && p->observer == req->observer();
5548 });
5549 if (it != m_allocatedPixmaps.end()) {
5550 AllocatedPixmap *p = *it;
5551 m_allocatedPixmaps.erase(it);
5552 m_allocatedPixmapsTotalMemory -= p->memory;
5553 delete p;
5554 }
5555
5556 DocumentObserver *observer = req->observer();
5557 if (m_observers.contains(observer)) {
5558 // [MEM] 1.2 append memory allocation descriptor to the FIFO
5559 qulonglong memoryBytes = 0;
5560 const TilesManager *tm = req->d->tilesManager();
5561 if (tm) {
5562 memoryBytes = tm->totalMemory();
5563 } else {
5564 memoryBytes = 4 * qulonglong(req->width()) * req->height();
5565 }
5566
5567 AllocatedPixmap *memoryPage = new AllocatedPixmap(req->observer(), req->pageNumber(), memoryBytes);
5568 m_allocatedPixmaps.push_back(memoryPage);
5569 m_allocatedPixmapsTotalMemory += memoryBytes;
5570
5571 // 2. notify an observer that its pixmap changed
5572 observer->notifyPageChanged(req->pageNumber(), DocumentObserver::Pixmap);
5573 }
5574#ifndef NDEBUG
5575 else {

Callers 1

Calls 11

shouldAbortRenderMethod · 0.80
totalMemoryMethod · 0.80
containsMethod · 0.60
canGeneratePixmapMethod · 0.45
pageNumberMethod · 0.45
observerMethod · 0.45
endMethod · 0.45
tilesManagerMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
notifyPageChangedMethod · 0.45

Tested by

no test coverage detected