Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDFReader hold resource issue #276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
11 changes: 11 additions & 0 deletions src/PDFReaderDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void PDFReaderDriver::Init()
t->SetClassName(NEW_STRING("PDFReader"));
t->InstanceTemplate()->SetInternalFieldCount(1);

SET_PROTOTYPE_METHOD(t, "end", End);
SET_PROTOTYPE_METHOD(t, "getPDFLevel", GetPDFLevel);
SET_PROTOTYPE_METHOD(t, "getPagesCount", GetPagesCount);
SET_PROTOTYPE_METHOD(t, "getTrailer", GetTrailer);
Expand Down Expand Up @@ -129,6 +130,16 @@ METHOD_RETURN_TYPE PDFReaderDriver::New(const ARGS_TYPE& args)

SET_FUNCTION_RETURN_VALUE(args.This())
}
METHOD_RETURN_TYPE PDFReaderDriver::End(const ARGS_TYPE& args)
{
CREATE_ISOLATE_CONTEXT;
CREATE_ESCAPABLE_SCOPE;

PDFReaderDriver* reader = ObjectWrap::Unwrap<PDFReaderDriver>(args.This());
if (reader->mPDFReader->GetParserStream())
delete reader->mPDFReader->GetParserStream();
SET_FUNCTION_RETURN_VALUE(args.This());
}

METHOD_RETURN_TYPE PDFReaderDriver::GetPDFLevel(const ARGS_TYPE& args)
{
Expand Down
1 change: 1 addition & 0 deletions src/PDFReaderDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PDFReaderDriver : public node::ObjectWrap
static v8::Persistent<v8::FunctionTemplate> constructor_template;
static METHOD_RETURN_TYPE New(const ARGS_TYPE& args);
static METHOD_RETURN_TYPE GetPDFLevel(const ARGS_TYPE& args);
static METHOD_RETURN_TYPE End(const ARGS_TYPE& args);
static METHOD_RETURN_TYPE GetPagesCount(const ARGS_TYPE& args);
static METHOD_RETURN_TYPE QueryDictionaryObject(const ARGS_TYPE& args);
static METHOD_RETURN_TYPE QueryArrayObject(const ARGS_TYPE& args);
Expand Down