Don't call method on potentially null object
authorKevin Ottens <kevin.ottens@nextcloud.com>
Mon, 15 Jun 2020 18:20:40 +0000 (20:20 +0200)
committerKevin Ottens <ervin@ipsquad.net>
Tue, 16 Jun 2020 17:15:53 +0000 (19:15 +0200)
We were calling accountState() on a "folder" member which could be
nullptr. In fact this would happen any time one right click on a file
outside of a sync dir under Windows, this thus led to a crash.

Since the capabilities variable was unused anyway, we just removed it.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/gui/socketapi.cpp

index 3daa9bc23eab9f2943b8a1e036aec71bd54ad7c4..ad5e5758bdfc42cb1886dacc6ce8341cd72002aa 100644 (file)
@@ -799,7 +799,6 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
     FileData fileData = hasSeveralFiles ? FileData{} : FileData::get(argument);
     bool isOnTheServer = fileData.journalRecord().isValid();
     auto flagString = isOnTheServer ? QLatin1String("::") : QLatin1String(":d:");
-    auto capabilities = fileData.folder->accountState()->account()->capabilities();
 
     if (fileData.folder && fileData.folder->accountState()->isConnected()) {
         DirectEditor* editor = getDirectEditorForLocalFile(fileData.localPath);