Hi,
I had problem with loading playlist on one of my machines. This code failed.
std::string playlistInfoFile = filename;
std::ifstream verify( playlistInfoFile.c_str() , std::ios::in |
std::ios::binary );
Really, I'm not sure why, but for fix this I change this to more proper QT
style.
Patch is in attachment. Please say is this OK or not, and apply if you can.
Best Regards
Xj
diff --git a/src/core/src/local_file_mgr.cpp b/src/core/src/local_file_mgr.cpp
index 8ca8284..3c59291 100644
--- a/src/core/src/local_file_mgr.cpp
+++ b/src/core/src/local_file_mgr.cpp
@@ -70,7 +70,7 @@ LocalFileMng::~LocalFileMng()
QString LocalFileMng::getDrumkitNameForPattern( const QString& patternDir )
{
- QDomDocument doc = LocalFileMng::openXmlDocument( patternDir );
+ QDomDocument doc = openXmlDocument( patternDir );
QDomNode rootNode = doc.firstChildElement( "drumkit_pattern" ); // root element
if ( rootNode.isNull() ) {
@@ -831,13 +831,19 @@ int LocalFileMng::savePlayList( const std::string& filename)
int LocalFileMng::loadPlayList( const std::string& filename)
{
- std::string playlistInfoFile = filename;
- std::ifstream verify( playlistInfoFile.c_str() , std::ios::in | std::ios::binary );
- if ( verify ) {
+ /* openXmlDocument can create new document ( which is bad idea anyway )
+ We don't want create new playlist here , so we just open it for test ;-)
+ */
+ QString Filename = QString( filename.c_str() );
+ QFile file( Filename );
+ if ( file.open(QIODevice::ReadOnly) ) {
+ file.close();
+ } else {
+ ERRORLOG( QString("Error reading playlist: can't open file %1").arg( Filename ) );
return 1;
}
- QDomDocument doc = LocalFileMng::openXmlDocument( QString( filename.c_str() ) );
+ QDomDocument doc = openXmlDocument( Filename );
Hydrogen::get_instance()->m_PlayList.clear();
@@ -854,11 +860,11 @@ int LocalFileMng::loadPlayList( const std::string& filename)
SongReader reader;
while ( ! nextNode.isNull() ) {
Hydrogen::HPlayListNode playListItem;
- playListItem.m_hFile = LocalFileMng::readXmlString( nextNode, "song", "" );
+ playListItem.m_hFile = readXmlString( nextNode, "song", "" );
QString FilePath = reader.getPath( playListItem.m_hFile );
playListItem.m_hFileExists = Filesystem::file_readable( FilePath );
playListItem.m_hScript = LocalFileMng::readXmlString( nextNode, "script", "" );
- playListItem.m_hScriptEnabled = LocalFileMng::readXmlString( nextNode, "enabled", "" );
+ playListItem.m_hScriptEnabled = readXmlString( nextNode, "enabled", "" );
Hydrogen::get_instance()->m_PlayList.push_back( playListItem );
nextNode = nextNode.nextSiblingElement( "next" );
@@ -867,8 +873,6 @@ int LocalFileMng::loadPlayList( const std::string& filename)
return 0; // ok
}
-
-
/* New QtXml based methods */
QString LocalFileMng::readXmlString( QDomNode node , const QString& nodeName, const QString& defaultValue, bool bCanBeEmpty, bool bShouldExists, bool tinyXmlCompatMode)
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Hydrogen-devel mailing list
Hydrogen-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hydrogen-devel