Re: stupid segfaults -- argh!



On 6/7/06, Joe Van Dyk <joevandyk gmail com> wrote:
On 6/6/06, Paul Davis <paul linuxaudiosystems com> wrote:
> On Mon, 2006-06-05 at 17:40 -0700, Joe Van Dyk wrote:
> > I wonder why the documentation says a Gtk::Main object can't be
> > created in the global scope.  Apparently, that's what I want to do, as
> > I can't put it inside main().
>
> GTK and gtkmm require library initialization before any objects related
> to them can be created. by attempting to put Gtk::Main in global scope
> you are effectively asking for this order to be reversed.

If I have Gtk::Main outside of any classes or functions (global scope,
right?), what "related" objects would be created before Gtk::Main was
called?

well, if I'm not mistaken, the constructor for Gtk::Main actually
initializes GTK+, right?  so you might be able to get away with a
global Gtk::Main, but if the documentation says not to, I'd be very
wary of doing so.

Perhaps you could just have a global Gtk::Main* (pointer), and then
inside your Program::Initialize() function do something like
globalMainPointer = new Gtk::Main(argc, argv);
then the Gtk::Main object won't be destroyed after exiting
Program::Initialize() and you'll still be able to access it through
your global pointer variable.

That said, I haven't done any multi-threaded GTK / gtkmm programming,
so there may be a completely different approach that would work
better.

Jonner



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