Fwd: Re: (process:5746): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to call g_type_init() - Fedora 16



Here's the last part of this conversation that should have been sent to gtkmm-list earlier.

Kjell

-------- Ursprungligt meddelande --------
Ämne: Re: (process:5746): GLib-GObject-CRITICAL **: gtype.c:2708: You forgot to call g_type_init() - Fedora 16
Datum: Wed, 7 Dec 2011 14:27:52 -0500
Från: Phong Cao <phngcv gmail com>
Till: Kjell Ahlstedt <kjell ahlstedt bredband net>


Hi Kjell,

Thank you for your solution! It works perfectly!

On Tue, Dec 6, 2011 at 3:12 PM, Kjell Ahlstedt <kjell ahlstedt bredband net> wrote:
2011-12-06 15:08, Phong Cao skrev:

Hi Kjell,

Thank you for the response. I was also thinking that it might be the static data members initialization that causes this error. The problem is I dont know any other appropriate places to initialize them... ?

Hi,

I tried to compile and run your program, but it's more time-consuming than I thought. I had to first install gstreamermm. If I install with Ubuntu's package manager, Synaptic, I get version 0.10.9, which lacks Gst::Discoverer. Your code requires at least version 0.10.10.
When I tried to install from the git repository with jhbuild, I ran into problems when jhbuild built some of the packages that gstreamermm depends on. I'm sure those problems are solvable, but I don't want to spend the necessary time on it.

Assuming that the static data in Dingo::DBManager is actually the problem, there are some ways to solve it. Defer the creation of real objects until first use. E.g. something like this:

dingo-dbmanager.h
-----------------
namespace Dingo {
 class DBManager {
   public:
     static TrackColumnRecord* get_trackCR();
     static PlaylistColumnRecord* get_playlistCR();
     static BehaviorsColumnRecord* get_behaviorsCR();


   private:
     static std::auto_ptr<TrackColumnRecord> trackCR;
     static std::auto_ptr<PlaylistColumnRecord> playlistCR;
     static std::auto_ptr<BehaviorsColumnRecord> behaviorsCR;
 };
}

dingo-dbmanager.cc
------------------
std::auto_ptr<Dingo::TrackColumnRecord> Dingo::DBManager::trackCR;
std::auto_ptr<Dingo::PlaylistColumnRecord> Dingo::DBManager::playlistCR;
std::auto_ptr<Dingo::BehaviorsColumnRecord> Dingo::DBManager::behaviorsCR;

Dingo::TrackColumnRecord* Dingo::DBManager::get_trackCR()
{
 if (!trackCR.get())
 {
   trackCR.reset(new Dingo::TrackColumnRecord());
 }
 return trackCR.get();
}

// get_playlistCR() and get_behaviorsCR() are similar.

I don't think the static data with Glib::RefPtr will cause problems. It should be possible to initialize a Glib::RefPtr with a 0 pointer before anything else has been initialized.

Kjell



--
Phong V. Cao





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]