Ticket #12618: BMessage-WasHandled-12618.patch

File BMessage-WasHandled-12618.patch, 2.2 KB (added by looncraz, 5 years ago)

Patch Candidate

  • headers/private/app/MessagePrivate.h

    From f8b54f01550a65ceadeb5758d57b3af6bf65cf9b Mon Sep 17 00:00:00 2001
    From: looncraz <looncraz@looncraz.net>
    Date: Tue, 26 Jan 2016 15:08:06 +0000
    Subject: [PATCH] Prevent B_COLORS_UPDATED Message Repetition
    
    Add BMessage::Private methods WasHandled() and SetWasHandled().
    Use the above methods to indicate that the B_COLORS_UPDATED message was
    previously handled.
    
    This fixes ticket #12618.
    ---
     headers/private/app/MessagePrivate.h | 18 +++++++++++++++++-
     src/kits/app/Application.cpp         |  8 ++++++++
     2 files changed, 25 insertions(+), 1 deletion(-)
    
    diff --git a/headers/private/app/MessagePrivate.h b/headers/private/app/MessagePrivate.h
    index 9e6a611..946bed5 100644
    a b enum {  
    3232    MESSAGE_FLAG_HAS_SPECIFIERS = 0x0020,
    3333    MESSAGE_FLAG_WAS_DROPPED = 0x0040,
    3434    MESSAGE_FLAG_PASS_BY_AREA = 0x0080,
    35     MESSAGE_FLAG_REPLY_AS_KMESSAGE = 0x0100
     35    MESSAGE_FLAG_REPLY_AS_KMESSAGE = 0x0100,
     36    MESSAGE_FLAG_WAS_HANDLED = 0x0200
    3637};
    3738
    3839
    class BMessage::Private {  
    140141                fMessage->fHeader->flags &= ~MESSAGE_FLAG_WAS_DROPPED;
    141142        }
    142143
     144        void
     145        SetWasHandled(bool wasHandled)
     146        {
     147            if (wasHandled)
     148                fMessage->fHeader->flags |= MESSAGE_FLAG_WAS_HANDLED;
     149            else
     150                fMessage->fHeader->flags &= ~MESSAGE_FLAG_WAS_HANDLED;
     151        }
     152
     153        bool
     154        WasHandled() const
     155        {
     156            return (fMessage->fHeader->flags & MESSAGE_FLAG_WAS_HANDLED) != 0;
     157        }
     158
    143159        status_t
    144160        Clear()
    145161        {
  • src/kits/app/Application.cpp

    diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp
    index 51db371..3e2b79f 100644
    a b  
    4444#include <LaunchRoster.h>
    4545#include <LooperList.h>
    4646#include <MenuWindow.h>
     47#include <MessagePrivate.h>
    4748#include <PicturePrivate.h>
    4849#include <PortLink.h>
    4950#include <RosterPrivate.h>
    BApplication::DispatchMessage(BMessage* message, BHandler* handler)  
    11041105
    11051106        case B_COLORS_UPDATED:
    11061107        {
     1108            // Prevent message from being repeated:
     1109            BMessage::Private messagePrivate(message);
     1110            if (messagePrivate.WasHandled())
     1111                break;
     1112
     1113            messagePrivate.SetWasHandled(true);
     1114
    11071115            AutoLocker<BLooperList> listLock(gLooperList);
    11081116            if (!listLock.IsLocked())
    11091117                break;