Skip to content

Commit

Permalink
fix a bug with the chat synposis generated by dbus notifications
Browse files Browse the repository at this point in the history
When searching for the next line, if it didn't find one, index
npos would cause it to wrap around unexpectedly.
  • Loading branch information
cbeck88 committed Jul 14, 2014
1 parent a7617ac commit 4a20dd4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/desktop/dbus_notification.cpp
Expand Up @@ -170,6 +170,8 @@ uint32_t send_dbus_notification(DBusConnection *connection, uint32_t replaces_id

namespace dbus {

const int MAX_MSG_LINES = 5;

void send_notification(const std::string & owner, const std::string & message)
{
DBusConnection *connection = get_dbus_connection();
Expand All @@ -181,9 +183,14 @@ void send_notification(const std::string & owner, const std::string & message)

if (i != i_end) {
i->message = message + "\n" + i->message;
int endl_pos = -1;
for (int ctr = 0; ctr < 5; ctr++)

size_t endl_pos = i->message.find('\n');
size_t ctr = 1;

while (ctr < MAX_MSG_LINES && endl_pos != std::string::npos) {
endl_pos = i->message.find('\n', endl_pos+1);
ctr++;
}

i->message = i->message.substr(0,endl_pos);

Expand Down

0 comments on commit 4a20dd4

Please sign in to comment.