← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2858: fix "Max PM windows"

 

------------------------------------------------------------
revno: 2858
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2012-02-06 00:14:50 +0100
message:
  fix "Max PM windows"
modified:
  win32/HubFrame.cpp
  win32/PrivateFrame.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp	2012-02-04 18:32:29 +0000
+++ win32/HubFrame.cpp	2012-02-05 23:14:50 +0000
@@ -660,7 +660,11 @@
 		addStatus(str(TF_("Ignored message: %1%") % Text::toT(message.message)), false);
 
 	} else {
-		if(!window || !PrivateFrame::gotMessage(getParent(), message.from, message.to, message.replyTo, message, url)) {
+		if(window && !PrivateFrame::gotMessage(getParent(), message.from, message.to, message.replyTo, message, url)) {
+			window = false;
+			addStatus(T_("Failed to create a new PM window; check the \"Max PM windows\" value in Settings > Experts only"));
+		}
+		if(!window) {
 			/// @todo add formatting here (for PMs in main chat)
 			addChat(str(TF_("Private message from %1%: %2%") % getNick(message.from) % Text::toT(message.message)));
 		}

=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp	2012-02-04 17:40:35 +0000
+++ win32/PrivateFrame.cpp	2012-02-05 23:14:50 +0000
@@ -59,13 +59,15 @@
 bool PrivateFrame::gotMessage(TabViewPtr parent, const UserPtr& from, const UserPtr& to, const UserPtr& replyTo,
 	const ChatMessage& message, const string& hubHint)
 {
-	if(frames.size() >= SETTING(MAX_PM_WINDOWS)) {
-		return false;
-	}
-
 	const UserPtr& user = (replyTo == ClientManager::getInstance()->getMe()) ? to : replyTo;
 	auto i = frames.find(user);
 	if(i == frames.end()) {
+		// creating a new window
+
+		if(frames.size() >= SETTING(MAX_PM_WINDOWS)) {
+			return false;
+		}
+
 		auto p = new PrivateFrame(parent, HintedUser(user, hubHint));
 		if(!BOOLSETTING(POPUNDER_PM))
 			p->activate();
@@ -82,6 +84,7 @@
 		WinUtil::notify(WinUtil::NOTIFICATION_PM_WINDOW, Text::toT(message.message), [user] { activateWindow(user); });
 
 	} else {
+		// send the message to the existing window
 		i->second->addChat(message);
 	}