Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanly exit Chatterino instead of force exiting #4993

Closed
wants to merge 14 commits into from
Closed
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- Dev: Move `clang-tidy` checker to its own CI job. (#4996)
- Dev: Refactored the Image Uploader feature. (#4971)
- Dev: Fixed deadlock and use-after-free in tests. (#4981)
- Dev: Cleanly exit Chatterino instead of force exiting. (#4993)

## 2.4.6

Expand Down
2 changes: 1 addition & 1 deletion src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Application::Application(Settings &_settings, Paths &_paths)
, emotes(&this->emplace<Emotes>())
, accounts(&this->emplace<AccountController>())
, hotkeys(&this->emplace<HotkeyController>())
, twitch(&this->emplace<TwitchIrcServer>())
, windows(&this->emplace<WindowManager>())
, toasts(&this->emplace<Toasts>())
, imageUploader(&this->emplace<ImageUploader>())
Expand All @@ -117,7 +118,6 @@ Application::Application(Settings &_settings, Paths &_paths)
, commands(&this->emplace<CommandController>())
, notifications(&this->emplace<NotificationController>())
, highlights(&this->emplace<HighlightController>())
, twitch(&this->emplace<TwitchIrcServer>())
, chatterinoBadges(&this->emplace<ChatterinoBadges>())
, ffzBadges(&this->emplace<FfzBadges>())
, seventvBadges(&this->emplace<SeventvBadges>())
Expand Down
2 changes: 1 addition & 1 deletion src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Application : public IApplication
Emotes *const emotes{};
AccountController *const accounts{};
HotkeyController *const hotkeys{};
TwitchIrcServer *const twitch{};
WindowManager *const windows{};
Toasts *const toasts{};
ImageUploader *const imageUploader{};
Expand All @@ -106,7 +107,6 @@ class Application : public IApplication
CommandController *const commands{};
NotificationController *const notifications{};
HighlightController *const highlights{};
TwitchIrcServer *const twitch{};
ChatterinoBadges *const chatterinoBadges{};
FfzBadges *const ffzBadges{};
SeventvBadges *const seventvBadges{};
Expand Down
9 changes: 7 additions & 2 deletions src/RunGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <QtConcurrent>

#include <csignal>
#include <thread>
#include <tuple>

#ifdef USEWINSDK
Expand Down Expand Up @@ -245,6 +246,7 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
});

auto thread = std::thread([dir = paths.miscDirectory] {
#ifdef Q_OS_WIN32
{
auto path = combinePath(dir, "Update.exe");
if (QFile::exists(path))
Expand All @@ -259,6 +261,7 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
QFile::remove(path);
}
}
#endif
});

// Clear the cache 1 minute after start.
Expand Down Expand Up @@ -308,13 +311,15 @@ void runGui(QApplication &a, Paths &paths, Settings &settings)
pajlada::Settings::SettingManager::gSave();
}

if (thread.joinable())
{
thread.join();
}
chatterino::NetworkManager::deinit();

#ifdef USEWINSDK
// flushing windows clipboard to keep copied messages
flushClipboard();
#endif

_exit(0);
}
} // namespace chatterino
5 changes: 4 additions & 1 deletion src/providers/liveupdates/BasicPubSubManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ class BasicPubSubManager
.toStdString());
}

virtual ~BasicPubSubManager() = default;
virtual ~BasicPubSubManager()
{
this->stop();
};

BasicPubSubManager(const BasicPubSubManager &) = delete;
BasicPubSubManager(const BasicPubSubManager &&) = delete;
Expand Down
11 changes: 10 additions & 1 deletion src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,16 @@ WindowManager::WindowManager()
});
}

WindowManager::~WindowManager() = default;
WindowManager::~WindowManager()
{
for (const auto &window : this->windows_)
{
// We would prefer to use window->deleteLater() here, but the timings are too tight
// Channel's completion model gets destroyed before the deleteLater call actually deletes the
// UI objects that rely on the completion model
delete window;
}
}

MessageElementFlags WindowManager::getWordFlags()
{
Expand Down
8 changes: 5 additions & 3 deletions src/widgets/splits/SplitInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
this->installEventFilter(this);
this->initLayout();

auto completer =
new QCompleter(&this->split_->getChannel()->completionModel);
auto *completer =
new QCompleter(&this->split_->getChannel()->completionModel, this);
this->ui_.textEdit->setCompleter(completer);

this->signalHolder_.managedConnect(this->split_->channelChanged, [this] {
auto channel = this->split_->getChannel();
auto completer = new QCompleter(&channel->completionModel);
auto *completer = new QCompleter(&channel->completionModel, this);
this->ui_.textEdit->setCompleter(completer);
});

Expand All @@ -76,6 +76,8 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
});
}

SplitInput::~SplitInput() = default;

void SplitInput::initLayout()
{
auto app = getApp();
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/splits/SplitInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class ResizingTextEdit;
class ChannelView;
enum class CompletionKind;

class SplitInput : public BaseWidget
class SplitInput final : public BaseWidget
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
Q_OBJECT

public:
SplitInput(Split *_chatWidget, bool enableInlineReplying = true);
SplitInput(QWidget *parent, Split *_chatWidget, ChannelView *_channelView,
bool enableInlineReplying = true);
~SplitInput() override;

bool hasSelection() const;
void clearSelection() const;
Expand Down
Loading