made channels shared_pointers
This commit is contained in:
@@ -14,7 +14,7 @@ namespace widgets {
|
||||
|
||||
ChatWidget::ChatWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, channel(NULL)
|
||||
, channel(Channels::getEmpty())
|
||||
, channelName(QString())
|
||||
, vbox(this)
|
||||
, header(this)
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
return view;
|
||||
}
|
||||
|
||||
Channel *
|
||||
std::shared_ptr<Channel>
|
||||
getChannel() const
|
||||
{
|
||||
return channel;
|
||||
@@ -49,7 +49,7 @@ protected:
|
||||
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
Channel *channel;
|
||||
std::shared_ptr<Channel> channel;
|
||||
QString channelName;
|
||||
|
||||
QFont font;
|
||||
|
||||
@@ -52,7 +52,9 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *widget)
|
||||
|
||||
this->edit.keyPressed.connect([this](QKeyEvent *event) {
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
Channel *c = this->chatWidget->getChannel();
|
||||
auto ptr = this->chatWidget->getChannel();
|
||||
Channel *c = ptr.get();
|
||||
|
||||
if (c != nullptr) {
|
||||
IrcManager::send("PRIVMSG #" + c->getName() + ": " +
|
||||
this->edit.toPlainText());
|
||||
|
||||
@@ -42,7 +42,7 @@ MainWindow::layoutVisibleChatWidgets(Channel *channel)
|
||||
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
|
||||
ChatWidget *widget = *it;
|
||||
|
||||
if (channel == NULL || channel == widget->getChannel()) {
|
||||
if (channel == NULL || channel == widget->getChannel().get()) {
|
||||
if (widget->getView().layoutMessages()) {
|
||||
widget->update();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ MainWindow::repaintVisibleChatWidgets(Channel *channel)
|
||||
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
|
||||
ChatWidget *widget = *it;
|
||||
|
||||
if (channel == NULL || channel == widget->getChannel()) {
|
||||
if (channel == NULL || channel == widget->getChannel().get()) {
|
||||
widget->getView().layoutMessages();
|
||||
widget->update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user