Skip to content

Commit

Permalink
fix crash when user deletes all metadata in MetaEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Sep 29, 2023
1 parent ee35baf commit 4c405c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pre-2.0.2
- harden delete unused styles to trailing whitespace in class names
- fix unrecognized media-types application/xml and text/xml
- fix cursor just before end tag bug in align justiry, centre, right
- fix crash when all metadata removed by user in MetaEditor


Sigil-2.0.1
Expand Down
9 changes: 8 additions & 1 deletion src/Dialogs/MetaEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
#include "Dialogs/MetaEditorItemDelegate.h"
#include "Dialogs/MetaEditor.h"

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#define QT_ENUM_SKIPEMPTYPARTS Qt::SkipEmptyParts
#define QT_ENUM_KEEPEMPTYPARTS Qt::KeepEmptyParts
#else
#define QT_ENUM_SKIPEMPTYPARTS QString::SkipEmptyParts
#define QT_ENUM_KEEPEMPTYPARTS QString::KeepEmptyParts
#endif

static const QString SETTINGS_GROUP = "meta_editor";
static const QString _IN = " ";
Expand Down Expand Up @@ -303,7 +310,7 @@ QString MetaEditor::SetNewOPFMetadata(QString& data)
QString newopfdata = m_opfdata;
MetadataPieces mdp;
// Translate from Human Readable Form
QStringList dlist = data.split(_RS);
QStringList dlist = data.split(_RS, QT_ENUM_SKIPEMPTYPARTS);
QStringList nlist;
foreach(QString rc, dlist) {
if (rc.startsWith(_IN)) {
Expand Down

0 comments on commit 4c405c0

Please sign in to comment.