[Lazarus] For issue #31638 (gtk2 function that require free mem)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] For issue #31638 (gtk2 function that require free mem)

Free Pascal - Lazarus mailing list
+      if Assigned(Path) then
+      begin
+        AStr := gtk_tree_path_to_string(path);
+        AIsSet := (StrToInt(AStr) = AIndex);
+        if AStr <> nil then
+          g_free(AStr);
+        if Path <> nil then
+          gtk_tree_path_free(Path);
+        Result := True;
+      end;

1- not need in last check "if Path<>nil", checked before
2- better StrToIntDef(AStr, -1) to not give exception
(cannot comment there.)

Alexey
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] For issue #31638 (gtk2 function that require free mem)

Free Pascal - Lazarus mailing list
On Thu, 20 Apr 2017 07:47:29 +0300
Alexey via Lazarus <[hidden email]> wrote:

> +      if Assigned(Path) then
> +      begin
> +        AStr := gtk_tree_path_to_string(path);
> +        AIsSet := (StrToInt(AStr) = AIndex);
> +        if AStr <> nil then
> +          g_free(AStr);
> +        if Path <> nil then
> +          gtk_tree_path_free(Path);
> +        Result := True;
> +      end;
>
> 1- not need in last check "if Path<>nil", checked before
> 2- better StrToIntDef(AStr, -1) to not give exception
> (cannot comment there.)

Done. Thanks for the hint.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus