Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix: fix segfault while trying to send messages
Browse files Browse the repository at this point in the history
Unfortunately, can not pass local variable on ChatLine::Ptr through
several method calls so ChatMessage inserted after its creating in the
same scope. Updated docs
  • Loading branch information
noavarice committed Apr 26, 2017
1 parent 037f669 commit b5f4628
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ bool GenericChatForm::needsToHideName(const ToxPk &messageAuthor) const
}

/**
* @brief Creates ChatMessage shared object that later will be inserted into ChatLog
* @brief Creates ChatMessage shared object and inserts it into ChatLog
* @param author Author of the message
* @param message Message text
* @param dt Date and time when message was sent
Expand Down Expand Up @@ -425,6 +425,7 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri
msg->markAsSent(dt);
}

insertChatMessage(msg);
return msg;
}

Expand All @@ -444,7 +445,7 @@ ChatMessage::Ptr GenericChatForm::createSelfMessage(const QString& message, cons
void GenericChatForm::addMessage(const ToxPk& author, const QString& message, const QDateTime& dt,
bool isAction)
{
insertChatMessage(createMessage(author, message, dt, isAction, true));
createMessage(author, message, dt, isAction, true);
}

/**
Expand All @@ -453,7 +454,7 @@ void GenericChatForm::addMessage(const ToxPk& author, const QString& message, co
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime,
bool isAction)
{
insertChatMessage(createSelfMessage(message, datetime, isAction, true));
createSelfMessage(message, datetime, isAction, true);
}

void GenericChatForm::addAlertMessage(const ToxPk& author, const QString& msg, const QDateTime& dt)
Expand Down

0 comments on commit b5f4628

Please sign in to comment.