Merge lp:~smspillaz/nux/nux.fix_1097281 into lp:nux
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Francis Ginther | ||||
Approved revision: | 758 | ||||
Merged at revision: | 761 | ||||
Proposed branch: | lp:~smspillaz/nux/nux.fix_1097281 | ||||
Merge into: | lp:nux | ||||
Diff against target: |
958 lines (+667/-18) 8 files modified
Nux/MainLoopGLib.cpp (+96/-0) Nux/MainLoopGLib.h (+21/-0) Nux/ProgramFramework/ProgramTemplate.cpp (+102/-1) Nux/ProgramFramework/ProgramTemplate.h (+26/-0) Nux/WindowThread.cpp (+108/-5) Nux/WindowThread.h (+26/-0) tests/gtest-nux-windowthread.cpp (+257/-8) tests/xtest-text-entry.cpp (+31/-4) |
||||
To merge this branch: | bzr merge lp:~smspillaz/nux/nux.fix_1097281 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+146078@code.launchpad.net |
Commit message
Implement a message-passing system in nux::WindowThread and nux::ProgramFra
This makes it possible to define and implement protocols for WindowThreads to
communicate with each other in a thread-safe way without having to resort to
using window system events or the like.
New file descriptors can be added for watching with a watch-callback executed
inside the window thread with nux::WindowThre
read-data is supported right now.
When there is new data available to be read, the provided FdWatchCallback will
be called by the window thread, and executed inside the window thread. From
there, clients can safely modify data contained by the WindowThread object.
Remove a watched file descriptor with UnwatchFd.
It is safe to add file descriptors for watching during the call to the provided
ThreadUserInitFunc in CreateGUIThread. This is because the main loop
implementation must be created before those file descriptors are added for
watching (particularly in the case of GLib, because nux::WindowThre
will use the default GMainContext the first time it is called, and then create
a new one for each window thereafter.
Added three new tests to demonstrate and cover this functionality.
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from TestWindowThread
[ RUN ] TestWindowThrea
[ OK ] TestWindowThrea
[ RUN ] TestWindowThrea
[ OK ] TestWindowThrea
[ RUN ] TestWindowThrea
[ OK ] TestWindowThrea
[----------] 3 tests from TestWindowThread (9532 ms total)
[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (9532 ms total)
[ PASSED ] 3 tests.
Fixed segfaulting test xtest-text-input. That test unsafely mutated object
state contained by the WindowThread running in another thread inside of the
test thread. This resulted in a null pointer dereference because it had a
side effect of calling nux::GetWindowT
thread-
the running program to mutate the relevant state, and then communicate back
when it has completed execution.
(LP: #1097281)
Description of the change
Implement a message-passing system in nux::WindowThread and nux::ProgramFra
This makes it possible to define and implement protocols for WindowThreads to
communicate with each other in a thread-safe way without having to resort to
using window system events or the like.
New file descriptors can be added for watching with a watch-callback executed
inside the window thread with nux::WindowThre
read-data is supported right now.
When there is new data available to be read, the provided FdWatchCallback will
be called by the window thread, and executed inside the window thread. From
there, clients can safely modify data contained by the WindowThread object.
Remove a watched file descriptor with UnwatchFd.
It is safe to add file descriptors for watching during the call to the provided
ThreadUserInitFunc in CreateGUIThread. This is because the main loop
implementation must be created before those file descriptors are added for
watching (particularly in the case of GLib, because nux::WindowThre
will use the default GMainContext the first time it is called, and then create
a new one for each window thereafter.
Added three new tests to demonstrate and cover this functionality.
[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from TestWindowThread
[ RUN ] TestWindowThrea
[ OK ] TestWindowThrea
[ RUN ] TestWindowThrea
[ OK ] TestWindowThrea
[ RUN ] TestWindowThrea
[ OK ] TestWindowThrea
[----------] 3 tests from TestWindowThread (9532 ms total)
[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (9532 ms total)
[ PASSED ] 3 tests.
Fixed segfaulting test xtest-text-input. That test unsafely mutated object
state contained by the WindowThread running in another thread inside of the
test thread. This resulted in a null pointer dereference because it had a
side effect of calling nux::GetWindowT
thread-
the running program to mutate the relevant state, and then communicate back
when it has completed execution.
(LP: #1097281)
I understand that introducing such a large amount of framework is a hefty change for what appears to be fixing a small bug. However, I feel that it is justified. I'm surprised that as a toolkit Nux didn't even have support for this in the first place, since it is definitely a valid usecase where the underlying framework is controlling program flow. There also didn't appear to be any other (sane and safe) way of implementing the calls to SetKeyFocusArea properly, and I don't know if the test works without them.
Note: xtest-text-
Nux: TextEntry created: Ok
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 132 (XTEST)
Minor opcode of failed request: 2 (X_XTestFakeInput)
Value in failed request: 0x0
Serial number of failed request: 276
Current serial number in output stream: 278
That's a separate issue, which I'll deal with in another review (bug 1112321)
Looks good to me, the idea of it sounds excellent as well. Im just a bit rusty on fd/thread and pipes and would love a seconds reviewer.