diff options
author | Tobias Markmann <tm@ayena.de> | 2016-11-01 16:22:19 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-11-01 16:35:02 (GMT) |
commit | c867e55403de9691bc0657378a078cf2bd774b85 (patch) | |
tree | f5da8456739aa0174fb4875ee9d59ae3f9800136 /Swift/QtUI/QtUIFactory.cpp | |
parent | 97bc94bfee234d5ca93e61a55c13d864ddd79ec6 (diff) | |
download | swift-c867e55403de9691bc0657378a078cf2bd774b85.zip swift-c867e55403de9691bc0657378a078cf2bd774b85.tar.bz2 |
Explicitly synchronize chat view font sizes on font size change
Test-Information:
Unit tests pass with Qt 5.7.0. Chat view sizes are synchronised
on change. ASAN does not complain when opening/closing lots
of chat windows and then closing Swift.
Change-Id: Ib00260d2331f48f0ca3c47a2340311dcff85c5ed
Diffstat (limited to 'Swift/QtUI/QtUIFactory.cpp')
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp index a9e0e8f..9eed822 100644 --- a/Swift/QtUI/QtUIFactory.cpp +++ b/Swift/QtUI/QtUIFactory.cpp @@ -6,6 +6,8 @@ #include <Swift/QtUI/QtUIFactory.h> +#include <algorithm> + #include <QSplitter> #include <Swiften/Whiteboard/WhiteboardSession.h> @@ -120,19 +122,15 @@ MUCSearchWindow* QtUIFactory::createMUCSearchWindow() { ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eventStream) { QtChatWindow* window = dynamic_cast<QtChatWindow*>(chatWindowFactory->createChatWindow(contact, eventStream)); + + // remove already closed and thereby deleted chat windows + chatWindows.erase(std::remove_if(chatWindows.begin(), chatWindows.end(), + [](QPointer<QtChatWindow>& window) { + return window.isNull(); + }), chatWindows.end()); + chatWindows.push_back(window); - std::vector<QPointer<QtChatWindow> > deletions; - foreach (QPointer<QtChatWindow> existingWindow, chatWindows) { - if (existingWindow.isNull()) { - deletions.push_back(existingWindow); - } else { - connect(window, SIGNAL(fontResized(int)), existingWindow, SLOT(handleFontResized(int))); - connect(existingWindow, SIGNAL(fontResized(int)), window, SLOT(handleFontResized(int))); - } - } - foreach (QPointer<QtChatWindow> deletedWindow, deletions) { - chatWindows.erase(std::remove(chatWindows.begin(), chatWindows.end(), deletedWindow), chatWindows.end()); - } + connect(window, SIGNAL(fontResized(int)), this, SLOT(handleChatWindowFontResized(int))); window->handleFontResized(chatFontSize); return window; @@ -141,6 +139,13 @@ ChatWindow* QtUIFactory::createChatWindow(const JID& contact, UIEventStream* eve void QtUIFactory::handleChatWindowFontResized(int size) { chatFontSize = size; settings->storeSetting(QtUISettingConstants::CHATWINDOW_FONT_SIZE, size); + + // resize font in other chat windows + for (auto&& existingWindow : chatWindows) { + if (!existingWindow.isNull()) { + existingWindow->handleFontResized(size); + } + } } UserSearchWindow* QtUIFactory::createUserSearchWindow(UserSearchWindow::Type type, UIEventStream* eventStream, const std::set<std::string>& groups) { |