Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95944875 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Syncronize pdfium initialization between users." into nyc-dev

parents 25459e13 be2e7121
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -51,22 +51,22 @@ static struct {
    jfieldID bottom;
} gRectClassInfo;

static Mutex sLock;

static int sUnmatchedInitRequestCount = 0;
// Also used in PdfRenderer.cpp
Mutex sPdfiumLock;
int sUnmatchedPdfiumInitRequestCount = 0;

static void initializeLibraryIfNeeded() {
    Mutex::Autolock _l(sLock);
    if (sUnmatchedInitRequestCount == 0) {
    Mutex::Autolock _l(sPdfiumLock);
    if (sUnmatchedPdfiumInitRequestCount == 0) {
        FPDF_InitLibrary();
    }
    sUnmatchedInitRequestCount++;
    sUnmatchedPdfiumInitRequestCount++;
}

static void destroyLibraryIfNeeded() {
    Mutex::Autolock _l(sLock);
    sUnmatchedInitRequestCount--;
    if (sUnmatchedInitRequestCount == 0) {
    Mutex::Autolock _l(sPdfiumLock);
    sUnmatchedPdfiumInitRequestCount--;
    if (sUnmatchedPdfiumInitRequestCount == 0) {
       FPDF_DestroyLibrary();
    }
}
+9 −9
Original line number Diff line number Diff line
@@ -43,22 +43,22 @@ static struct {
    jfieldID y;
} gPointClassInfo;

static Mutex sLock;

static int sUnmatchedInitRequestCount = 0;
// See PdfEditor.cpp
extern Mutex sPdfiumLock;
extern int sUnmatchedPdfiumInitRequestCount;

static void initializeLibraryIfNeeded() {
    Mutex::Autolock _l(sLock);
    if (sUnmatchedInitRequestCount == 0) {
    Mutex::Autolock _l(sPdfiumLock);
    if (sUnmatchedPdfiumInitRequestCount == 0) {
        FPDF_InitLibrary();
    }
    sUnmatchedInitRequestCount++;
    sUnmatchedPdfiumInitRequestCount++;
}

static void destroyLibraryIfNeeded() {
    Mutex::Autolock _l(sLock);
    sUnmatchedInitRequestCount--;
    if (sUnmatchedInitRequestCount == 0) {
    Mutex::Autolock _l(sPdfiumLock);
    sUnmatchedPdfiumInitRequestCount--;
    if (sUnmatchedPdfiumInitRequestCount == 0) {
       FPDF_DestroyLibrary();
    }
}