From a6ecc8855a0a2a8f76234f77422940b863960944 Mon Sep 17 00:00:00 2001
From: Antonio Rojas <arojas@archlinux.org>
Date: Sat, 2 Oct 2021 12:53:27 +0200
Subject: [PATCH] Fix kio-mtp with libmtp 1.1.19

In libmtp 1.1.19, an empty string is returned instead of NULL for devices without a deviceName, which breaks accessing those devices with kio-mtp
---
 mtp/kiod_module/mtpdevice.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mtp/kiod_module/mtpdevice.cpp b/mtp/kiod_module/mtpdevice.cpp
index 8fe4abb2..f32cd1a4 100644
--- a/mtp/kiod_module/mtpdevice.cpp
+++ b/mtp/kiod_module/mtpdevice.cpp
@@ -40,7 +40,7 @@ MTPDevice::MTPDevice(const QString &dbusObjectPath, LIBMTP_mtpdevice_t *device,
     const char *deviceModel = LIBMTP_Get_Modelname(device);
 
     // prefer friendly devicename over model
-    if (!deviceName) {
+    if (!deviceName || strlen(deviceName) == 0) {
         m_friendlyName = QString::fromUtf8(deviceModel);
     } else {
         m_friendlyName = QString::fromUtf8(deviceName);
-- 
GitLab

