Gtk::Window* cannot be closed, Help!

This is a discussion on Gtk::Window* cannot be closed, Help! within the C++ Programming forums, part of the General Programming Boards category; Why could be the causes of a window cannot be closed? I got a couple of misfuntion windows, they cannot ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    6

    Gtk::Window* cannot be closed, Help!

    Why could be the causes of a window cannot be closed?


    I got a couple of misfuntion windows, they cannot be closed while the dialog whose create is still opened. Once the dialog whose opened that windows is closed, them can be closed normally ... is a strage behaviour.


    In another version of the application i was creating the windows in the same way, but from the main window but now they cannot be closed.


    The main window is created in the main, the dialog is created in the main window and finally the two windows whose cannot be closed are created in the dialog.


    Any hint/clue/fix would be appreciate! I can post the code if is needed. Thx in advance

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    > Any hint/clue/fix would be appreciate! I can post the code if is needed. Thx in advance
    Make a copy of the project, and start chopping out code which has no bearing on the problem.

    You might simplify it enough to see what's going on.

    And if not, you have a nice simple example to post.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    Have you defined but not properly implemented callbacks for the windows? It could be that if you have attached a callback to the windows then the default behaviour is ignored, and the GUI depends on your code to manage actions. I would suspect you need to examine the documentation and find out about parent child relationships for your objects, and you will certainly have to post a concise code example, as Salem suggests to receive more meaningfull advice...
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    6
    I did what you said, i chop off 95% of the code and here is the example of what is going on

    main.cpp
    Code:
    #include "MainWindow.h"
    #include <gtkmm/main.h>
    #include <iostream>
    
    int main(int argc, char *argv[]) {
    
        Gnome::Gda::init();
    
        Gtk::Main kit(argc, argv);
    
        Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create_from_file("MainWindow.glade");
    
    
        MainWindow *window;
    
    
        refBuilder->get_widget_derived("window1", window);
        //Shows the window and returns when it is closed.
        Gtk::Main::run(*window);
    
    
        return 0;
    }
    
    MainWindow.cpp
    Code:
    #include "MainWindow.h"
    #include <libgdamm.h>
    #include <gtkmm.h>
    #include <iostream>
    #include <fstream>
    #include <memory>
    
    
    #include "FormDialog.h"
    //#include "Evaluador.h"
    
    
    MainWindow::MainWindow(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> refBuilder) :
    Gtk::Window(cobject),
    m_refBuilder(refBuilder) {
    
    
        m_refBuilder->get_widget("button1", m_Button_New);
    
    
        if (m_Button_New) {
            m_Button_New->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::on_button_new));
        }
    }
    
    
    MainWindow::~MainWindow() {
    }
    
    
    void MainWindow::on_button_new() {
    
    
        FormDialog *dialog;
    
    
        Glib::RefPtr<Gtk::Builder> refBuilder = Gtk::Builder::create_from_file("FormDialog.glade");
    
    
        refBuilder->get_widget_derived("dialog1", dialog);
        dialog->run();
    
    
        delete dialog;
    
    
    }
    FormDialog.cpp
    Code:
    #include "FormDialog.h"
    
    #include <gtkmm.h>
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    
    
    FormDialog::FormDialog(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> refBuilder) :
    Gtk::Dialog(cobject),
    m_refBuilder(refBuilder) {
    
        m_refBuilder->get_widget("button3", button3);
    
       if (button3) {
            button3->signal_clicked().connect(sigc::mem_fun(*this, &FormDialog::on_button_sel));
        }
        show_all_children();
    }
    
    
    FormDialog::~FormDialog() {
    }
    
    
    void FormDialog::on_button_sel() {
        Glib::ustring* us = new Glib::ustring("\n  Help text \n");
        Gtk::Window* help_win = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
    
        help_win->set_title ("Help title");
        Gtk::Label* etiqueta = new Gtk::Label(*us,false);
        help_win->add(*etiqueta);
        help_win->show_all();
    }
    Last edited by wisuzu; 12-06-2011 at 03:15 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. RE: Closed Threads (and why)
    By lightatdawn in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-09-2003, 05:34 PM
  2. know where the form it was closed from
    By talal*c in forum Windows Programming
    Replies: 3
    Last Post: 11-09-2002, 07:45 PM
  3. console window needs closed~
    By black in forum C++ Programming
    Replies: 12
    Last Post: 07-11-2002, 11:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21