Error with "g_signal_connect_data_" since PB 5.40

Linux specific forum
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

Since PB 5.40 I get the following error from the compiler at line:

g_signal_connect_data_(*Widget, *buffer, Function, user_data.i, 0, 0)

The error: Bad parameter type: a string is expected.

Before, with exactly the same code files, I didn't get this or any other error.
Now, my question is: At which part PureBasic expects now a string and didn't before?

Thanks
gerd
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by Oma »

Hello Gerd!

In your example the *buffer-argument is the mentioned string and it seems to be no longer a pointer:
You could use something like:

Code: Select all

g_signal_connect_data_(*gInstance, "value-changed", @My_Callback(), Variable, #Null, #Null)
But the safe way is an import like:

Code: Select all

g_signal_connect_data(*instance, detailed_signal.p-utf8, *c_handler, *pdata, destroy= 0, flags= 0)
and a call like

Code: Select all

g_signal_connect_data(*gInstance, "value-changed", @My_Callback(), Variable);, #Null, #Null)
so the string is reliably passed as UTF-8.
Best Regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

Thank you Oma,

this problem seems to be solved. Unfortunately now I get the following linker error

purebasic.o: In function `PB_EndFunctions':
(.text+0xa9016): undefined reference to `gdk_pixbuf_render_pixmap_and_mask'
collect2: error: ld returned 1 exit status


and I have no clue, what it means.

I would be grateful, if somebody could help me with this too.

Thanks
gerd
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by Oma »

Hi Gerd,

gdk_pixbuf_render_pixmap_and_mask is deprecated in Gtk3.
Please post an example how and where it's used, then we have a chance to find a proper replacement.

Regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

Hi Oma,

posting an example, that's where the problem starts. My program consists of 7 files with about 25k lines
and I have no clue where this gdk_pixbuf_render_pixmap_and_mask is coming from.

I will try to find some more infos, but this might take a while.

Thanks
gerd

edit: just one question. What replaces the deprecated function?
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by Oma »

Hi Gerd,
there's no direct replacement for the command (possibly used for background-images?)
Pixmap-support has dropped in Gtk3.
But maybe another method is found to fill the "source gap".

Best regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
Fred
Administrator
Administrator
Posts: 16683
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by Fred »

You can compile with the 'gtk2' subsystem if you want to support your old program with new PB version
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by Keya »

if im just going to release a "regular small utility app with 'typical' GUI - nothing fancy, that doesn't specifically use any new features (to my knowledge)" should I just always compile with gtk2 or gtk3? I have no idea so any suggestions/advice welcome thankyou
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

Unfortunately I cannot compile with 'gtk2' subsystem because I get the following:

[13:12:27] Waiting for executable to start...
[13:12:27] Executable type: Linux - x86 (32bit, Unicode)
[13:12:27] Executable started.
[13:12:27] [WARNING] Main.pb (Line: 1)
[13:12:27] [WARNING] Gtk (ERROR): GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
[13:12:30] The debugged executable quit unexpectedly.

And as before, I have no clue where to look after. And what does "GTK+ 2.x symbols detected" mean?
I have set the subsystem "gtk2", so I would think the detection of GTK+ 2.x symbols is, what has to be expected?
Then why this warning, which is more likely an error, because the program quits.

Any help is welcome.

Thanks
gerd
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

Ok!
After a bit more thinking about the original problem together with the information from Oma
about the exact position of the problem within the code, I inserted an additional line,
which solved the problem. Below I post the modification I had to make:

Here the original portion of the code:

Code: Select all

     
Procedure.i GTKSignalConnect(*Widget, Signal.s, Function, user_data.i)
       Protected *buffer
       *buffer = AllocateMemory(StringByteLength(Signal.s, #PB_Ascii) + 1)        
      If *buffer
        PokeS(*buffer, Signal.s, -1, #PB_Ascii)
        g_signal_connect_data_(*Widget, *buffer, Function, user_data.i, 0, 0)
        FreeMemory(*buffer)
      EndIf        
EndProcedure
And now the same code with an additional line inserted:

Code: Select all

     
Procedure.i GTKSignalConnect(*Widget, Signal.s, Function, user_data.i)
       Protected *buffer
       *buffer = AllocateMemory(StringByteLength(Signal.s, #PB_Ascii) + 1)
      If *buffer
        PokeS(*buffer, Signal.s, -1, #PB_Ascii)
        Signal.s = PeekS(*buffer, -1, #PB_Ascii) ; <------ This is what I inserted!
        g_signal_connect_data_(*Widget, Signal.s, Function, user_data.i, 0, 0)
        FreeMemory(*buffer)
      EndIf        
EndProcedure
Now, what I don't understand, why the first version does not work, although,
if I use Debug to see the content of the buffer both versions show the same.

Anybody has an explanation for me?

Thanks to everybody who helped and tried to help

regards
gerd
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

@Oma

You were right, the function "gdk_pixbuf_render_pixmap_and_mask", is used for
background images of windows. For now I just commented it out until I find a
suitable replacement.

Many thanks for your help
gerd
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by Shardik »

The problem using the deprecated gdk_pixbuf_render_pixmap_and_mask() in Gtk3 when displaying a background image was already discussed in this previous thread. At the end of this thread I posted an example code which demonstrates how to display a background image using the same code for both Gtk2 and Gtk3.
gerd
User
User
Posts: 94
Joined: Tue Feb 23, 2010 7:50 pm
Location: Germany

Re: Error with "g_signal_connect_data_" since PB 5.40

Post by gerd »

Thank you Shardik,

it does work very well.

Greetings
gerd
Post Reply