From 72355ecfd565dcce33febfc91b5cce7224750c26 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Fri, 26 Aug 2005 13:11:35 +0000 Subject: [PATCH] fixed bug #1390 --- .../gLiveSupport/src/UploadFileWindow.cxx | 20 ++++++++++++------- .../gLiveSupport/src/UploadFileWindow.h | 9 +++++---- .../products/gLiveSupport/var/root.txt | 4 ++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx b/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx index 1b0502cde..cb5039396 100644 --- a/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx +++ b/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.16 $ + Version : $Revision: 1.17 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -244,7 +244,11 @@ UploadFileWindow :: updateFileInfo(void) throw () try { playlength = readPlaylength(fileName); } catch (std::invalid_argument &e) { - statusBar->set_text(e.what()); + statusBar->set_text(*getResourceUstring("unsupportedFileTypeMsg")); + return; + } + if (!playlength) { + statusBar->set_text(*getResourceUstring("couldNotReadLengthMsg")); playlength.reset(new time_duration(0,0,0,0)); } @@ -369,15 +373,17 @@ UploadFileWindow :: readPlaylength(const std::string & fileName) throw (std::invalid_argument) { TagLib::FileRef fileRef(fileName.c_str()); + if (fileRef.isNull()) { + throw std::invalid_argument("unsupported file type"); + } + TagLib::AudioProperties * audioProperties = fileRef.audioProperties(); - + Ptr::Ref length; if (audioProperties) { - Ptr::Ref length(new time_duration( + length.reset(new time_duration( seconds( audioProperties->length() ) + microseconds(audioProperties->length_microseconds()) )); - return length; - } else { - throw std::invalid_argument("could not read file length"); } + return length; } diff --git a/livesupport/products/gLiveSupport/src/UploadFileWindow.h b/livesupport/products/gLiveSupport/src/UploadFileWindow.h index 2cfd19505..1463b6c53 100644 --- a/livesupport/products/gLiveSupport/src/UploadFileWindow.h +++ b/livesupport/products/gLiveSupport/src/UploadFileWindow.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/UploadFileWindow.h,v $ ------------------------------------------------------------------------------*/ @@ -87,7 +87,7 @@ using namespace LiveSupport::Widgets; * * * @author $Author: fgerlits $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ class UploadFileWindow : public WhiteWindow, public LocalizedObject { @@ -273,9 +273,10 @@ class UploadFileWindow : public WhiteWindow, public LocalizedObject * Determine the length of an audio file on disk. * * @param fileName a binary audio file (e.g., /tmp/some_clip.mp3) - * @return the length of the file + * @return the length of the file; a null pointer if the + * length could not be read (see bug #1426) * @exception std::invalid_argument if the file is not found, or its - * length could not be determined + * format is not supported by TagLib */ Ptr::Ref readPlaylength(const std::string & fileName) diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index f81f79261..c107a808e 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -115,6 +115,10 @@ root:table { "Choose a File" } clipUploadedMsg:string { "Uploaded clip ''{0}''." } couldNotOpenFileMsg:string { "The file could not be opened." } + couldNotReadLengthMsg:string + { "Could not determine audio clip length." } + unsupportedFileTypeMsg:string + { "Unsupported file type." } missingTitleMsg:string { "Please enter a title." } }