shell_integration: Fix disappearing context menus on Windows #2898
authorJocelyn Turcotte <jturcotte@woboq.com>
Fri, 13 Mar 2015 17:30:45 +0000 (18:30 +0100)
committerJocelyn Turcotte <jturcotte@woboq.com>
Fri, 13 Mar 2015 19:53:59 +0000 (20:53 +0100)
Since each new connection to the socket API would trigger a broadcast
of REGISTER_PATH to all existing connections, opening the context menu
would trigger a SHChangeNotify call of the root directory through
the overlay icon extension, which is currently also connected to the
socket API, waiting for changes.

Fix the issue by sending the initial REGISTER_PATH automatic response
only to the connecting socket.

src/gui/socketapi.cpp
src/gui/socketapi.h

index fa8244f850163000f9d0ae14f3a97daa33932493..6bd86cc6291b074201d9a609e197cb3cbb1bcc75 100644 (file)
@@ -185,8 +185,9 @@ void SocketApi::slotNewConnection()
     broadcastMessage(QLatin1String("ICON_PATH"), iconPath );
 #endif
 
-    foreach( QString alias, FolderMan::instance()->map().keys() ) {
-       slotRegisterPath(alias);
+    foreach( Folder *f, FolderMan::instance()->map() ) {
+        QString message = buildRegisterPathMessage(f->path());
+        sendMessage(socket, message);
     }
 }
 
@@ -226,7 +227,10 @@ void SocketApi::slotRegisterPath( const QString& alias )
 {
     Folder *f = FolderMan::instance()->folder(alias);
     if (f) {
-        broadcastMessage(QLatin1String("REGISTER_PATH"), f->path() );
+        QString message = buildRegisterPathMessage(f->path());
+        foreach(SocketType *socket, _listeners) {
+            sendMessage(socket, message);
+        }
     }
 }
 
@@ -449,6 +453,14 @@ void SocketApi::command_SHARE_MENU_TITLE(const QString &, SocketType* socket)
     sendMessage(socket, QLatin1String("SHARE_MENU_TITLE:") + tr("Share with %1", "parameter is ownCloud").arg(Theme::instance()->appNameGUI()));
 }
 
+QString SocketApi::buildRegisterPathMessage(const QString& path)
+{
+    QFileInfo fi(path);
+    QString message = QLatin1String("REGISTER_PATH:");
+    message.append(QDir::toNativeSeparators(fi.absoluteFilePath()));
+    return message;
+}
+
 SqlQuery* SocketApi::getSqlQuery( Folder *folder )
 {
     if( !folder ) {
index b6c82d925645a5a31a3d91089290d31184c17542..9a383292b6f1745f94ea79eb76c55fa57d2a73ba 100644 (file)
@@ -82,6 +82,7 @@ private:
     Q_INVOKABLE void command_VERSION(const QString& argument, SocketType* socket);
 
     Q_INVOKABLE void command_SHARE_MENU_TITLE(const QString& argument, SocketType* socket);
+    QString buildRegisterPathMessage(const QString& path);
 
 #ifdef SOCKETAPI_TCP
     QTcpServer _localServer;