r20211 by jghali - #13173: Crash with fonts embed/subset config in PDF Export Dialog
scribus-commit
scribus-commit at lists.scribus.net
Fri Jun 26 11:43:54 UTC 2015
Author: jghali
Date: Fri Jun 26 11:43:54 2015
New Revision: 20211
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20211
Log:
#13173: Crash with fonts embed/subset config in PDF Export Dialog
Modified:
trunk/Scribus/scribus/ui/tabpdfoptions.cpp
Modified: trunk/Scribus/scribus/ui/tabpdfoptions.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20211&path=/trunk/Scribus/scribus/ui/tabpdfoptions.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/tabpdfoptions.cpp (original)
+++ trunk/Scribus/scribus/ui/tabpdfoptions.cpp Fri Jun 26 11:43:54 2015
@@ -96,7 +96,9 @@
// Fonts tab
groupFontLayout->setAlignment( Qt::AlignTop );
EmbedList->setMaximumHeight(300);
+ EmbedList->setSelectionMode(QListWidget::ExtendedSelection);
SubsetList->setMaximumHeight(300);
+ SubsetList->setSelectionMode(QListWidget::ExtendedSelection);
ToSubset->setIcon(IconManager::instance()->loadIcon("22/go-next.png"));
FromSubset->setIcon(IconManager::instance()->loadIcon("22/go-previous.png"));
@@ -1327,69 +1329,76 @@
void TabPDFOptions::RemoveSubset()
{
- QString currentFont = SubsetList->currentItem()->text();
- const ScFace fontFace = AllFonts[currentFont];
- if ((fontFace.type() != ScFace::OTF) && (!fontFace.subset()))
- {
+ QList<QListWidgetItem*> selection = SubsetList->selectedItems();
+ for (int i = 0; i < selection.count() ; ++i)
+ {
+ QListWidgetItem* fontItem = selection[i];
+ QString currentFont = fontItem->text();
+ const ScFace fontFace = AllFonts[currentFont];
+ if ((fontFace.type() == ScFace::OTF) || (fontFace.subset()))
+ continue;
addFontItem(currentFont, EmbedList);
- delete SubsetList->takeItem(SubsetList->currentRow());
- }
+ int currentRow = SubsetList->row(fontItem);
+ delete SubsetList->takeItem(currentRow);
+ }
+
SubsetList->clearSelection();
- if (SubsetList->count() == 0)
- FromSubset->setEnabled(false);
+ FromSubset->setEnabled(false);
}
void TabPDFOptions::PutToSubset()
{
- QString currentFont = EmbedList->currentItem()->text();
- if (SubsetList->count() != 0)
- {
- if (SubsetList->findItems(currentFont, Qt::MatchExactly).count() == 0)
+ QList<QListWidgetItem*> selection = EmbedList->selectedItems();
+ for (int i = 0; i < selection.count() ; ++i)
+ {
+ QListWidgetItem* fontItem = selection[i];
+ QString currentFont = fontItem->text();
+ if (SubsetList->count() != 0)
+ {
+ if (SubsetList->findItems(currentFont, Qt::MatchExactly).count() == 0)
+ addFontItem(currentFont, SubsetList);
+ }
+ else
+ {
addFontItem(currentFont, SubsetList);
- }
- else
- {
- addFontItem(currentFont, SubsetList);
- }
- delete EmbedList->takeItem(EmbedList->currentRow());
+ }
+ int itemRow = EmbedList->row(fontItem);
+ delete EmbedList->takeItem(itemRow);
+ }
+
EmbedList->clearSelection();
- if (EmbedList->count() == 0)
- {
- ToSubset->setEnabled(false);
- }
- else if (!(EmbedList->currentItem()->flags() & Qt::ItemIsSelectable))
- {
- ToSubset->setEnabled(false);
- }
-}
-
-void TabPDFOptions::SelEFont(QListWidgetItem *c)
-{
- if (c != NULL)
- {
- if (c->flags() & Qt::ItemIsSelectable)
- ToSubset->setEnabled(true);
- FromSubset->setEnabled(false);
- SubsetList->clearSelection();
- }
-}
-
-void TabPDFOptions::SelSFont(QListWidgetItem *c)
-{
- if (c != NULL)
- {
- if (PDFVersionCombo->currentIndex() == 4)
- {
- if ((AllFonts[c->text()].type() == ScFace::OTF) || (AllFonts[c->text()].subset()))
- FromSubset->setEnabled(false);
- else
- FromSubset->setEnabled(true);
- }
- else
- FromSubset->setEnabled(true);
- ToSubset->setEnabled(false);
- EmbedList->clearSelection();
- }
+ ToSubset->setEnabled(false);
+}
+
+void TabPDFOptions::SelEFont(QListWidgetItem*)
+{
+ QList<QListWidgetItem*> selection = EmbedList->selectedItems();
+ bool enableToSubset = (selection.count() > 0);
+
+ ToSubset->setEnabled(enableToSubset);
+ FromSubset->setEnabled(false);
+ SubsetList->clearSelection();
+}
+
+void TabPDFOptions::SelSFont(QListWidgetItem*)
+{
+ QList<QListWidgetItem*> selection = SubsetList->selectedItems();
+ int enabledForEmbedding = selection.count();
+
+ if (PDFVersionCombo->currentIndex() == 4)
+ {
+ for (int i = 0; i < selection.count(); ++i)
+ {
+ const QListWidgetItem* item = selection.at(i);
+ const ScFace face = AllFonts[item->text()];
+ if ((face.type() == ScFace::OTF) || (face.subset()))
+ enabledForEmbedding--;
+ }
+ }
+
+ FromSubset->setEnabled(enabledForEmbedding > 0);
+ ToSubset->setEnabled(false);
+ EmbedList->clearSelection();
}
void TabPDFOptions::EmbedAll()
More information about the scribus-commit
mailing list