[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kdnssd/multiengine/kdelibs/dnssd
From:       Jakub Stachowski <qbast () go2 ! pl>
Date:       2005-08-02 9:18:10
Message-ID: 1122974290.944433.12752.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 442295 by qbast:

scope->stop() now removes all children



 M  +4 -4      dnssdtest.cpp  
 M  +0 -6      engines/test/testengine.cpp  
 M  +9 -4      scope.cpp  
 M  +8 -0      scope.h  


--- branches/work/kdnssd/multiengine/kdelibs/dnssd/dnssdtest.cpp #442294:442295
@@ -82,13 +82,13 @@
 */	result_called=0;
 	kdDebug() << "Stopping\n";
 	discoRoot->stop();
-	while (result_called<4) qApp->processEvents();
-	CHECK(result_called,4);
+	while (result_called<6) qApp->processEvents();
+	CHECK(result_called,6);
 	result_called=0;
 	kdDebug() << "Restarting\n";
 	discoRoot->start();
-	while (result_called<4) qApp->processEvents();
-	CHECK(result_called,4);
+	while (result_called<6) qApp->processEvents();
+	CHECK(result_called,6);
 	QHash<QString,QVariant> d2;
 	d2["enabled"]=false;
 	result_called=0;
--- branches/work/kdnssd/multiengine/kdelibs/dnssd/engines/test/testengine.cpp #442294:442295
@@ -53,12 +53,6 @@
 		new Scope(m_num+"-child1.test",this,m_engine,"Child 1 of "+m_num);
 		new Scope(m_num+"-child2.test",this,m_engine,"Child 2 of "+m_num);
 		}
-	virtual void stop() {
-		if (!m_running) return;
-		Runner::stop();
-		delete (findChild<Scope*>(m_num+"-child1.test"));
-		delete (findChild<Scope*>(m_num+"-child2.test"));
-		}
 private:
 	QString m_num;
 };
--- branches/work/kdnssd/multiengine/kdelibs/dnssd/scope.cpp #442294:442295
@@ -81,6 +81,12 @@
 	stop();
 }
 
+void ActiveScope::stop() 
+{
+	Runner::stop();
+	foreach (QObject* child,children()) delete child;
+}	
+
 // FIXME: import correct catalog!
 RootScope::RootScope(Scope::Type type) : Scope("everything.core",0,0,i18n("Everything")), 
 	m_type(type),	m_running(false)
@@ -94,9 +100,7 @@
 {
 	if (m_running) return;
 	m_running=true;
-	// if there are main scopes then initialization is already done
-	if (m_mainScopes.count()) foreach (ActiveScope* scope, m_mainScopes) scope->start();
-	else foreach(Engine* eng, EngineList::self().engines()) 
+	foreach(Engine* eng, EngineList::self().engines()) 
 		if (eng->capabilities()&m_type && eng->capabilities()&Engine::Scopes) {
 		QList<ActiveScope*> l = eng->getScopes(m_type,this);
 		foreach (ActiveScope* scope,l) {
@@ -111,7 +115,8 @@
 void RootScope::stop()
 {
 	if (!m_running) return;
-	foreach (ActiveScope* scope, m_mainScopes) scope->stop();
+	foreach (ActiveScope* scope, m_mainScopes) delete scope;
+	m_mainScopes.clear();
 	m_running=false;
 }
 
--- branches/work/kdnssd/multiengine/kdelibs/dnssd/scope.h #442294:442295
@@ -99,6 +99,10 @@
 	ActiveScope(QString name, Scope* parent, Engine* engine, QString prettyName) 
 		: Scope(name,parent,engine,prettyName), Runner() {};
 	virtual ~ActiveScope();
+	/**
+	 Stops searching and removes all children
+	 */
+	virtual void stop();
 };
 /**
 Root node of scopes tree (discovery or publishing).
@@ -111,6 +115,10 @@
 	RootScope(Scope::Type type);
 	virtual ~RootScope();
 	void start();
+
+	/**
+	 Stop searching and remove all children.
+	 */
 	void stop();
 	/**
 	Set detailed engine properties. It allow to more fine tuned control over separate discovery engines. 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic