soc.2008.masterpassword: 3bc9cb71: It seems that std::list manages its elem...

qulogic at pidgin.im qulogic at pidgin.im
Sat Nov 12 04:01:22 EST 2011


----------------------------------------------------------------------
Revision: 3bc9cb71010bf337ae332ae89ddce3b10e14045b
Parent:   9f4f1b251faf390a768c41cbad2e7b8774dcdb6c
Author:   qulogic at pidgin.im
Date:     11/12/11 00:10:38
Branch:   im.pidgin.soc.2008.masterpassword
URL: http://d.pidgin.im/viewmtn/revision/info/3bc9cb71010bf337ae332ae89ddce3b10e14045b

Changelog: 

It seems that std::list manages its elements, so there's no need to
delete things. Also, I don't know C++ well, but iterating and deleting
items at the same time seems wrong to me.

Changes against parent 9f4f1b251faf390a768c41cbad2e7b8774dcdb6c

  patched  libpurple/plugins/keyrings/kwallet.cpp

-------------- next part --------------
============================================================
--- libpurple/plugins/keyrings/kwallet.cpp	605efa865d94698b091794d4e9f0f4666dd7a17a
+++ libpurple/plugins/keyrings/kwallet.cpp	ae99e193519d845fbe97785349fbf8cfd5a50d44
@@ -134,10 +134,9 @@ KWalletPlugin::engine::~engine()
 
 KWalletPlugin::engine::~engine()
 {
-	std::list<request>::iterator it;
-
-	for(it = requests.begin(); it != requests.end(); it++) {
-		it->abort();
+	while (!requests.empty()) {
+		request &req = requests.front();
+		req.abort();
 		requests.pop_front();
 	}
 
@@ -157,15 +156,14 @@ KWalletPlugin::engine::walletOpened(bool
 void
 KWalletPlugin::engine::walletOpened(bool opened)
 {
-	std::list<request>::iterator it;
-
 	connected = opened;
 
 	if (opened) {
 		ExecuteRequests();
 	} else {
-		for (it = requests.begin(); it != requests.end(); it++) {
-			it->abort();
+		while (!requests.empty()) {
+			request &req = requests.front();
+			req.abort();
 			requests.pop_front();
 		}
 		delete this;
@@ -182,13 +180,11 @@ KWalletPlugin::engine::ExecuteRequests()
 void
 KWalletPlugin::engine::ExecuteRequests()
 {
-	std::list<request>::iterator it;
-
 	if (connected) {
-		for (it = requests.begin(); it != requests.end(); it++) {
-			it->execute(wallet);
+		while (!requests.empty()) {
+			request &req = requests.front();
+			req.execute(wallet);
 			requests.pop_front();
-			delete it;
 		}
 	}
 }


More information about the Commits mailing list