Re: SIGSEGV one sample application



Note also that when MainWindow() returns, all of your widgets are destroyed since they go out of scope.

Try this instead:

MainWindow::MainWindow() {
    Gtk::HPaned* mainHPaned = new Gtk::HPaned ();
    mainHPaned->set_position(50);

    Gtk::Label* label1 = new Gtk::Label("the first label");
    mainHPaned->add1(*label1);

    Gtk::Label* label2 = new Gtk::Label("that is the second label");
    mainHPaned->add2(*label2);

    this->add(*mainHPaned);
    this->show_all();
}

On 08/13/2015 01:51 PM, Phil Wolff wrote:
After inventing a MainWindow.h, I compiled and executed your example without any problems. Perhaps you should show us your MainWindow.h.

On 08/13/2015 01:28 PM, Emil Nowak wrote:
Hello,
I'm having problems running just a simple application. I got Segmentation
fault with almost empty backtrace, so can't find what is wrong.
The code looks like this:

main.cc file:
#include "MainWindow.h"
int main(int argc, char **argv) {
    Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc,
argv); MainWindow window;
    return app->run(window);
}

MainWindow.cc file:
#include "MainWindow.h"

MainWindow::MainWindow() {
     Gtk::HPaned mainHPaned;
     mainHPaned.set_position(50);

     Gtk::Label label1;
     label1.set_text("the first label");
     mainHPaned.add1(label1);

     Gtk::Label label2;
     label2.set_text("that is the second label");
     mainHPaned.add2(label2);

     this->add(mainHPaned);
     this->show_all();
}

When I run it in debugger:
Using host libthread_db library
"/lib/i386-linux-gnu/i686/cmov/libthread_db.so.1". [New Thread 0xb5b5db40 (LWP
4799)]

Program received signal SIGSEGV, Segmentation fault.
0x006c6562 in ?? ()
(gdb) bt
#0  0x006c6562 in ?? ()
#1  0xbffff54c in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)


My environment is:
g++ version is 4.9.3,
gtkmm 3.16.0

Can you tell me what is wrong with this sample, or how to get more details in
debugging?
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


--
Just remember, if we get caught, you're deaf and I don't speak English.
    -- Unknown


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