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 | |
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
-rw-r--r-- | Swift/QtUI/QtUIFactory.cpp | 29 | ||||
-rw-r--r-- | Swift/QtUI/QtUIFactory.h | 21 |
2 files changed, 28 insertions, 22 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) { diff --git a/Swift/QtUI/QtUIFactory.h b/Swift/QtUI/QtUIFactory.h index a57d509..ce3b533 100644 --- a/Swift/QtUI/QtUIFactory.h +++ b/Swift/QtUI/QtUIFactory.h @@ -6,6 +6,8 @@ #pragma once +#include <vector> + #include <QObject> #include <QPointer> @@ -14,21 +16,20 @@ class QSplitter; namespace Swift { - class QtSettingsProvider; - class SettingsProviderHierachy; - class QtChatTabsBase; class QtChatTabs; - class QtSystemTray; - class QtLoginWindow; - class QtMainWindow; + class QtChatTabsBase; class QtChatTheme; - class QtChatWindowFactory; class QtChatWindow; + class QtChatWindowFactory; + class QtLoginWindow; + class QtMainWindow; + class QtSettingsProvider; + class QtSingleWindow; + class QtSystemTray; + class SettingsProviderHierachy; + class StatusCache; class TimerFactory; - class historyWindow_; class WhiteboardSession; - class StatusCache; - class QtSingleWindow; class QtUIFactory : public QObject, public UIFactory { Q_OBJECT |