Merge lp:~3v1n0/frame/remove-asserts-on-device-get into lp:frame

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 123
Merged at revision: 123
Proposed branch: lp:~3v1n0/frame/remove-asserts-on-device-get
Merge into: lp:frame
Diff against target: 54 lines (+15/-8)
1 file modified
src/device.cpp (+15/-8)
To merge this branch: bzr merge lp:~3v1n0/frame/remove-asserts-on-device-get
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+302439@code.launchpad.net

Commit message

device: don't use asserts to get properties on failures, to avoid crashes

To post a comment you must log in.
123. By Marco Trevisan (Treviño)

device: don't use asserts to get properties on failures, to avoid crashes

Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/device.cpp'
--- src/device.cpp 2012-12-04 18:46:01 +0000
+++ src/device.cpp 2016-08-09 15:48:12 +0000
@@ -20,8 +20,6 @@
2020
21#include "device.h"21#include "device.h"
2222
23#include <assert.h>
24
25#include "axis.h"23#include "axis.h"
2624
27#include <oif/frame_backend.h>25#include <oif/frame_backend.h>
@@ -135,8 +133,11 @@
135 unsigned int num_axes;133 unsigned int num_axes;
136 UFStatus status = frame_device_get_property(device, UFDevicePropertyNumAxes,134 UFStatus status = frame_device_get_property(device, UFDevicePropertyNumAxes,
137 &num_axes);135 &num_axes);
138 assert(status == UFStatusSuccess);136 if (status == UFStatusSuccess)
139 return num_axes;137 return num_axes;
138
139 fprintf(stderr, "Error: failed to get device number of axes\n");
140 return 0;
140}141}
141142
142float frame_device_get_window_resolution_x(UFDevice device) {143float frame_device_get_window_resolution_x(UFDevice device) {
@@ -144,8 +145,11 @@
144 UFStatus status = frame_device_get_property(device,145 UFStatus status = frame_device_get_property(device,
145 UFDevicePropertyWindowResolutionX,146 UFDevicePropertyWindowResolutionX,
146 &resolution);147 &resolution);
147 assert(status == UFStatusSuccess);148 if (status == UFStatusSuccess)
148 return resolution;149 return resolution;
150
151 fprintf(stderr, "Error: failed to get device X resolution\n");
152 return 0;
149}153}
150154
151float frame_device_get_window_resolution_y(UFDevice device) {155float frame_device_get_window_resolution_y(UFDevice device) {
@@ -153,8 +157,11 @@
153 UFStatus status = frame_device_get_property(device,157 UFStatus status = frame_device_get_property(device,
154 UFDevicePropertyWindowResolutionY,158 UFDevicePropertyWindowResolutionY,
155 &resolution);159 &resolution);
156 assert(status == UFStatusSuccess);160 if (status == UFStatusSuccess)
157 return resolution;161 return resolution;
162
163 fprintf(stderr, "Error: failed to get device Y resolution\n");
164 return 0;
158}165}
159166
160UFStatus frame_accept_touch(UFDevice device, UFWindowId window_id,167UFStatus frame_accept_touch(UFDevice device, UFWindowId window_id,

Subscribers

People subscribed via source and target branches