r25114 by jghali - #16882: Scribus crash if you delete a symbol in "symbol edit mode".
scribus-commit
scribus-commit at lists.scribus.net
Thu Jun 30 22:05:56 UTC 2022
Author: jghali
Date: Thu Jun 30 22:05:56 2022
New Revision: 25114
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25114
Log:
#16882: Scribus crash if you delete a symbol in "symbol edit mode".
Modified:
trunk/Scribus/scribus/ui/symbolpalette.cpp
trunk/Scribus/scribus/ui/symbolpalette.h
Modified: trunk/Scribus/scribus/ui/symbolpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25114&path=/trunk/Scribus/scribus/ui/symbolpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/symbolpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/symbolpalette.cpp Thu Jun 30 22:05:56 2022
@@ -45,23 +45,23 @@
delegate = new ScListWidgetDelegate(this, this);
setItemDelegate(delegate);
setIconSize(QSize(48, 48));
- connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(HandleContextMenu(QPoint)));
-}
-
-void SymbolView::HandleContextMenu(QPoint p)
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleContextMenu(QPoint)));
+}
+
+void SymbolView::handleContextMenu(QPoint p)
{
QListWidgetItem *item = itemAt(p);
- if (!item)
- {
- QMenu *pmenu = new QMenu();
- QAction* viewAct;
- viewAct = pmenu->addAction( tr("Display Icons only"));
- viewAct->setCheckable(true);
- viewAct->setChecked(delegate->iconOnly());
- connect(viewAct, SIGNAL(triggered()), this, SLOT(changeDisplay()));
- pmenu->exec(QCursor::pos());
- delete pmenu;
- }
+ if (item)
+ return;
+
+ QMenu *pmenu = new QMenu();
+ QAction* viewAct;
+ viewAct = pmenu->addAction( tr("Display Icons only"));
+ viewAct->setCheckable(true);
+ viewAct->setChecked(delegate->iconOnly());
+ connect(viewAct, SIGNAL(triggered()), this, SLOT(changeDisplay()));
+ pmenu->exec(QCursor::pos());
+ delete pmenu;
}
void SymbolView::changeDisplay()
@@ -166,26 +166,31 @@
languageChange();
m_item = nullptr;
connect(SymbolViewWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(handleDoubleClick(QListWidgetItem*)));
- connect(SymbolViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleContextMenue(QPoint)));
+ connect(SymbolViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(handleContextMenu(QPoint)));
connect(SymbolViewWidget, SIGNAL(objectDropped()), this, SIGNAL(objectDropped()));
}
-void SymbolPalette::handleContextMenue(QPoint p)
+void SymbolPalette::handleContextMenu(QPoint p)
{
if (!m_doc)
return;
+
QListWidgetItem *item = SymbolViewWidget->itemAt(p);
- if (item)
- {
- m_item = item;
- QMenu *pmenu = new QMenu();
- QAction* editAct = pmenu->addAction( tr("Edit Item"));
- connect(editAct, SIGNAL(triggered()), this, SLOT(handleEditItem()));
- QAction* delAct = pmenu->addAction( tr("Remove Item"));
- connect(delAct, SIGNAL(triggered()), this, SLOT(handleDeleteItem()));
- pmenu->exec(QCursor::pos());
- delete pmenu;
- }
+ if (!item)
+ return;
+ m_item = item;
+
+ QMenu *pmenu = new QMenu();
+ QAction* editAct = pmenu->addAction( tr("Edit Item"));
+ editAct->setEnabled(item->flags() & Qt::ItemIsEnabled);
+ connect(editAct, SIGNAL(triggered()), this, SLOT(handleEditItem()));
+
+ QAction* delAct = pmenu->addAction( tr("Remove Item"));
+ delAct->setEnabled(item->flags() & Qt::ItemIsEnabled);
+ connect(delAct, SIGNAL(triggered()), this, SLOT(handleDeleteItem()));
+
+ pmenu->exec(QCursor::pos());
+ delete pmenu;
}
void SymbolPalette::handleDoubleClick(QListWidgetItem *item)
@@ -205,16 +210,16 @@
void SymbolPalette::handleDeleteItem()
{
- if (m_item != nullptr)
- {
- if (m_doc->docPatterns.contains(m_item->text()))
- {
- m_doc->removePattern(m_item->text());
- updateSymbolList();
- m_doc->regionsChanged()->update(QRect());
- }
- m_item = nullptr;
- }
+ if (m_item == nullptr)
+ return;
+
+ if (m_doc->docPatterns.contains(m_item->text()))
+ {
+ m_doc->removePattern(m_item->text());
+ updateSymbolList();
+ m_doc->regionsChanged()->update(QRect());
+ }
+ m_item = nullptr;
}
void SymbolPalette::editingStart(QStringList names)
Modified: trunk/Scribus/scribus/ui/symbolpalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25114&path=/trunk/Scribus/scribus/ui/symbolpalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/symbolpalette.h (original)
+++ trunk/Scribus/scribus/ui/symbolpalette.h Thu Jun 30 22:05:56 2022
@@ -53,7 +53,7 @@
~SymbolView() {};
public slots:
- void HandleContextMenu(QPoint p);
+ void handleContextMenu(QPoint p);
void changeDisplay();
protected:
@@ -77,6 +77,7 @@
public:
SymbolPalette(QWidget* parent);
~SymbolPalette() {};
+
void setMainWindow(ScribusMainWindow *mw);
void setDoc(ScribusDoc *);
void unsetDoc();
@@ -85,7 +86,7 @@
void updateSymbolList();
public slots:
- void handleContextMenue(QPoint p);
+ void handleContextMenu(QPoint p);
void handleDoubleClick(QListWidgetItem *item);
void handleEditItem();
void handleDeleteItem();
@@ -99,12 +100,12 @@
void objectDropped();
protected:
- SymbolView *SymbolViewWidget;
- QVBoxLayout* PaletteLayout;
- ScribusDoc *m_doc;
- ScribusMainWindow *m_scMW;
+ SymbolView *SymbolViewWidget { nullptr };
+ QVBoxLayout* PaletteLayout { nullptr };
+ ScribusDoc *m_doc { nullptr };
+ ScribusMainWindow *m_scMW { nullptr };
QStringList editItemNames;
- QListWidgetItem *m_item;
+ QListWidgetItem *m_item { nullptr };
void changeEvent(QEvent *e) override;
};
More information about the scribus-commit
mailing list