Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: Orione on February 15, 2012, 12:37:35 pm

Title: gtk_text_buffer_emit_insert: assertion `g_utf8_validate` on HelloWorld plugin
Post by: Orione on February 15, 2012, 12:37:35 pm
I'm trying to start plugin development and followed wiki for HelloWorld plugin.
It compiles fine but as I try to add the new plugin I get following error on the terminal:

(codeblocks:3285): Gtk-CRITICAL **: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)' failed
Failed

I'm developing on Linux, installed wxWidget and Code::Blocks from sources as described on
http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks_from_source_on_Linux

Output from "wx-config --libs":
-L/opt/wx/2.8/lib -pthread   -lwx_gtk2u-2.8

and the output from "wx-config --prefix" is in $LD_LIBRARY_PATH.

I read on a previous post that such error was solved by a user by linking to correct libraries, but I was not able to find how.

Hope someone can give me a hint.
Thanks!
Title: Re: gtk_text_buffer_emit_insert: assertion `g_utf8_validate` on HelloWorld plugin
Post by: Jenna on February 15, 2012, 02:35:16 pm
Maybe this helps:
http://www.c-plusplus.de/forum/160326 (http://www.c-plusplus.de/forum/160326)

If it happens in your plugin, it's not a C::B issue.
Title: Re: gtk_text_buffer_emit_insert: assertion `g_utf8_validate` on HelloWorld plugin
Post by: Orione on February 15, 2012, 03:05:34 pm
Thanks for your hint, unfortunately it's not the case.

It's a new plugin, but anything is created automatically through Code::Blocks procedures.
Maybe I was not fully clear in my previous message, sorry about that:
- I start codeblocks compiled from sources.
- I create a new plugin project, named HelloWorld as detailed on wiki page
- I compile the plugin project anhat add it goes fine
- I try to "Install new" plugin in plugin manager and it fails with Gtk message

The only change I did to what Code::Blocks creates automatically is to copy libHelloWorld.so file to HelloWorld.so and to zip HelloWorld.so in plugin.
If I don't do this the plugin manager complais for: File 'HelloWorld.so' not found in plugin '/home/Development/CodeBlocks/HelloWorldPlugin/HelloWorld.cbplugin'

I'm currently trying to track the code execution in Code::Blocks methods related to installing new plugins.

Suggestions of any kind are always welcome!
Title: Re: gtk_text_buffer_emit_insert: assertion `g_utf8_validate` on HelloWorld plugin
Post by: Orione on February 16, 2012, 07:39:31 pm
As an update to problem description, and hopefully a hint to get hint:

file src/include/cbplugin.h
in PluginRegistrant::PluginRegistrant
I get correct value for parameter "name" -> HelloWorld

This method contains only following call:
Manager::Get()->GetPluginManager()->RegisterPlugin(name, // plugin's name
                                                                &CreatePlugin, // creation
                                                                &FreePlugin, // destruction
                                                                &SDKVersion); // SDK version

both "Manager::Get()" and "Manager::Get()->GetPluginManager()" return valid instances

method declaration in src/include/pluginmanager.h is
        void RegisterPlugin(const wxString& name,
                            CreatePluginProc createProc,
                            FreePluginProc freeProc,
                            PluginSDKVersionProc versionProc);


but in the file sdk/pluginmanager.cpp
method PluginManager::RegisterPlugin
the first parameter contains odd values: lenght is correct, memory address is still the same as in PluginRegistrant::PluginRegistrant, characters in wxString are no more correct

Hope this information could be helpful to someone to help me.
I have no idea on how to proceed deeper in code inspection... maybe gdb on memory address but I don't know how to get who is modifying the value.
Thanks!
Title: Re: gtk_text_buffer_emit_insert: assertion `g_utf8_validate` on HelloWorld plugin
Post by: oBFusCATed on February 16, 2012, 08:50:59 pm
Orione:
How many versions of C::B do you have installed?

To compile a plugin on linux you don't have to build from source, because we provide usable sdk.
You can use pkg-config to get the proper compiler/linker settings.

What is the output of ldd libyourplugin.so?

If you have mixed libraries there is no point in debugging it with gdb.
Title: Re: gtk_text_buffer_emit_insert: assertion `g_utf8_validate` on HelloWorld plugin
Post by: Orione on February 23, 2012, 04:07:21 pm
Thanks for your help!
Problem was related to a library mess as I had two set of libraries for wx.
I went to reset both of them and to remove all Code::Blocks libraries too.

Then started again compiling a unicode version of wxWidgets and Code::Blocks from SVN.
Now I have a fully functional and updated IDE where I can develope my own plugins!

Hope I could give back help next time!