summaryrefslogtreecommitdiff
path: root/NxWidgets/nxwm
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-19 01:01:00 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-19 01:01:00 +0000
commita591b9ca86b86684f2804cedf5d0c17a3614e913 (patch)
treeb60235b0a038088298aa0f5497411fcb453c424d /NxWidgets/nxwm
parent6cf694d2da5a661373a58c70e3d8e07cc8223eed (diff)
downloadnuttx-a591b9ca86b86684f2804cedf5d0c17a3614e913.tar.gz
nuttx-a591b9ca86b86684f2804cedf5d0c17a3614e913.tar.bz2
nuttx-a591b9ca86b86684f2804cedf5d0c17a3614e913.zip
NxWM: Add a missing part of the message blocking logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4748 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/nxwm')
-rw-r--r--NxWidgets/nxwm/include/capplicationwindow.hxx4
-rw-r--r--NxWidgets/nxwm/include/cfullscreenwindow.hxx4
-rw-r--r--NxWidgets/nxwm/include/cwindowmessenger.hxx18
-rw-r--r--NxWidgets/nxwm/include/iapplication.hxx8
-rw-r--r--NxWidgets/nxwm/include/iapplicationwindow.hxx12
-rw-r--r--NxWidgets/nxwm/src/capplicationwindow.cxx6
-rw-r--r--NxWidgets/nxwm/src/ccalibration.cxx8
-rw-r--r--NxWidgets/nxwm/src/cfullscreenwindow.cxx8
-rw-r--r--NxWidgets/nxwm/src/cnxconsole.cxx2
-rw-r--r--NxWidgets/nxwm/src/cstartwindow.cxx2
-rw-r--r--NxWidgets/nxwm/src/cwindowmessenger.cxx57
11 files changed, 78 insertions, 51 deletions
diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx
index 686150d14..46e4e90d2 100644
--- a/NxWidgets/nxwm/include/capplicationwindow.hxx
+++ b/NxWidgets/nxwm/include/capplicationwindow.hxx
@@ -162,9 +162,11 @@ namespace NxWM
/**
* Block further activity on this window in preparation for window
* shutdown.
+ *
+ * @param app. The application to be blocked
*/
- void block(void);
+ void block(IApplication *app);
/**
* Set the window label
diff --git a/NxWidgets/nxwm/include/cfullscreenwindow.hxx b/NxWidgets/nxwm/include/cfullscreenwindow.hxx
index 1bab37543..70da9fee5 100644
--- a/NxWidgets/nxwm/include/cfullscreenwindow.hxx
+++ b/NxWidgets/nxwm/include/cfullscreenwindow.hxx
@@ -126,9 +126,11 @@ namespace NxWM
/**
* Block further activity on this window in preparation for window
* shutdown.
+ *
+ * @param app. The application to be blocked
*/
- void block(void);
+ void block(IApplication *app);
/**
* Set the window label
diff --git a/NxWidgets/nxwm/include/cwindowmessenger.hxx b/NxWidgets/nxwm/include/cwindowmessenger.hxx
index 645e750cb..0aa8961bb 100644
--- a/NxWidgets/nxwm/include/cwindowmessenger.hxx
+++ b/NxWidgets/nxwm/include/cwindowmessenger.hxx
@@ -98,6 +98,14 @@ namespace NxWM
void handleKeyboardEvent(void);
#endif
+ /**
+ * Handle a NX window blocked event
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+ void handleBlockedEvent(FAR void *arg);
+
public:
/**
@@ -111,16 +119,6 @@ namespace NxWM
*/
~CWindowMessenger(void);
-
- /**
- * Destroy the application window and everything in it. This is
- * handled by CWindowMessenger (vs just calling the destructors) because
- * in the case where an application destroys itself (because of pressing
- * the stop button), then we need to unwind and get out of the application
- * logic before destroying all of its objects.
- */
-
- void destroy(IApplication *app);
};
}
#endif // __cplusplus
diff --git a/NxWidgets/nxwm/include/iapplication.hxx b/NxWidgets/nxwm/include/iapplication.hxx
index 28e50e013..456202c6d 100644
--- a/NxWidgets/nxwm/include/iapplication.hxx
+++ b/NxWidgets/nxwm/include/iapplication.hxx
@@ -45,8 +45,6 @@
#include "cnxstring.hxx"
#include "ibitmap.hxx"
-#include "iapplicationwindow.hxx"
-
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@@ -60,6 +58,12 @@
namespace NxWM
{
/**
+ * Foward references
+ */
+
+ class IApplicationWindow;
+
+ /**
* IApplication provides the abstract base class for each NxWM application.
*/
diff --git a/NxWidgets/nxwm/include/iapplicationwindow.hxx b/NxWidgets/nxwm/include/iapplicationwindow.hxx
index ed221797d..60f1b332c 100644
--- a/NxWidgets/nxwm/include/iapplicationwindow.hxx
+++ b/NxWidgets/nxwm/include/iapplicationwindow.hxx
@@ -46,6 +46,8 @@
#include "cnxstring.hxx"
#include "cwidgetcontrol.hxx"
+#include "iapplication.hxx"
+
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@@ -59,6 +61,12 @@
namespace NxWM
{
/**
+ * Foward references
+ */
+
+ class IApplication;
+
+ /**
* This callback class is used by the application to get notification of toolbar
* related events.
*/
@@ -137,9 +145,11 @@ namespace NxWM
/**
* Block further activity on this window in preparation for window
* shutdown.
+ *
+ * @param app. The application to be blocked
*/
- virtual void block(void) = 0;
+ virtual void block(IApplication *app) = 0;
/**
* Set the window label
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx
index c0bc9ed62..5cf172ea6 100644
--- a/NxWidgets/nxwm/src/capplicationwindow.cxx
+++ b/NxWidgets/nxwm/src/capplicationwindow.cxx
@@ -426,9 +426,11 @@ NXWidgets::CWidgetControl *CApplicationWindow::getWidgetControl(void) const
/**
* Block further activity on this window in preparation for window
* shutdown.
+ *
+ * @param app. The application to be blocked
*/
-void CApplicationWindow::block(void)
+void CApplicationWindow::block(IApplication *app)
{
// Get the widget control from the NXWidgets::CNxWindow instance
@@ -437,7 +439,7 @@ void CApplicationWindow::block(void)
// And then block further reporting activity on the underlying
// NX framed window
- nxtk_block(control->getWindowHandle());
+ nxtk_block(control->getWindowHandle(), (FAR void *)app);
}
/**
diff --git a/NxWidgets/nxwm/src/ccalibration.cxx b/NxWidgets/nxwm/src/ccalibration.cxx
index d93f56a47..6f5976100 100644
--- a/NxWidgets/nxwm/src/ccalibration.cxx
+++ b/NxWidgets/nxwm/src/ccalibration.cxx
@@ -220,13 +220,13 @@ void CCalibration::stop(void)
void CCalibration::destroy(void)
{
- // Block any further window messages
+ // Make sure that the application is stopped (should already be stopped)
- m_window->block();
+ stop();
- // Make sure that the application is stopped
+ // Block any further window messages
- stop();
+ m_window->block(this);
}
/**
diff --git a/NxWidgets/nxwm/src/cfullscreenwindow.cxx b/NxWidgets/nxwm/src/cfullscreenwindow.cxx
index 0c34166c0..6ec5bf802 100644
--- a/NxWidgets/nxwm/src/cfullscreenwindow.cxx
+++ b/NxWidgets/nxwm/src/cfullscreenwindow.cxx
@@ -36,7 +36,7 @@
/********************************************************************************************
* Included Files
********************************************************************************************/
-
+
#include <nuttx/config.h>
#include <nuttx/nx/nxglib.h>
@@ -141,9 +141,11 @@ NXWidgets::CWidgetControl *CFullScreenWindow::getWidgetControl(void) const
/**
* Block further activity on this window in preparation for window
* shutdown.
+ *
+ * @param app. The application to be blocked
*/
-void CFullScreenWindow::block(void)
+void CFullScreenWindow::block(IApplication *app)
{
// Get the widget control from the NXWidgets::CNxWindow instance
@@ -152,7 +154,7 @@ void CFullScreenWindow::block(void)
// And then block further reporting activity on the underlying
// NX raw window
- nx_block(control->getWindowHandle());
+ nx_block(control->getWindowHandle(), (FAR void *)app);
}
/**
diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx
index 64321ddfb..6a64afc1b 100644
--- a/NxWidgets/nxwm/src/cnxconsole.cxx
+++ b/NxWidgets/nxwm/src/cnxconsole.cxx
@@ -341,7 +341,7 @@ void CNxConsole::destroy(void)
{
// Block any further window messages
- m_window->block();
+ m_window->block(this);
// Make sure that the application is stopped
diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx
index 3dfab5097..af46e7b82 100644
--- a/NxWidgets/nxwm/src/cstartwindow.cxx
+++ b/NxWidgets/nxwm/src/cstartwindow.cxx
@@ -234,7 +234,7 @@ void CStartWindow::destroy(void)
// Block any further window messages
- m_window->block();
+ m_window->block(this);
// Make sure that the application is stopped
diff --git a/NxWidgets/nxwm/src/cwindowmessenger.cxx b/NxWidgets/nxwm/src/cwindowmessenger.cxx
index 4e458566d..b467f533c 100644
--- a/NxWidgets/nxwm/src/cwindowmessenger.cxx
+++ b/NxWidgets/nxwm/src/cwindowmessenger.cxx
@@ -91,31 +91,6 @@ CWindowMessenger::~CWindowMessenger(void)
}
/**
- * Destroy the application window and everything in it. This is
- * handled by CWindowMessenger (vs just calling the destructors) because
- * in the case where an application destroys itself (because of pressing
- * the stop button), then we need to unwind and get out of the application
- * logic before destroying all of its objects.
- */
-
-void CWindowMessenger::destroy(IApplication *app)
-{
- // Send a message to destroy the window isntance at a later time
-
- struct SStartWindowMessage outmsg;
- outmsg.msgId = MSGID_DESTROY_APP;
- outmsg.instance = (FAR void *)app;
-
- gdbg("Sending MSGID_DESTROY_APP with instance=%p\n", app);
- int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
- CONFIG_NXWM_STARTWINDOW_MXMPRIO);
- if (ret < 0)
- {
- gdbg("ERROR: mq_send failed: %d\n", errno);
- }
-}
-
-/**
* Handle an NX window mouse input event.
*
* @param e The event data.
@@ -208,3 +183,35 @@ void CWindowMessenger::handleKeyboardEvent(void)
}
}
#endif
+
+/**
+ * Handle a NX window blocked event. This handler is called when we
+ * receive the BLOCKED message meaning that there are no further pending
+ * actions on the window. It is now safe to delete the window.
+ *
+ * This is handled by sending a message to the start window thread (vs just
+ * calling the destructors) because in the case where an application
+ * destroys itself (because of pressing the stop button), then we need to
+ * unwind and get out of the application logic before destroying all of its
+ * objects.
+ *
+ * @param arg - User provided argument (see nx_block or nxtk_block)
+ */
+
+void CWindowMessenger::handleBlockedEvent(FAR void *arg)
+{
+ // Send a message to destroy the window isntance at a later time
+
+ struct SStartWindowMessage outmsg;
+ outmsg.msgId = MSGID_DESTROY_APP;
+ outmsg.instance = arg;
+
+ gdbg("Sending MSGID_DESTROY_APP with instance=%p\n", arg);
+ int ret = mq_send(m_mqd, &outmsg, sizeof(struct SStartWindowMessage),
+ CONFIG_NXWM_STARTWINDOW_MXMPRIO);
+ if (ret < 0)
+ {
+ gdbg("ERROR: mq_send failed: %d\n", errno);
+ }
+}
+