JM_DESTROY message cannot be used in derived classes of Widget.

This commit is contained in:
David Capello 2010-03-27 18:53:47 -03:00
parent c3ef673421
commit b1a53bfdd2
6 changed files with 34 additions and 28 deletions

View File

@ -58,6 +58,19 @@ PopupWindow::PopupWindow(const char* text, bool close_on_buttonpressed)
jwidget_noborders(this);
}
PopupWindow::~PopupWindow()
{
if (m_filtering) {
m_filtering = false;
jmanager_remove_msg_filter(JM_MOTION, this);
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
}
if (m_hot_region != NULL) {
jregion_free(m_hot_region);
}
}
/**
* @param region The new hot-region. This pointer is holded by the @a widget.
* So you cannot destroy it after calling this routine.
@ -91,18 +104,6 @@ bool PopupWindow::msg_proc(JMessage msg)
}
break;
case JM_DESTROY:
if (m_filtering) {
m_filtering = false;
jmanager_remove_msg_filter(JM_MOTION, this);
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
}
if (m_hot_region != NULL) {
jregion_free(m_hot_region);
}
break;
case JM_REQSIZE: {
int w = 0, h = 0;

View File

@ -42,6 +42,7 @@ class PopupWindow : public Frame
public:
PopupWindow(const char* text, bool close_on_buttonpressed);
~PopupWindow();
void setHotRegion(JRegion region);

View File

@ -164,6 +164,19 @@ TipWindow::TipWindow(const char *text, bool close_on_buttonpressed)
jwidget_init_theme(this);
}
TipWindow::~TipWindow()
{
if (m_filtering) {
m_filtering = false;
jmanager_remove_msg_filter(JM_MOTION, this);
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
}
if (m_hot_region != NULL) {
jregion_free(m_hot_region);
}
}
/**
* @param region The new hot-region. This pointer is holded by the @a widget.
* So you can't destroy it after calling this routine.
@ -197,18 +210,6 @@ bool TipWindow::msg_proc(JMessage msg)
}
break;
case JM_DESTROY:
if (m_filtering) {
m_filtering = false;
jmanager_remove_msg_filter(JM_MOTION, this);
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
}
if (m_hot_region != NULL) {
jregion_free(m_hot_region);
}
break;
case JM_REQSIZE: {
int w = 0, h = 0;

View File

@ -43,6 +43,7 @@ class TipWindow : public Frame
public:
TipWindow(const char *text, bool close_on_buttonpressed = false);
~TipWindow();
void set_hotregion(JRegion region);

View File

@ -78,6 +78,11 @@ Frame::Frame(bool desktop, const char* text)
jwidget_init_theme(this);
}
Frame::~Frame()
{
_jmanager_close_window(getManager(), this, false);
}
Widget* Frame::get_killer()
{
return m_killer;
@ -237,10 +242,6 @@ bool Frame::msg_proc(JMessage msg)
{
switch (msg->type) {
case JM_DESTROY:
_jmanager_close_window(getManager(), this, false);
break;
case JM_REQSIZE:
this->window_request_size(&msg->reqsize.w, &msg->reqsize.h);
return true;

View File

@ -52,6 +52,7 @@ class Frame : public Widget
public:
Frame(bool is_desktop, const char* text);
~Frame();
Widget* get_killer();