Why could be the causes of a Gtk::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 and could be closed.
The main window is created in the main, the dialog is created in a class extended gtk::window and finally the two windows whose cannot be closed are created from the dialog.
main.cpp
#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);
Gtk::Main::run(*window);
return 0;
}
MainWindow.cpp -> class MainWindow : public Gtk::Window
#include "MainWindow.h"
#include <libgdamm.h>
#include <gtkmm.h>
#include <iostream>
#include <fstream>
#include <memory>
#include "DBUtil.h"
#include "FormDialog.h"
MainWindow::MainWindow(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> refBuilder) :
Gtk::Window(cobject),
m_refBuilder(refBuilder) {
//stuff
}
//more stuff
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->setConnectionData(cnc, parser);
dialog->run();
delete dialog;
}
//even more stuff
FormDialog.cpp -> class FormDialog : public Gtk::Dialog
#include "FormDialog.h"
#include <gtkmm.h>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include "DBUtil.h"
FormDialog::FormDialog(BaseObjectType* cobject, Glib::RefPtr<Gtk::Builder> refBuilder) :
Gtk::Dialog(cobject),
m_refBuilder(refBuilder) {
//stuff
}
//more stuff
int FormDialog::check_file(const char * path){
if (strstr(path, ".jpg")!=NULL || strstr(path, ".jpeg")!=NULL)
{ return 1; }
else {
Glib::ustring* us = new Glib::ustring("\n Help \n");
Gtk::Window* help_win = new Gtk::Window(Gtk::WINDOW_TOPLEVEL);
help_win->set_title ("Help");
help_win->move(15,55);
Gtk::Label* lab = new Gtk::Label(*us,false);
help_win->add(*lab);
help_win->show_all();
return 0; }
}
//More stuff
void FormDialog::on_button_sel() {
//function stuff
if (check_file(dialog.get_filename().c_str())) {
//more function stuff
}
Any hint/clue/fix would be appreciate! I can post the code if is needed. Thx in advance