Skip to content

Commit e87feff

Browse files
authored
Merge pull request #83 from sorryforthecommit/get_html_source_leak
Fix memory leak in get_html_source (thanks @mreitinger for patch)
2 parents fc8783b + 1e6a27c commit e87feff

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/WWW/WebKit2/Inspector.pm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,20 @@ sub get_body_text {
106106
sub get_html_source {
107107
my ($self) = @_;
108108

109-
my $html_source;
110109
my $resource = $self->view->get_main_resource();
111-
my $done = 0;
112110

113111
return '' unless $resource;
114112

115-
$resource->get_data(undef, sub {
116-
my ($resource, $result, $user_data) = @_;
113+
my $result;
117114

118-
$html_source = $resource->get_data_finish($result);
119-
$done = 1;
115+
$resource->get_data(undef, sub {
116+
$result = $_[1]; #store GAsyncResult, used for the _finish call later
120117
}, undef);
121118

122-
Gtk3::main_iteration while Gtk3::events_pending or not $done;
119+
#wait for the callback to fire
120+
Gtk3::main_iteration while Gtk3::events_pending or not defined $result;
121+
122+
my $html_source = $resource->get_data_finish($result);
123123

124124
# get_data_finish returns a byte-array, turn it into a human readable string
125125
my $html_string = decode_utf8(join('', map chr, @$html_source));

0 commit comments

Comments
 (0)