Segmentation fault with statusbar



Hi everyone,
I'm new to gtkmm, so I'm playing around with examples and writing
simple applications.

Here's a strange problem. This code compiles and runs correctly:

// AlarmWindow.h
#ifndef ALARMWINDOW_H
#define ALARMWINDOW_H

#include <gtkmm.h>

#include "AnalogClock.h"

class AlarmWindow : public Gtk::Window {
    public:
        AlarmWindow();
        virtual ~AlarmWindow();

    protected:        
        // Widgets:
        Gtk::Notebook nb;
        Gtk::VBox main_vbox;
        Gtk::HBox buttons_box;
        Gtk::HBox empty;        //usata per allineare i bottoni
    
        Gtk::Button btnAbout;
        Gtk::Button btnQuit;
        
        AnalogClock ck;

        // Signal Handlers:
        void on_btnQuit_clicked();
};

#endif

// AlarmWindow.cpp
#include <gtkmm.h>

#include "AlarmWindow.h"
#include "AnalogClock.h"

AlarmWindow::AlarmWindow() : ck(300, 300), btnQuit(Gtk::Stock::QUIT), 
    btnAbout(Gtk::Stock::ABOUT) {

    btnQuit.signal_clicked().connect(sigc::mem_fun(*this,
&AlarmWindow::on_btnQuit_clicked));

    add(main_vbox);
    
    main_vbox.pack_start(nb, Gtk::PACK_SHRINK, 0);
    main_vbox.pack_start(buttons_box, Gtk::PACK_SHRINK, 0);
    
    buttons_box.pack_start(btnAbout);
    buttons_box.pack_start(empty);
    buttons_box.pack_start(btnQuit);

    nb.append_page(ck, "Clock");
        
    show_all_children();
}

void AlarmWindow::on_btnQuit_clicked() {
    hide();
}

AlarmWindow::~AlarmWindow() {};


But if I add to the header (under Gtk::Button btnQuit;)

        Gtk::Statusbar sb;

and to the .cpp file I add (under main_vbox.pack_start(buttons_box,
Gtk::PACK_SHRINK, 0); )

	main_vbox.pack_start(sb, Gtk::PACK_SHRINK, 0);

I receive a Segmentation Fault error.. Can somebody help me to spot the
bug out?

Thanks in advance,

-- 
[ Andrea Spadaccini - a.k.a. Lupino/Lupin85 - Catania - ICQ#: 91528290 ]
[ GPG ID: 5D41ABF0 - key @ pgp.mit.edu - Slackware 10.1 w/Linux 2.4.22 ]
[ Linux User # 313388 - MAIL: a.spadaccini(at)catania(dot)linux(dot)it ]

Attachment: pgpDo5vdHJHsH.pgp
Description: PGP signature



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