Ticket #12799: 0001-Fix-12799-Make-BClipboard-compatible-with-BeOS-again.patch

File 0001-Fix-12799-Make-BClipboard-compatible-with-BeOS-again.patch, 5.0 KB (added by markh, 3 years ago)
  • docs/user/app/Clipboard.dox

    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()) {  
    287287    You should call Clear() before adding new data to the BClipboard object.
    288288
    289289    \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.
    294292
    295293    \since BeOS R3
    296294*/
    if (be_clipboard->Lock()) {  
    301299    \brief Commits the clipboard data to the BClipboard object.
    302300
    303301    \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.
    307304
    308305    \since BeOS R3
    309306*/
    if (be_clipboard->Lock()) {  
    318315        if there is a change in the clipboard data.
    319316
    320317        \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.
    324321
    325     \since BeOS R5
     322    \since Haiku R1
    326323*/
    327324
    328325
    if (be_clipboard->Lock()) {  
    335332    committing it.
    336333
    337334    \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.
    342337
    343338    \since BeOS R5
    344339*/
  • src/kits/app/Clipboard.cpp

    diff --git a/src/kits/app/Clipboard.cpp b/src/kits/app/Clipboard.cpp
    index a17ea09..67d55f8 100644
    a b status_t  
    181181BClipboard::Clear()
    182182{
    183183    if (!_AssertLocked())
    184         return B_NOT_ALLOWED;
     184        return B_ERROR;
    185185
    186     return fData->MakeEmpty();
     186    fData->MakeEmpty();
     187   
     188    return B_OK;
    187189}
    188190
    189191
    190192status_t
    191193BClipboard::Commit()
    192194{
    193     return Commit(false);
     195    if (!_AssertLocked())
     196        return B_ERROR;
     197
     198    Commit(false);
     199   
     200    return B_OK;
    194201}
    195202
    196203
    status_t  
    198205BClipboard::Commit(bool failIfChanged)
    199206{
    200207    if (!_AssertLocked())
    201         return B_NOT_ALLOWED;
     208        return B_ERROR;
    202209
    203     status_t status = B_ERROR;
     210    status_t status;
    204211    BMessage message(B_REG_UPLOAD_CLIPBOARD), reply;
    205212    if (message.AddString("name", fName) == B_OK
    206213        && message.AddMessage("data", fData) == B_OK
    BClipboard::Commit(bool failIfChanged)  
    208215        && message.AddInt32("count", fCount) == B_OK
    209216        && message.AddBool("fail if changed", failIfChanged) == B_OK)
    210217        status = fClipHandler.SendMessage(&message, &reply);
     218    else
     219        status = B_NO_MEMORY;
    211220
    212221    if (status == B_OK) {
    213222        int32 count;
    status_t  
    223232BClipboard::Revert()
    224233{
    225234    if (!_AssertLocked())
    226         return B_NOT_ALLOWED;
     235        return B_ERROR;
    227236
    228237    status_t status = fData->MakeEmpty();
    229238    if (status == B_OK)
    230         status = _DownloadFromSystem();
     239        _DownloadFromSystem();
    231240
    232     return status;
     241    return B_OK;
    233242}
    234243
    235244
    void BClipboard::_ReservedClipboard3() {}  
    274283bool
    275284BClipboard::_AssertLocked() const
    276285{
    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();
    283287}
    284288
    285289
  • src/tests/kits/app/bclipboard/ReadWriteTester.cpp

    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()  
    3838#ifdef TEST_R5
    3939  CHK(false);
    4040#endif
    41   CPPUNIT_ASSERT_DEBUGGER(clip.Clear());
     41  CHK(clip.Clear() == B_ERROR);
    4242}
    4343
    4444/*
    void ReadWriteTester::Revert1()  
    7474#ifdef TEST_R5
    7575  CHK(false);
    7676#endif
    77   CPPUNIT_ASSERT_DEBUGGER(clip.Revert());
     77  CHK(clip.Revert() == B_ERROR);
    7878}
    7979
    8080/*
    void ReadWriteTester::Commit1()  
    132132#ifdef TEST_R5
    133133  CHK(false);
    134134#endif
    135   CPPUNIT_ASSERT_DEBUGGER(clip.Commit());
     135  CHK(clip.Commit() == B_ERROR);
    136136}
    137137
    138138/*
    void ReadWriteTester::Data1()  
    184184#ifdef TEST_R5
    185185  CHK(false);
    186186#endif
    187   CPPUNIT_ASSERT_DEBUGGER(clip.Data());
     187  CHK(clip.Data() == NULL);
    188188}
    189189
    190190/*