[vlmc-devel] commit: ProjectManager: Display something when the project failed to load. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Apr 21 02:54:41 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Apr 21 02:54:25 2010 +0200| [ec68122e48fbd92a77131287edd70f3c942b73f5] | committer: Hugo Beauzée-Luyssen
ProjectManager: Display something when the project failed to load.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=ec68122e48fbd92a77131287edd70f3c942b73f5
---
src/Gui/project/GuiProjectManager.cpp | 6 ++++++
src/Gui/project/GuiProjectManager.h | 3 +++
src/Metadata/MetaDataWorker.cpp | 1 +
src/Project/ProjectManager.cpp | 19 +++++++++++++++++--
src/Project/ProjectManager.h | 2 ++
5 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/Gui/project/GuiProjectManager.cpp b/src/Gui/project/GuiProjectManager.cpp
index 066ffdc..dcae06d 100644
--- a/src/Gui/project/GuiProjectManager.cpp
+++ b/src/Gui/project/GuiProjectManager.cpp
@@ -200,3 +200,9 @@ GUIProjectManager::projectNameChanged( const QVariant& name )
m_projectName = name.toString();
emit projectUpdated( m_projectName, !m_needSave );
}
+
+void
+GUIProjectManager::failedToLoad( const QString &reason ) const
+{
+ QMessageBox::warning( NULL, tr( "Failed to load project file" ), reason );
+}
diff --git a/src/Gui/project/GuiProjectManager.h b/src/Gui/project/GuiProjectManager.h
index d59aa54..37ba86b 100644
--- a/src/Gui/project/GuiProjectManager.h
+++ b/src/Gui/project/GuiProjectManager.h
@@ -53,6 +53,9 @@ public:
bool closeProject();
bool needSave() const;
+protected:
+ virtual void failedToLoad( const QString &reason ) const;
+
private:
bool createNewProjectFile( bool saveAs );
diff --git a/src/Metadata/MetaDataWorker.cpp b/src/Metadata/MetaDataWorker.cpp
index 731e01c..fa7dec9 100644
--- a/src/Metadata/MetaDataWorker.cpp
+++ b/src/Metadata/MetaDataWorker.cpp
@@ -115,6 +115,7 @@ MetaDataWorker::metaDataAvailable()
quint32 width, height;
m_mediaPlayer->getSize( &width, &height );
+ qDebug() << width << height;
m_media->setWidth( width );
m_media->setHeight( height );
m_media->setFps( m_mediaPlayer->getFps() );
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index de9769b..e82d136 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -99,12 +99,19 @@ void ProjectManager::loadTimeline()
void ProjectManager::loadProject( const QString& fileName )
{
if ( fileName.isEmpty() == true )
- return;
+ {
+ failedToLoad( tr( "Invalid project file name." ) );
+ return ;
+ }
if ( closeProject() == false )
return ;
m_projectFile = new QFile( fileName );
- m_projectFile->open( QFile::ReadOnly );
+ if ( m_projectFile->open( QFile::ReadOnly ) == false )
+ {
+ failedToLoad( tr( "Can't open project file. (%1)" ).arg( m_projectFile->errorString() ) );
+ return ;
+ }
m_projectFile->close();
m_domDocument = new QDomDocument;
@@ -235,3 +242,11 @@ ProjectManager::loadEmergencyBackup()
}
return false;
}
+
+void
+ProjectManager::failedToLoad( const QString &reason ) const
+{
+ //When running in server mode, we can't do anything without a project file.
+ qCritical() << tr( "Failed to load the project file: %1. Aborting." ).arg( reason );
+ abort();
+}
diff --git a/src/Project/ProjectManager.h b/src/Project/ProjectManager.h
index 8719baf..32e3e6d 100644
--- a/src/Project/ProjectManager.h
+++ b/src/Project/ProjectManager.h
@@ -70,6 +70,8 @@ protected:
*/
QString projectName() const;
+ virtual void failedToLoad( const QString& reason ) const;
+
protected:
ProjectManager();
~ProjectManager();
More information about the Vlmc-devel
mailing list