Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > by-pkgid > a4e51422fe1b8d073f47c12205a319a3 > files > 9

kdelibs-3.5.10-4.4mdv2009.0.src.rpm

--- kdelibs-3.5.4/kdecore/kapplication.cpp.orig	2006-09-28 17:47:15.000000000 -0400
+++ kdelibs-3.5.4/kdecore/kapplication.cpp	2006-09-28 17:51:41.000000000 -0400
@@ -2626,12 +2626,18 @@
    if (!dcopClient->call(_launcher, _launcher,
         function, params, replyType, replyData))
    {
-        if (error)
-           *error = i18n("KLauncher could not be reached via DCOP.\n");
-        if (!kapp)
-           delete dcopClient;
-        return -1;
-   }
+			if (error)
+			   *error = i18n("KLauncher could not be reached via DCOP.\n");
+			if (!kapp)
+			   delete dcopClient;
+			return -1;
+	   }
+	   if (replyType != "serviceResult")
+      {
+	      kdDebug() << "kapplication: dcopClient() returned wrong type. Reply type: " << replyType << endl;
+         noWait = true;
+      }
+
    if (!kapp)
       delete dcopClient;
 
--- kdelibs-3.5.4/kio/kio/slave.cpp.dcop_wrong_reply	2005-10-10 11:05:42.000000000 -0400
+++ kdelibs-3.5.4/kio/kio/slave.cpp	2006-09-29 13:32:23.000000000 -0400
@@ -354,7 +354,7 @@
 
 Slave* Slave::createSlave( const QString &protocol, const KURL& url, int& error, QString& error_text )
 {
-    //kdDebug(7002) << "createSlave '" << protocol << "' for " << url.prettyURL() << endl;
+    kdDebug(7002) << "createSlave '" << protocol << "' for " << url.prettyURL() << endl;
     // Firstly take into account all special slaves
     if (protocol == "data")
         return new DataProtocol();
@@ -432,29 +432,41 @@
     stream << protocol << url.host() << socketfile.name();
 
     QCString launcher = KApplication::launcher();
-    if (!client->call(launcher, launcher, "requestSlave(QString,QString,QString)",
-	    params, replyType, reply)) {
-	error_text = i18n("Cannot talk to klauncher");
-	error = KIO::ERR_SLAVE_DEFINED;
-        delete slave;
-        return 0;
-    }
-    QDataStream stream2(reply, IO_ReadOnly);
-    QString errorStr;
-    pid_t pid;
-    stream2 >> pid >> errorStr;
-    if (!pid)
-    {
-        error_text = i18n("Unable to create io-slave:\nklauncher said: %1").arg(errorStr);
-        error = KIO::ERR_CANNOT_LAUNCH_PROCESS;
-        delete slave;
-        return 0;
-    }
+   // FIXME: there is a bug in dcop that makes it reply requests out
+   // of order and the messages are then wrongly delivered.
+   // We didn't find the proper fix, so we are just trying more than once
+   // to make the call praying for it to reply correctly.
+
+   if (!client->call(launcher, launcher, "requestSlave(QString,QString,QString)", params, replyType, reply)) 
+   {
+      kdDebug() << "slave: 1 - requestSlave() returned wrong type = " << replyType << endl;
+      error_text = i18n("Cannot talk to klauncher");
+      error = KIO::ERR_SLAVE_DEFINED;
+      delete slave;
+      return 0;
+   }
+   
+   if (replyType == "QString")
+   {
+      QDataStream stream2(reply, IO_ReadOnly);
+      QString errorStr;
+      pid_t pid;
+      stream2 >> pid >> errorStr;
+      if (!pid)
+      {
+         error_text = i18n("Unable to create io-slave:\nklauncher said: %1").arg(errorStr);
+         error = KIO::ERR_CANNOT_LAUNCH_PROCESS;
+         delete slave;
+         return 0;
+      }
 #ifndef Q_WS_WIN
-    slave->setPID(pid);
-    QTimer::singleShot(1000*SLAVE_CONNECTION_TIMEOUT_MIN, slave, SLOT(timeout()));
+      slave->setPID(pid);
+      QTimer::singleShot(1000*SLAVE_CONNECTION_TIMEOUT_MIN, slave, SLOT(timeout()));
 #endif
-    return slave;
+   }
+   else
+      kdDebug() << "slave: 2 - requestSlave() returned wrong type = " << replyType << endl;
+   return slave;
 }
 
 Slave* Slave::holdSlave( const QString &protocol, const KURL& url )