diff --git a/plugins/commentshape/CommentShape.cpp b/plugins/commentshape/CommentShape.cpp --- a/plugins/commentshape/CommentShape.cpp +++ b/plugins/commentshape/CommentShape.cpp @@ -48,10 +48,14 @@ CommentShape::CommentShape(KoDocumentResourceManager* resourceManager) : KoShapeContainer() , m_active(false) +, m_comment(nullptr) { KoShapeContainer::setSize(initialsBoxSize); - m_comment = KoShapeRegistry::instance()->value(TextShapeId)->createDefaultShape(resourceManager); + KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(TextShapeId); + if (factory) { + m_comment = factory->createDefaultShape(resourceManager); + } if ( !m_comment ) { // m_comment = new KoShape; KMessageBox::error( 0, i18n("The plugin needed for displaying comments is not present."), i18n("Plugin Missing") ); diff --git a/plugins/defaultTools/connectionTool/ConnectionTool.cpp b/plugins/defaultTools/connectionTool/ConnectionTool.cpp --- a/plugins/defaultTools/connectionTool/ConnectionTool.cpp +++ b/plugins/defaultTools/connectionTool/ConnectionTool.cpp @@ -299,7 +299,10 @@ // and start editing the new connection // create the new connection shape KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value("KoConnectionShape"); - KoShape *shape = factory->createDefaultShape(canvas()->shapeController()->resourceManager()); + KoShape *shape = nullptr; + if (factory) { + shape = factory->createDefaultShape(canvas()->shapeController()->resourceManager()); + } KoConnectionShape * connectionShape = dynamic_cast(shape); if (!connectionShape) { delete shape; diff --git a/plugins/dockers/shapecollection/ShapeCollectionDocker.cpp b/plugins/dockers/shapecollection/ShapeCollectionDocker.cpp --- a/plugins/dockers/shapecollection/ShapeCollectionDocker.cpp +++ b/plugins/dockers/shapecollection/ShapeCollectionDocker.cpp @@ -265,6 +265,9 @@ foreach(const QString & id, KoShapeRegistry::instance()->keys()) { KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(id); + if (!factory) { + continue; + } // don't show hidden factories if ( factory->hidden() ) { continue; diff --git a/plugins/textshape/TextTool.cpp b/plugins/textshape/TextTool.cpp --- a/plugins/textshape/TextTool.cpp +++ b/plugins/textshape/TextTool.cpp @@ -188,7 +188,7 @@ list.append(this->action("format_font")); foreach (const QString &key, KoTextEditingRegistry::instance()->keys()) { KoTextEditingFactory *factory = KoTextEditingRegistry::instance()->value(key); - if (factory->showInMenu()) { + if (factory && factory->showInMenu()) { QAction *a = new QAction(factory->title(), this); connect(a, SIGNAL(triggered()), signalMapper, SLOT(map())); signalMapper->setMapping(a, factory->id()); diff --git a/sheets/Sheet.cpp b/sheets/Sheet.cpp --- a/sheets/Sheet.cpp +++ b/sheets/Sheet.cpp @@ -211,9 +211,12 @@ KoShape* shape; const QList shapes = other.d->shapes; for (int i = 0; i < shapes.count(); ++i) { - shape = KoShapeRegistry::instance()->value(shapes[i]->shapeId())->createDefaultShapeAndInit(0); - shape->copySettings(shapes[i]); - addShape(shape); + KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(shapes[i]->shapeId()); + if (factory) { + shape = factory->createDefaultShapeAndInit(0); + shape->copySettings(shapes[i]); + addShape(shape); + } } #endif // CALLIGRA_SHEETS_WIP_COPY_SHEET_(SHAPES) diff --git a/sheets/part/Doc.cpp b/sheets/part/Doc.cpp --- a/sheets/part/Doc.cpp +++ b/sheets/part/Doc.cpp @@ -154,6 +154,8 @@ if (chartShape) { QList panels = ChartDialog::panels(d->map); chartShape->setOptionPanels(panels); + } else { + warnSheets << "chart shape factory not found"; } connect(d->map, SIGNAL(commandAdded(KUndo2Command*)), diff --git a/stage/part/KPrEndOfSlideShowPage.cpp b/stage/part/KPrEndOfSlideShowPage.cpp --- a/stage/part/KPrEndOfSlideShowPage.cpp +++ b/stage/part/KPrEndOfSlideShowPage.cpp @@ -70,6 +70,8 @@ textShape->setPosition( QPointF( 10.0, 10.0 ) ); textShape->setSize( QSizeF( pageLayout.width - 20.0, pageLayout.height - 20.0 ) ); layer->addShape( textShape ); + } else { + warnStage << "text shape factory not found"; } } diff --git a/stage/part/KPrNotes.cpp b/stage/part/KPrNotes.cpp --- a/stage/part/KPrNotes.cpp +++ b/stage/part/KPrNotes.cpp @@ -66,22 +66,29 @@ // All sizes and positions are hardcoded for now KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value("TextShapeID"); Q_ASSERT(factory); - m_textShape = factory->createDefaultShape(m_doc->resourceManager()); - m_textShape->setGeometryProtected(true); - m_textShape->setAdditionalAttribute( "presentation:class", "notes" ); - m_textShape->setPosition(QPointF(62.22, 374.46)); - m_textShape->setSize(QSizeF(489.57, 356.37)); + if (factory) { + m_textShape = factory->createDefaultShape(m_doc->resourceManager()); + m_textShape->setGeometryProtected(true); + m_textShape->setAdditionalAttribute( "presentation:class", "notes" ); + m_textShape->setPosition(QPointF(62.22, 374.46)); + m_textShape->setSize(QSizeF(489.57, 356.37)); + layer->addShape( m_textShape ); + } else { + warnStage << "text shape factory not found"; + } factory = KoShapeRegistry::instance()->value("PictureShape"); Q_ASSERT(factory); - m_thumbnailShape = factory->createDefaultShape(m_doc->resourceManager()); - m_thumbnailShape->setGeometryProtected(true); - m_thumbnailShape->setAdditionalAttribute( "presentation:class", "page" ); - m_thumbnailShape->setPosition(QPointF(108.00, 60.18)); - m_thumbnailShape->setSize(QSizeF(396.28, 296.96)); - - layer->addShape( m_textShape ); - layer->addShape( m_thumbnailShape ); + if (factory) { + m_thumbnailShape = factory->createDefaultShape(m_doc->resourceManager()); + m_thumbnailShape->setGeometryProtected(true); + m_thumbnailShape->setAdditionalAttribute( "presentation:class", "page" ); + m_thumbnailShape->setPosition(QPointF(108.00, 60.18)); + m_thumbnailShape->setSize(QSizeF(396.28, 296.96)); + layer->addShape( m_thumbnailShape ); + } else { + warnStage << "picture shape factory not found"; + } } KPrNotes::~KPrNotes() diff --git a/stage/part/KPrPlaceholderStrategy.cpp b/stage/part/KPrPlaceholderStrategy.cpp --- a/stage/part/KPrPlaceholderStrategy.cpp +++ b/stage/part/KPrPlaceholderStrategy.cpp @@ -123,6 +123,8 @@ Q_ASSERT( factory ); if ( factory ) { shape = factory->createDefaultShape(rm); + } else { + warnStage << "no factory found for placeholder"; } return shape; } diff --git a/stage/part/KPrPlaceholderTextStrategy.cpp b/stage/part/KPrPlaceholderTextStrategy.cpp --- a/stage/part/KPrPlaceholderTextStrategy.cpp +++ b/stage/part/KPrPlaceholderTextStrategy.cpp @@ -44,6 +44,8 @@ #include #include +#include "StageDebug.h" + KPrPlaceholderTextStrategy::KPrPlaceholderTextStrategy( const QString & presentationClass ) : KPrPlaceholderStrategy( presentationClass ) , m_textShape( 0 ) @@ -124,6 +126,10 @@ if (KoTextSharedLoadingData *textSharedData = dynamic_cast(context.sharedData(KOTEXT_SHARED_LOADING_ID))) { KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value("TextShapeID"); Q_ASSERT(factory); + if (!factory) { + warnStage << "text shape factory not found"; + return false; + } delete m_textShape; m_textShape = factory->createDefaultShape(context.documentResourceManager()); @@ -164,6 +170,10 @@ { KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value( "TextShapeID" ); Q_ASSERT( factory ); + if (!factory) { + warnStage << "text shape factory not found"; + return; + } KoProperties props; props.setProperty("text", text()); delete m_textShape; diff --git a/words/part/KWDocument.cpp b/words/part/KWDocument.cpp --- a/words/part/KWDocument.cpp +++ b/words/part/KWDocument.cpp @@ -114,7 +114,9 @@ m_panelFactories = KWFrameDialog::panels(this); foreach (const QString &id, KoShapeRegistry::instance()->keys()) { KoShapeFactoryBase *shapeFactory = KoShapeRegistry::instance()->value(id); - shapeFactory->setOptionPanels(m_panelFactories); + if (shapeFactory) { + shapeFactory->setOptionPanels(m_panelFactories); + } } resourceManager()->setUndoStack(undoStack());