Skip to content

Commit 0bb4df8

Browse files
committed
Fix epub files with an empty title in metadata.
1 parent ee55561 commit 0bb4df8

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

lib/libebook/ebook_epub.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <QByteArray>
2727
#include <QChar>
2828
#include <QIODevice>
29+
#include <QFileInfo>
2930
#include <QList>
3031
#include <QMessageBox>
3132
#include <QString>
@@ -224,8 +225,8 @@ bool EBook_EPUB::parseBookinfo()
224225
if ( !parseXML( container_parser.contentPath, &content_parser ) )
225226
return false;
226227

227-
// At least title and the TOC must be present
228-
if ( !content_parser.metadata.contains( "title" ) || content_parser.tocname.isEmpty() )
228+
// At least the TOC must be present
229+
if ( content_parser.tocname.isEmpty() )
229230
return false;
230231

231232
// All the files, including TOC, are relative to the container_parser.contentPath
@@ -242,7 +243,10 @@ bool EBook_EPUB::parseBookinfo()
242243
return false;
243244

244245
// Get the data
245-
m_title = content_parser.metadata[ "title" ];
246+
if ( content_parser.metadata.contains( "title" ) )
247+
m_title = content_parser.metadata[ "title" ];
248+
else
249+
m_title = QFileInfo( m_epubFile ).fileName();
246250

247251
// Move the manifest entries into the list
248252
Q_FOREACH ( QString f, content_parser.manifest.values() )

src/mainwindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ bool MainWindow::loadFile( const QString& loadFileName, bool call_open_page )
382382
else
383383
{
384384
QMessageBox mbox(
385-
i18n( "%1 - failed to load the chm file" ) . arg( QCoreApplication::applicationName() ),
386-
i18n( "Unable to load the chm file %1" ) . arg( fileName ),
385+
i18n( "%1 - failed to load file" ) . arg( QCoreApplication::applicationName() ),
386+
i18n( "Unable to load file %1" ) . arg( fileName ),
387387
QMessageBox::Critical,
388388
QMessageBox::Ok,
389389
Qt::NoButton,

0 commit comments

Comments
 (0)