Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-12

g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed

10 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I've created a short
example<https://github.com/ik5/libnotify-fpc/blob/master/tests/test_notify.lpr>to display how to use libnotify in Pascal.
The problem is that I'm getting the following exception:

(process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed
(process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed
(process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed

The text as you can see, is pure "ASCII", so what am I missing or doing wrong here ?

Ido
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/3bf54cfd/attachment.html>

Reply by email

Ludo Brands
to ik

Hello,

I've created a short
<https://github.com/ik5/libnotify-fpc/blob/master/tests/test_notify.lpr> example to display how to use libnotify in Pascal. The problem is that I'm getting the following exception:

(process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed
(process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed
(process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed

The text as you can see, is pure "ASCII", so what am I missing or doing wrong here ?

Ido

Forgot to call gtk_init?

Ludo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/9cb2e8a1/attachment.html>

Reply by email

ik
to Ludo Brands

2011/12/14 Ludo Brands

Show quoted text 24 lines
** Hello, I've created a short example<https://github.com/ik5/libnotify-fpc/blob/master/tests/test_notify.lpr>to display how to use libnotify in Pascal. The problem is that I'm getting the following exception: (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed The text as you can see, is pure "ASCII", so what am I missing or doing wrong here ? Ido Forgot to call gtk_init?

That's create now gibrish as text :(

The original code that I tested was in C:
#include <libnotify/notify.h>
void main () {
  notify_init ("Hello world!");
  NotifyNotification * Hello = notify_notification_new ("Hello world",
"This is an example notification.", "dialog-information");
  notify_notification_show (Hello, NULL);
  notify_uninit ();
}

And after compiling it as follows:
gcc -o notify `pkg-config --cflags --libs libnotify` notify.c

It properly display the text, however the Pascal code does not, even with gtk_init(@argc, @argv) :(

Ludo

Ido

Show quoted text 7 lines
-- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/f8c40010/attachment-0001.html>

Reply by email

Ludo Brands
to ik
Earlier message 66 lines
-----Message d'origine----- De : ik [mailto:] Envoy? : mercredi 14 d?cembre 2011 17:05 ? : Lazarus mailing list Objet : Re: [Lazarus] RE : g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed 2011/12/14 Ludo Brands Hello, I've created a short example <https://github.com/ik5/libnotify-fpc/blob/master/tests/test_notify.lpr> to display how to use libnotify in Pascal. The problem is that I'm getting the following exception: (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed The text as you can see, is pure "ASCII", so what am I missing or doing wrong here ? Ido Forgot to call gtk_init? That's create now gibrish as text :( The original code that I tested was in C: #include <libnotify/notify.h> void main () { notify_init ("Hello world!"); NotifyNotification * Hello = notify_notification_new ("Hello world", "This is an example notification.", "dialog-information"); notify_notification_show (Hello, NULL); notify_uninit (); } And after compiling it as follows: gcc -o notify `pkg-config --cflags --libs libnotify` notify.c It properly display the text, however the Pascal code does not, even with gtk_init(@argc, @argv) :( AFAIK, the use of constref for cdecl parameters is wrong in libnotify.pas. Ludo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/b1f7550e/attachment.html>

Reply by email

ik
to Ludo Brands

2011/12/14 Ludo Brands

Show quoted text 60 lines
** -----Message d'origine----- *De :* ik [mailto:] *Envoy? :* mercredi 14 d?cembre 2011 17:05 *? :* Lazarus mailing list *Objet :* Re: [Lazarus] RE : g_variant_new_string: assertion `g_utf8_validate (string, -1, NULL)' failed 2011/12/14 Ludo Brands > ** > > > > Hello, > > I've created a short example<https://github.com/ik5/libnotify-fpc/blob/master/tests/test_notify.lpr>to display how to use libnotify in Pascal. > The problem is that I'm getting the following exception: > > (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion > `g_utf8_validate (string, -1, NULL)' failed > (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion > `g_utf8_validate (string, -1, NULL)' failed > (process:7633): GLib-CRITICAL **: g_variant_new_string: assertion > `g_utf8_validate (string, -1, NULL)' failed > > The text as you can see, is pure "ASCII", so what am I missing or doing > wrong here ? > > Ido > > > Forgot to call gtk_init? > That's create now gibrish as text :( The original code that I tested was in C: #include <libnotify/notify.h> void main () { notify_init ("Hello world!"); NotifyNotification * Hello = notify_notification_new ("Hello world", "This is an example notification.", "dialog-information"); notify_notification_show (Hello, NULL); notify_uninit (); } And after compiling it as follows: gcc -o notify `pkg-config --cflags --libs libnotify` notify.c It properly display the text, however the Pascal code does not, even with gtk_init(@argc, @argv) :( AFAIK, the use of constref for cdecl parameters is wrong in libnotify.pas.

Indeed that was the problem. So what does constref is used for ?!

Thanks Ludo

Ludo

Ido

Show quoted text 9 lines
-- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/df862155/attachment.html>

Reply by email

Ludo Brands
to ik

AFAIK, the use of constref for cdecl parameters is wrong in libnotify.pas.

Indeed that was the problem. So what does constref is used for ?!

Thanks Ludo

Constref is passing a value by its reference (as in var paramter) with the promise that the callee won't change it. In this case you want to pass the pchar and not a pointer to the pchar (ppchar).

Ludo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/efaad10a/attachment.html>

Reply by email

ik
to Felipe Monteiro de Carvalho

On Wed, Dec 14, 2011 at 18:25, Felipe Monteiro de Carvalho <

Show quoted text 7 lines
wrote: 2011/12/14 ik : > Indeed that was the problem. So what does constref is used for ?! Surely not to convert c headers, I've never seen it be used for that.

The reason I used it was this wiki entry:
http://wiki.freepascal.org/FPC_New_Features_2.6.0#Constref_parameter_modifier I guess i did not understand it correctly...

Show quoted text 10 lines
-- Felipe Monteiro de Carvalho -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/a2afb5ef/attachment-0001.html>

Reply by email

Ludo Brands
to ik: 2011/12/14 Ludo Brands Indeed that was the problem. So what does constref is used for ?!…

A small suggestion for the example: test the libnotify version. The header conversion is based on 0.7.0 which is fairly recent. Ubuntu 10.04, the latest LTS, still only has version 0.4.5. The example crashes miserably with this version since notify_notification_new had an additional parameter.

Note also that the example could be reduced to a one-liner without header conversion:

Sysutils.ExecuteProcess('/usr/bin/notify-send','-i dialog-information
"Example for libnotify" "This is a simple example how to use libnotify."');

Notify-send comes with the libnotify package. I guess you need the header translation for doing things that aren't possible with notify-send but for the average user it is an easier alternative.

Ludo

Reply by email

ik
to Ludo Brands
Ludo Brands wrote 6 lines
A small suggestion for the example: test the libnotify version. The header conversion is based on 0.7.0 which is fairly recent. Ubuntu 10.04, the latest LTS, still only has version 0.4.5. The example crashes miserably with this version since notify_notification_new had an additional parameter.

Wow 0.4.5 is from 2008 and unmaintained anymore. In Arch we have newer version :)
I'll create also binding for the 0.4 version.

Show quoted text 11 lines
Note also that the example could be reduced to a one-liner without header conversion: Sysutils.ExecuteProcess('/usr/bin/notify-send','-i dialog-information "Example for libnotify" "This is a simple example how to use libnotify."'); Notify-send comes with the libnotify package. I guess you need the header translation for doing things that aren't possible with notify-send but for the average user it is an easier alternative.

Actually I started translating notify-send into Pascal as a bigger example (and mostly test).
Theidea is to use the library problematically and not executing external programs (unlike "normal" users :))

Show quoted text 9 lines
Ludo -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111214/ec9ce893/attachment.html>

Reply by email