Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/private/PDFViewImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "PDFViewBookmarks.h"
#include "PDFViewTextRange.h"

#include "v8.h"
#include "libplatform/libplatform.h"

class wxPDFViewImpl: public wxPDFViewPagesClient, public wxEvtHandler
{
public:
Expand Down Expand Up @@ -133,7 +136,7 @@ class wxPDFViewImpl: public wxPDFViewPagesClient, public wxEvtHandler

// PDF SDK Structures
static wxAtomicInt ms_pdfSDKRefCount;
static bool ms_v8initialized;
static v8::Platform* ms_platform;
FPDF_FILEACCESS m_pdfFileAccess;
FX_FILEAVAIL m_pdfFileAvail;
FX_DOWNLOADHINTS m_hints;
Expand Down
4 changes: 2 additions & 2 deletions src/PDFViewBookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class wxPDFViewBookmarkImpl: public wxPDFViewBookmark

virtual void Navigate(wxPDFView* pdfView)
{
FPDF_DOCUMENT doc = pdfView->GetImpl()->GetDocument();
FPDF_DOCUMENT doc = static_cast<FPDF_DOCUMENT>(pdfView->GetImpl()->GetDocument());
FPDF_ACTION action = FPDFBookmark_GetAction(m_bookmark);
FPDF_DEST dest = NULL;
if (action)
Expand All @@ -55,7 +55,7 @@ class wxPDFViewBookmarkImpl: public wxPDFViewBookmark
}
if (dest)
{
unsigned long pageIndex = FPDFDest_GetPageIndex(doc, dest);
unsigned long pageIndex = FPDFDest_GetDestPageIndex(doc, dest);
pdfView->GoToPage(pageIndex);
}
}
Expand Down
20 changes: 13 additions & 7 deletions src/PDFViewImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class wxPDFViewActivity
//

wxAtomicInt wxPDFViewImpl::ms_pdfSDKRefCount = 0;
bool wxPDFViewImpl::ms_v8initialized = false;
v8::Platform* wxPDFViewImpl::ms_platform = 0;

wxPDFViewImpl::wxPDFViewImpl(wxPDFView* ctrl):
m_ctrl(ctrl),
Expand Down Expand Up @@ -1317,7 +1317,7 @@ bool wxPDFViewImpl::EvaluateLinkTargetPageAtClientPos(const wxPoint& clientPos,
}

if (dest)
GoToPage(FPDFDest_GetPageIndex(m_pdfDoc, dest));
GoToPage(FPDFDest_GetDestPageIndex(m_pdfDoc, dest));
}
}
else
Expand Down Expand Up @@ -1571,7 +1571,7 @@ bool wxPDFViewImpl::AcquireSDK()
if (ms_pdfSDKRefCount == 0)
{
// Initialize PDF Rendering library
if (!ms_v8initialized)
if (!ms_platform)
{
v8::V8::InitializeICU();

Expand All @@ -1583,16 +1583,14 @@ bool wxPDFViewImpl::AcquireSDK()
wxString resPathStr = resPath.GetFullPath();
v8::V8::InitializeExternalStartupData(resPathStr.c_str());

v8::Platform* platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(platform);
ms_platform = v8::platform::CreateDefaultPlatform();
v8::V8::InitializePlatform(ms_platform);
v8::V8::Initialize();

// By enabling predictable mode, V8 won't post any background tasks.
const char predictable_flag[] = "--predictable";
v8::V8::SetFlagsFromString(predictable_flag,
static_cast<int>(strlen(predictable_flag)));

ms_v8initialized = true;
}

FPDF_LIBRARY_CONFIG config;
Expand All @@ -1613,6 +1611,14 @@ void wxPDFViewImpl::ReleaseSDK()
wxAtomicDec(ms_pdfSDKRefCount);
if (ms_pdfSDKRefCount == 0)
{
if (ms_platform)
{
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete ms_platform;
ms_platform = 0;
}

FPDF_DestroyLibrary();
}
}