GUI Exception, Help!!
- From: "Jamiil Abduqadir" <jalqadir gmail com>
- To: "Gtkmm Mailing List" <gtkmm-list gnome org>
- Subject: GUI Exception, Help!!
- Date: Sat, 3 Feb 2007 09:59:24 -0800
As I have just started programming with GTKmm, I would like to add a GUI interface to my
Exception class. I have been using my Exception class for some time now and I am quite happy
with it. Now, adding a GUI interface to the Exception handler class will constitute as huge step
into the GUI programming world, and a very good self-padding on my shoulder, hi-hi-hi.
Attached is a copy of my Exception class, should you need to use it, it is text base, but it
does the trick with debugging and elow is a the GtkmmException class that is supposed to give me a nice GUI MessageBox.
--------------- Header File ------------------
#ifndef JME_GTKMM_EXCEPTION_HPP
#define JME_GTKMM_EXCEPTION_HPP
#include <gtkmm/messagedialog.h>
#include <glibmm/ustring.h>
#include "../exception.hpp"
namespace jme{
class GtkmmException : virtual public jme::Exception{
private:
Gtk::MessageDialog* MsgD;
public:
GtkmmException();
virtual ~GtkmmException() throw(){};
void Display();
}; //Class
} // Namespace
#endif
--------------- Source Code File ------------------
#ifndef JME_GTKMM_EXCEPTION_HPP
#include "gtkmm_exception.hpp"
#endif
jme::GtkmmException::GtkmmException(){}
void jme::GtkmmException::Display(){
Glib::ustring Msg( this->getMessage() );
if(Msg.empty()){Msg = "Empty";}
MsgD = Gtk::manage(new Gtk::MessageDialog(Msg));
MsgD->run();
}
The class is very simple, it just extends the jme::Exception class, however, when working with
the class I use it like this:
namespace jme{
class JaimeEx : public GtkmmException {
public:
JaimeEx( jme::error_t ec, const std::string& f,
const std::string& m, size_t l ) {
setException( ec, f, m, l );
}
virtual ~JaimeEx() throw(){}
}; //class
class Jaime : public Gtk::Window{
private:
some_class* obj;
public:
.........
protected:
...........
}; // class
} // namespace
----------------------- implementation file ---------------
return_type jme::Jaime::SomeMethod(){
try{ obj = new some_class();}
catch(std::bad_alloc& x){throw jme::JaimeEx(mem_alloc, FILE, METHOD, LINE);}
....
}--------------------------------------
Whoever caches the throwned exception will call the Display method. At least that is what I would
like to happen. The program compiles without any errors, but I get a Run-Time error from MSW.
A side from my style of programming, which I am sure differers from yours, I would like to know
if I am doing something wrong and how to solve my mistake.
Thanks in advance.
Attachment:
exception.hpp
Description: Binary data
Attachment:
exception.cpp
Description: Binary data
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]