Nux

Merge lp:~apinheiro/nux/fix-event-inspector into lp:nux

Proposed by Alejandro Piñeiro
Status: Merged
Merged at revision: 270
Proposed branch: lp:~apinheiro/nux/fix-event-inspector
Merge into: lp:nux
Diff against target: 68 lines (+8/-7)
2 files modified
Nux/WindowThread.cpp (+5/-4)
Nux/WindowThread.h (+3/-3)
To merge this branch: bzr merge lp:~apinheiro/nux/fix-event-inspector
Reviewer Review Type Date Requested Status
Loïc Molinari (community) Approve
Jay Taoko Pending
Review via email: mp+53414@code.launchpad.net

Description of the change

Recently I started to work on bug 702672, and for that I need to use the EventInspector support on WindowThread.

So my idea was make something like this:

static int
unity_key_snooper (nux::Area *area, nux::Event *event, void *data)
{
 //do something
}

wt->InstallEventInspector (unity_key_snooper, NULL);

But this launches a casting error while compiling. So I tried to use a casting with (EventInspector *). But then it crashes while executing the code (I also tried with &unity_key_snooper).

Then I realized something on the install method:

    int InstallEventInspector (EventInspector *function, void* data);

EventInspector is already defined as a pointer, so this *function is not required. So I modified those, and things works now.

To post a comment you must log in.
Revision history for this message
Loïc Molinari (loic.molinari) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Nux/WindowThread.cpp'
--- Nux/WindowThread.cpp 2011-03-09 22:50:06 +0000
+++ Nux/WindowThread.cpp 2011-03-15 12:10:52 +0000
@@ -1839,7 +1839,7 @@
1839 GetGpuDevice()->DeactivateFrameBuffer();1839 GetGpuDevice()->DeactivateFrameBuffer();
1840 }1840 }
18411841
1842 int WindowThread::InstallEventInspector (EventInspector* function, void* data)1842 int WindowThread::InstallEventInspector (EventInspector function, void* data)
1843 {1843 {
1844 NUX_RETURN_VALUE_IF_NULL (function, 0);1844 NUX_RETURN_VALUE_IF_NULL (function, 0);
18451845
@@ -1881,7 +1881,7 @@
1881 return false;1881 return false;
1882 }1882 }
18831883
1884 bool WindowThread::RemoveEventInspector (EventInspector* function)1884 bool WindowThread::RemoveEventInspector (EventInspector function)
1885 {1885 {
1886 NUX_RETURN_VALUE_IF_NULL (function, false);1886 NUX_RETURN_VALUE_IF_NULL (function, false);
18871887
@@ -1912,12 +1912,13 @@
19121912
1913 for (it = _event_inspectors_map.begin (); it != _event_inspectors_map.end (); it++)1913 for (it = _event_inspectors_map.begin (); it != _event_inspectors_map.end (); it++)
1914 {1914 {
1915 EventInspector *callback = (*it).second._function;1915 EventInspector callback = (*it).second._function;
19161916
1917 if (callback == 0)1917 if (callback == 0)
1918 continue;1918 continue;
19191919
1920 int ret = (*callback) (0, event, (*it).second._data);1920 int ret = callback (0, event, (*it).second._data);
1921
1921 if (ret)1922 if (ret)
1922 {1923 {
1923 discard_event = true;1924 discard_event = true;
19241925
=== modified file 'Nux/WindowThread.h'
--- Nux/WindowThread.h 2011-03-09 22:50:06 +0000
+++ Nux/WindowThread.h 2011-03-15 12:10:52 +0000
@@ -383,7 +383,7 @@
383 @param data User defined data.383 @param data User defined data.
384 @return Unique id for the event inspector callback.384 @return Unique id for the event inspector callback.
385 */385 */
386 int InstallEventInspector (EventInspector* function, void* data);386 int InstallEventInspector (EventInspector function, void* data);
387387
388 //! Remove an event inspector.388 //! Remove an event inspector.
389 /*!389 /*!
@@ -401,7 +401,7 @@
401 @param function Event inspector function callback.401 @param function Event inspector function callback.
402 @return True If the event inspector exists and has been removed.402 @return True If the event inspector exists and has been removed.
403 */403 */
404 bool RemoveEventInspector (EventInspector* function);404 bool RemoveEventInspector (EventInspector function);
405405
406 //! Call event inspectors.406 //! Call event inspectors.
407 /*!407 /*!
@@ -555,7 +555,7 @@
555 _data = 0;555 _data = 0;
556 _uid = 0;556 _uid = 0;
557 }557 }
558 EventInspector* _function;558 EventInspector _function;
559 void* _data;559 void* _data;
560 int _uid;560 int _uid;
561 } EventInspectorStorage;561 } EventInspectorStorage;

Subscribers

People subscribed via source and target branches