Browse Source

fix: fix segfault while trying to send messages

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
pull/4351/head
noavarice 8 years ago
parent
commit
b5f4628c89
  1. 7
      src/widget/form/genericchatform.cpp

7
src/widget/form/genericchatform.cpp

@ -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 author Author of the message
* @param message Message text * @param message Message text
* @param dt Date and time when message was sent * @param dt Date and time when message was sent
@ -425,6 +425,7 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri
msg->markAsSent(dt); msg->markAsSent(dt);
} }
insertChatMessage(msg);
return msg; return msg;
} }
@ -444,7 +445,7 @@ ChatMessage::Ptr GenericChatForm::createSelfMessage(const QString& message, cons
void GenericChatForm::addMessage(const ToxPk& author, const QString& message, const QDateTime& dt, void GenericChatForm::addMessage(const ToxPk& author, const QString& message, const QDateTime& dt,
bool isAction) bool isAction)
{ {
insertChatMessage(createMessage(author, message, dt, isAction, true)); createMessage(author, message, dt, isAction, true);
} }
/** /**
@ -453,7 +454,7 @@ void GenericChatForm::addMessage(const ToxPk& author, const QString& message, co
void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime, void GenericChatForm::addSelfMessage(const QString& message, const QDateTime& datetime,
bool isAction) 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) void GenericChatForm::addAlertMessage(const ToxPk& author, const QString& msg, const QDateTime& dt)

Loading…
Cancel
Save