From 5f892014508eecc86dfb0eea54257238b394308c Mon Sep 17 00:00:00 2001
From: Mark Hellegers <mark@firedisk.net>
Date: Sat, 28 May 2016 17:21:03 +0000
Subject: [PATCH] Fix #12799: Make BClipboard compatible with BeOS again.
---
docs/user/app/Clipboard.dox | 25 +++++++-----------
src/kits/app/Clipboard.cpp | 32 +++++++++++++----------
src/tests/kits/app/bclipboard/ReadWriteTester.cpp | 8 +++---
3 files changed, 32 insertions(+), 33 deletions(-)
diff --git a/docs/user/app/Clipboard.dox b/docs/user/app/Clipboard.dox
index c34a77e..c91b83f 100644
a
|
b
|
if (be_clipboard->Lock()) {
|
287 | 287 | You should call Clear() before adding new data to the BClipboard object. |
288 | 288 | |
289 | 289 | \return A status code. |
290 | | \retval B_OK Everything went find. |
291 | | \retval B_NOT_ALLOWED The clipboard is not locked. |
292 | | \retval B_NO_MEMORY Ran out of memory initializing the data message. |
293 | | \retval B_ERROR Another error occurred. |
| 290 | \retval B_OK Everything went fine. |
| 291 | \retval B_ERROR The clipboard is not locked. |
294 | 292 | |
295 | 293 | \since BeOS R3 |
296 | 294 | */ |
… |
… |
if (be_clipboard->Lock()) {
|
301 | 299 | \brief Commits the clipboard data to the BClipboard object. |
302 | 300 | |
303 | 301 | \return A status code. |
304 | | \retval B_OK Everything went find. |
305 | | \retval B_NOT_ALLOWED The clipboard is not locked. |
306 | | \retval B_ERROR Another error occurred. |
| 302 | \retval B_OK Everything went fine. |
| 303 | \retval B_ERROR The clipboard is not locked. |
307 | 304 | |
308 | 305 | \since BeOS R3 |
309 | 306 | */ |
… |
… |
if (be_clipboard->Lock()) {
|
318 | 315 | if there is a change in the clipboard data. |
319 | 316 | |
320 | 317 | \return A status code. |
321 | | \retval B_OK Everything went find. |
322 | | \retval B_NOT_ALLOWED The clipboard is not locked. |
323 | | \retval B_ERROR Another error occurred. |
| 318 | \retval B_OK Everything went fine. |
| 319 | \retval B_ERROR The clipboard is not locked. |
| 320 | \retval B_NO_MEMORY Ran out of memory initializing the data message. |
324 | 321 | |
325 | | \since BeOS R5 |
| 322 | \since Haiku R1 |
326 | 323 | */ |
327 | 324 | |
328 | 325 | |
… |
… |
if (be_clipboard->Lock()) {
|
335 | 332 | committing it. |
336 | 333 | |
337 | 334 | \return A status code. |
338 | | \retval B_OK Everything went find. |
339 | | \retval B_NOT_ALLOWED The clipboard is not locked. |
340 | | \retval B_NO_MEMORY Ran out of memory initializing the data message. |
341 | | \retval B_ERROR Another error occurred. |
| 335 | \retval B_OK Everything went fine. |
| 336 | \retval B_ERROR The clipboard is not locked. |
342 | 337 | |
343 | 338 | \since BeOS R5 |
344 | 339 | */ |
diff --git a/src/kits/app/Clipboard.cpp b/src/kits/app/Clipboard.cpp
index a17ea09..67d55f8 100644
a
|
b
|
status_t
|
181 | 181 | BClipboard::Clear() |
182 | 182 | { |
183 | 183 | if (!_AssertLocked()) |
184 | | return B_NOT_ALLOWED; |
| 184 | return B_ERROR; |
185 | 185 | |
186 | | return fData->MakeEmpty(); |
| 186 | fData->MakeEmpty(); |
| 187 | |
| 188 | return B_OK; |
187 | 189 | } |
188 | 190 | |
189 | 191 | |
190 | 192 | status_t |
191 | 193 | BClipboard::Commit() |
192 | 194 | { |
193 | | return Commit(false); |
| 195 | if (!_AssertLocked()) |
| 196 | return B_ERROR; |
| 197 | |
| 198 | Commit(false); |
| 199 | |
| 200 | return B_OK; |
194 | 201 | } |
195 | 202 | |
196 | 203 | |
… |
… |
status_t
|
198 | 205 | BClipboard::Commit(bool failIfChanged) |
199 | 206 | { |
200 | 207 | if (!_AssertLocked()) |
201 | | return B_NOT_ALLOWED; |
| 208 | return B_ERROR; |
202 | 209 | |
203 | | status_t status = B_ERROR; |
| 210 | status_t status; |
204 | 211 | BMessage message(B_REG_UPLOAD_CLIPBOARD), reply; |
205 | 212 | if (message.AddString("name", fName) == B_OK |
206 | 213 | && message.AddMessage("data", fData) == B_OK |
… |
… |
BClipboard::Commit(bool failIfChanged)
|
208 | 215 | && message.AddInt32("count", fCount) == B_OK |
209 | 216 | && message.AddBool("fail if changed", failIfChanged) == B_OK) |
210 | 217 | status = fClipHandler.SendMessage(&message, &reply); |
| 218 | else |
| 219 | status = B_NO_MEMORY; |
211 | 220 | |
212 | 221 | if (status == B_OK) { |
213 | 222 | int32 count; |
… |
… |
status_t
|
223 | 232 | BClipboard::Revert() |
224 | 233 | { |
225 | 234 | if (!_AssertLocked()) |
226 | | return B_NOT_ALLOWED; |
| 235 | return B_ERROR; |
227 | 236 | |
228 | 237 | status_t status = fData->MakeEmpty(); |
229 | 238 | if (status == B_OK) |
230 | | status = _DownloadFromSystem(); |
| 239 | _DownloadFromSystem(); |
231 | 240 | |
232 | | return status; |
| 241 | return B_OK; |
233 | 242 | } |
234 | 243 | |
235 | 244 | |
… |
… |
void BClipboard::_ReservedClipboard3() {}
|
274 | 283 | bool |
275 | 284 | BClipboard::_AssertLocked() const |
276 | 285 | { |
277 | | // This function is for jumping to the debugger if not locked |
278 | | if (!fLock.IsLocked()) { |
279 | | debugger("The clipboard must be locked before proceeding."); |
280 | | return false; |
281 | | } |
282 | | return true; |
| 286 | return fLock.IsLocked(); |
283 | 287 | } |
284 | 288 | |
285 | 289 | |
diff --git a/src/tests/kits/app/bclipboard/ReadWriteTester.cpp b/src/tests/kits/app/bclipboard/ReadWriteTester.cpp
index 5d445be..707ad9d 100644
a
|
b
|
void ReadWriteTester::Clear1()
|
38 | 38 | #ifdef TEST_R5 |
39 | 39 | CHK(false); |
40 | 40 | #endif |
41 | | CPPUNIT_ASSERT_DEBUGGER(clip.Clear()); |
| 41 | CHK(clip.Clear() == B_ERROR); |
42 | 42 | } |
43 | 43 | |
44 | 44 | /* |
… |
… |
void ReadWriteTester::Revert1()
|
74 | 74 | #ifdef TEST_R5 |
75 | 75 | CHK(false); |
76 | 76 | #endif |
77 | | CPPUNIT_ASSERT_DEBUGGER(clip.Revert()); |
| 77 | CHK(clip.Revert() == B_ERROR); |
78 | 78 | } |
79 | 79 | |
80 | 80 | /* |
… |
… |
void ReadWriteTester::Commit1()
|
132 | 132 | #ifdef TEST_R5 |
133 | 133 | CHK(false); |
134 | 134 | #endif |
135 | | CPPUNIT_ASSERT_DEBUGGER(clip.Commit()); |
| 135 | CHK(clip.Commit() == B_ERROR); |
136 | 136 | } |
137 | 137 | |
138 | 138 | /* |
… |
… |
void ReadWriteTester::Data1()
|
184 | 184 | #ifdef TEST_R5 |
185 | 185 | CHK(false); |
186 | 186 | #endif |
187 | | CPPUNIT_ASSERT_DEBUGGER(clip.Data()); |
| 187 | CHK(clip.Data() == NULL); |
188 | 188 | } |
189 | 189 | |
190 | 190 | /* |