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 {
|
32 | 32 | MESSAGE_FLAG_HAS_SPECIFIERS = 0x0020, |
33 | 33 | MESSAGE_FLAG_WAS_DROPPED = 0x0040, |
34 | 34 | 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 |
36 | 37 | }; |
37 | 38 | |
38 | 39 | |
… |
… |
class BMessage::Private {
|
140 | 141 | fMessage->fHeader->flags &= ~MESSAGE_FLAG_WAS_DROPPED; |
141 | 142 | } |
142 | 143 | |
| 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 | |
143 | 159 | status_t |
144 | 160 | Clear() |
145 | 161 | { |
diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp
index 51db371..3e2b79f 100644
a
|
b
|
|
44 | 44 | #include <LaunchRoster.h> |
45 | 45 | #include <LooperList.h> |
46 | 46 | #include <MenuWindow.h> |
| 47 | #include <MessagePrivate.h> |
47 | 48 | #include <PicturePrivate.h> |
48 | 49 | #include <PortLink.h> |
49 | 50 | #include <RosterPrivate.h> |
… |
… |
BApplication::DispatchMessage(BMessage* message, BHandler* handler)
|
1104 | 1105 | |
1105 | 1106 | case B_COLORS_UPDATED: |
1106 | 1107 | { |
| 1108 | // Prevent message from being repeated: |
| 1109 | BMessage::Private messagePrivate(message); |
| 1110 | if (messagePrivate.WasHandled()) |
| 1111 | break; |
| 1112 | |
| 1113 | messagePrivate.SetWasHandled(true); |
| 1114 | |
1107 | 1115 | AutoLocker<BLooperList> listLock(gLooperList); |
1108 | 1116 | if (!listLock.IsLocked()) |
1109 | 1117 | break; |