Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Backport [25131] from trunk...

Make handling of untitled volumes more reliable (like the one that TimeMachine
creates temporarily).  Users still need to add something like this:
'/Volumes/TimeMachine,/Volumes/TimeMachine 1' into Ignore Devices, though.


git-svn-id: http://svn.mythtv.org/svn/branches/release-0-23-fixes@25132 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information...
commit a939b9b163b3c4efa953944b6edb00e94592d922 1 parent d86cdc3
@NigelPearson NigelPearson authored
Showing with 19 additions and 8 deletions.
  1. +19 −8 mythtv/libs/libmyth/mediamonitor-darwin.cpp
View
27 mythtv/libs/libmyth/mediamonitor-darwin.cpp
@@ -178,11 +178,11 @@ static char * getVolName(CFDictionaryRef diskDetails)
name = (CFStringRef)
CFDictionaryGetValue(diskDetails, kDADiskDescriptionVolumeNameKey);
- if (name)
- size = CFStringGetLength(name) + 1;
- else
- size = 9; // 'Untitled\0'
+ if (!name)
+ return NULL;
+
+ size = CFStringGetLength(name) + 1;
volName = (char *) malloc(size);
if (!volName)
{
@@ -191,9 +191,11 @@ static char * getVolName(CFDictionaryRef diskDetails)
return NULL;
}
- if (!name || !CFStringGetCString(name, volName, size,
- kCFStringEncodingUTF8))
- strcpy(volName, "Untitled");
+ if (!CFStringGetCString(name, volName, size, kCFStringEncodingUTF8))
+ {
+ free(volName);
+ return NULL;
+ }
return volName;
}
@@ -291,8 +293,14 @@ void diskAppearedCallback(DADiskRef disk, void *context)
// Get the volume and model name for more user-friendly interaction
volName = getVolName(details);
- model = getModel(details);
+ if (!volName)
+ {
+ VERBOSE(VB_MEDIA, msg + "No volume name for dev " + BSDname);
+ CFRelease(details);
+ return;
+ }
+ model = getModel(details);
mediaType = MediaTypeForBSDName(BSDname);
isCDorDVD = (mediaType == MEDIATYPE_DVD) || (mediaType == MEDIATYPE_AUDIO);
@@ -326,6 +334,9 @@ void diskChangedCallback(DADiskRef disk, CFArrayRef keys, void *context)
CFDictionaryRef details = DADiskCopyDescription(disk);
char *volName = getVolName(details);
+ VERBOSE(VB_MEDIA, QString("Disk %1 - changed name to '%2'.")
+ .arg(BSDname).arg(volName));
+
reinterpret_cast<MonitorThreadDarwin *>(context)
->diskRename(BSDname, volName);
CFRelease(details);
Please sign in to comment.
Something went wrong with that request. Please try again.