I believe that "delete MetadataExportDialog;" deletes too much. It
probably deletes all the dialog's child widgets, stored inside m_refGlade.
You can try to skip the deletion, or delete only when you know that you
will not need the dialog any more.
If you do this, you must move the call to Gtk::Dialog::run() from
metadataEncapsulationDialog's constructor to somewhere else. The
constructor will be executed only once, even if you call
m_refGlade->get_widget_derived("MetadataExportDialog",MetadataExportDialog);
several times.
Kjell
2013-03-28 17:35, Dos Santos, Oliveira skrev:
Hi everybody,
I'm experiencing some difficulties with a Gtk::Dialog built with Glade
which I instantiate from somewhere (I don't think it's relevant, but
the somewhere is just a Gtk::window...).
Basically, when I run it the first time, all is fine. When I run it a
second time or plus, the Gtk::Dialog becomes empty except for the
dialog title :-/ I think I'm doing something wrong... but where `???
All parameters of the Gtk::Dialog are defined into the XML Glade.
I copy paste the relevant parts of my source below
Regards
////////////////////// the instantiation from the parent window
voidmetadataWindow::on_exportEBUCore_clicked(void){
metadataEncapsulationDialog * MetadataExportDialog;
// instantiate glade dialog
m_refGlade->get_widget_derived("MetadataExportDialog",MetadataExportDialog);
if (MetadataExportDialog->getResponse() == Gtk::RESPONSE_OK)
std::cout<<"it works, I pressed the save button..."<<std::endl;
// free memory
delete MetadataExportDialog;
}
////////////////////// dialog hpp file
#ifndefCPP_METADATAENCAPSULATIONDIALOG_CLASS_H
#defineCPP_METADATAENCAPSULATIONDIALOG_CLASS_H
/// includes [...]
classmetadataEncapsulationDialog : public Gtk::Dialog {
public:
metadataEncapsulationDialog(BaseObjectType* cobject, const
Glib::RefPtr<Gtk::Builder>& refGlade);
~metadataEncapsulationDialog(void);
int getResponse(void);
protected:
// Glade reference
Glib::RefPtr<Gtk::Builder> m_refGlade; /*!< m_refGlade Glade references */
// gtk button
Gtk::Button* cancelDialog; /*!< cancelDialog */
Gtk::Button* saveMetadata; /*!< saveMetadata */
Gtk::Button* SelectPathToOutputMXF; /*!< SelectPathToOutputMXF */
// gtk radio button
Gtk::RadioButton* header; /*!< header */
Gtk::RadioButton* footer; /*!< footer */
Gtk::RadioButton* KLV; /*!< KLV */
Gtk::RadioButton* Dark; /*!< Dark */
Gtk::RadioButton* Sidecar; /*!< Sidecar */
// gtk entries
Gtk::Entry * PathToOutputMXF;
// dialog response
int response; /*!< response */
void refGladeWidgets(const Glib::RefPtr<Gtk::Builder>& refGlade);
void refGladeButton(const Glib::RefPtr<Gtk::Builder>& refGlade);
void connectSignalClicked(void);
void on_close_dialog(void);
void on_confirm_clicked(void);
};
#endif
////////////////////////////// dialog cpp file
#include"metadataEncapsulationDialog.hpp"
// class constructor
metadataEncapsulationDialog::metadataEncapsulationDialog
(
BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& refGlade
)
:
Gtk::Dialog(cobject),
m_refGlade(refGlade)
{
std::cout<<"Im instantiating this...."<<std::endl;
refGladeButton(refGlade); // " " " " buttons
refGladeWidgets(refGlade);// " " " " widgets
connectSignalClicked();
// run and grab the result
response = run();
}
metadataEncapsulationDialog::~metadataEncapsulationDialog(void)
{std::cout<<"byebye"<<std::endl;}
voidmetadataEncapsulationDialog::refGladeButton(const
Glib::RefPtr<Gtk::Builder>& refGlade) {
refGlade->get_widget("cancelDialog",cancelDialog);
refGlade->get_widget("saveMetadata",saveMetadata);
refGlade->get_widget("SelectPathToOutputMXF",SelectPathToOutputMXF);
}
voidmetadataEncapsulationDialog::refGladeWidgets(const
Glib::RefPtr<Gtk::Builder>& refGlade) {
refGlade->get_widget("header",header);
refGlade->get_widget("footer",footer);
refGlade->get_widget ("KLV",KLV);
refGlade->get_widget("Dark",Dark);
refGlade->get_widget("Sidecar",Sidecar);
refGlade->get_widget("PathToOutputMXF",PathToOutputMXF);
}
voidmetadataEncapsulationDialog::connectSignalClicked(void){
cancelDialog->signal_clicked().connect(sigc::mem_fun(*this,&metadataEncapsulationDialog::on_close_dialog));
saveMetadata->signal_clicked().connect(sigc::mem_fun(*this,&metadataEncapsulationDialog::on_confirm_clicked));
}
voidmetadataEncapsulationDialog::on_close_dialog(void) {hide();}
voidmetadataEncapsulationDialog::on_confirm_clicked(void) {hide();}
intmetadataEncapsulationDialog::getResponse(void) {return response;}
Marco Dos Santos Oliveira
EBU/European Broadcasting Union
Technology and Innovation Department
_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list