avoid crash when chart model is disposed
Change-Id: I70c3a06e2aa9112cd5a47b7d8839c4bd701cfc1e
This commit is contained in:
@@ -236,7 +236,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
|
||||
mxModel(pController->getModel()),
|
||||
mxListener(new ChartSidebarModifyListener(this)),
|
||||
mxSelectionListener(new ChartSidebarSelectionListener(this)),
|
||||
mbUpdate(true)
|
||||
mbUpdate(true),
|
||||
mbModelValid(true)
|
||||
{
|
||||
std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
|
||||
mxSelectionListener->setAcceptedTypes(aAcceptedTypes);
|
||||
@@ -366,7 +367,7 @@ void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
|
||||
|
||||
void ChartAreaPanel::updateData()
|
||||
{
|
||||
if (!mbUpdate)
|
||||
if (!mbUpdate || !mbModelValid)
|
||||
return;
|
||||
|
||||
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
||||
@@ -423,6 +424,7 @@ void ChartAreaPanel::updateData()
|
||||
|
||||
void ChartAreaPanel::modelInvalid()
|
||||
{
|
||||
mbModelValid = false;
|
||||
}
|
||||
|
||||
void ChartAreaPanel::selectionChanged(bool bCorrectType)
|
||||
@@ -438,10 +440,14 @@ void ChartAreaPanel::SelectionInvalid()
|
||||
void ChartAreaPanel::updateModel(
|
||||
css::uno::Reference<css::frame::XModel> xModel)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
if (mbModelValid)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
}
|
||||
|
||||
mxModel = xModel;
|
||||
mbModelValid = true;
|
||||
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcasterNew->addModifyListener(mxListener);
|
||||
|
@@ -91,6 +91,7 @@ private:
|
||||
void Initialize();
|
||||
|
||||
bool mbUpdate;
|
||||
bool mbModelValid;
|
||||
};
|
||||
|
||||
} } // end of namespace svx::sidebar
|
||||
|
@@ -191,7 +191,8 @@ ChartAxisPanel::ChartAxisPanel(
|
||||
mxFrame(rxFrame),
|
||||
mxModel(pController->getModel()),
|
||||
mxModifyListener(new ChartSidebarModifyListener(this)),
|
||||
mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_AXIS))
|
||||
mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_AXIS)),
|
||||
mbModelValid(true)
|
||||
{
|
||||
get(mpCBShowLabel, "checkbutton_show_label");
|
||||
get(mpCBReverse, "checkbutton_reverse");
|
||||
@@ -246,6 +247,9 @@ void ChartAxisPanel::Initialize()
|
||||
|
||||
void ChartAxisPanel::updateData()
|
||||
{
|
||||
if (!mbModelValid)
|
||||
return;
|
||||
|
||||
OUString aCID = getCID(mxModel);
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
@@ -291,15 +295,20 @@ void ChartAxisPanel::NotifyItemUpdate(
|
||||
|
||||
void ChartAxisPanel::modelInvalid()
|
||||
{
|
||||
mbModelValid = false;
|
||||
}
|
||||
|
||||
void ChartAxisPanel::updateModel(
|
||||
css::uno::Reference<css::frame::XModel> xModel)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxModifyListener);
|
||||
if (mbModelValid)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxModifyListener);
|
||||
}
|
||||
|
||||
mxModel = xModel;
|
||||
mbModelValid = true;
|
||||
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcasterNew->addModifyListener(mxModifyListener);
|
||||
|
@@ -88,6 +88,8 @@ private:
|
||||
css::uno::Reference<css::util::XModifyListener> mxModifyListener;
|
||||
css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener;
|
||||
|
||||
bool mbModelValid;
|
||||
|
||||
void Initialize();
|
||||
|
||||
DECL_LINK(CheckBoxHdl, CheckBox*);
|
||||
|
@@ -289,7 +289,8 @@ ChartElementsPanel::ChartElementsPanel(
|
||||
mxFrame(rxFrame),
|
||||
maContext(),
|
||||
mxModel(pController->getModel()),
|
||||
mxListener(new ChartSidebarModifyListener(this))
|
||||
mxListener(new ChartSidebarModifyListener(this)),
|
||||
mbModelValid(true)
|
||||
{
|
||||
get(mpCBTitle, "checkbutton_title");
|
||||
get(mpCBSubtitle, "checkbutton_subtitle");
|
||||
@@ -379,6 +380,9 @@ void ChartElementsPanel::Initialize()
|
||||
|
||||
void ChartElementsPanel::updateData()
|
||||
{
|
||||
if (!mbModelValid)
|
||||
return;
|
||||
|
||||
Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(mxModel));
|
||||
sal_Int32 nDimension = DiagramHelper::getDimension(xDiagram);
|
||||
SolarMutexGuard aGuard;
|
||||
@@ -452,16 +456,20 @@ void ChartElementsPanel::NotifyItemUpdate(
|
||||
|
||||
void ChartElementsPanel::modelInvalid()
|
||||
{
|
||||
|
||||
mbModelValid = false;
|
||||
}
|
||||
|
||||
void ChartElementsPanel::updateModel(
|
||||
css::uno::Reference<css::frame::XModel> xModel)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
if (mbModelValid)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
}
|
||||
|
||||
mxModel = xModel;
|
||||
mbModelValid = true;
|
||||
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcasterNew->addModifyListener(mxListener);
|
||||
|
@@ -104,6 +104,8 @@ private:
|
||||
css::uno::Reference<css::frame::XModel> mxModel;
|
||||
css::uno::Reference<css::util::XModifyListener> mxListener;
|
||||
|
||||
bool mbModelValid;
|
||||
|
||||
void Initialize();
|
||||
|
||||
DECL_LINK(CheckBoxHdl, CheckBox*);
|
||||
|
@@ -244,7 +244,8 @@ ChartErrorBarPanel::ChartErrorBarPanel(
|
||||
: PanelLayout(pParent, "ChartErrorBarPanel", "modules/schart/ui/sidebarerrorbar.ui", rxFrame),
|
||||
mxFrame(rxFrame),
|
||||
mxModel(pController->getModel()),
|
||||
mxListener(new ChartSidebarModifyListener(this))
|
||||
mxListener(new ChartSidebarModifyListener(this)),
|
||||
mbModelValid(true)
|
||||
{
|
||||
|
||||
get(mpRBPosAndNeg, "radiobutton_positive_negative");
|
||||
@@ -302,6 +303,9 @@ void ChartErrorBarPanel::Initialize()
|
||||
|
||||
void ChartErrorBarPanel::updateData()
|
||||
{
|
||||
if (!mbModelValid)
|
||||
return;
|
||||
|
||||
OUString aCID = getCID(mxModel);
|
||||
bool bPos = showPositiveError(mxModel, aCID);
|
||||
bool bNeg = showNegativeError(mxModel, aCID);
|
||||
@@ -379,15 +383,20 @@ void ChartErrorBarPanel::NotifyItemUpdate(
|
||||
|
||||
void ChartErrorBarPanel::modelInvalid()
|
||||
{
|
||||
mbModelValid = false;
|
||||
}
|
||||
|
||||
void ChartErrorBarPanel::updateModel(
|
||||
css::uno::Reference<css::frame::XModel> xModel)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
if (mbModelValid)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
}
|
||||
|
||||
mxModel = xModel;
|
||||
mbModelValid = true;
|
||||
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcasterNew->addModifyListener(mxListener);
|
||||
|
@@ -84,6 +84,8 @@ private:
|
||||
css::uno::Reference<css::frame::XModel> mxModel;
|
||||
css::uno::Reference<css::util::XModifyListener> mxListener;
|
||||
|
||||
bool mbModelValid;
|
||||
|
||||
void Initialize();
|
||||
|
||||
DECL_LINK(RadioBtnHdl, void*);
|
||||
|
@@ -121,7 +121,8 @@ ChartLinePanel::ChartLinePanel(vcl::Window* pParent,
|
||||
mxModel(pController->getModel()),
|
||||
mxListener(new ChartSidebarModifyListener(this)),
|
||||
mxSelectionListener(new ChartSidebarSelectionListener(this)),
|
||||
mbUpdate(true)
|
||||
mbUpdate(true),
|
||||
mbModelValid(true)
|
||||
{
|
||||
std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
|
||||
mxSelectionListener->setAcceptedTypes(aAcceptedTypes);
|
||||
@@ -160,7 +161,7 @@ void ChartLinePanel::Initialize()
|
||||
|
||||
void ChartLinePanel::updateData()
|
||||
{
|
||||
if (!mbUpdate)
|
||||
if (!mbUpdate || !mbModelValid)
|
||||
return;
|
||||
|
||||
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
||||
@@ -188,6 +189,7 @@ void ChartLinePanel::updateData()
|
||||
|
||||
void ChartLinePanel::modelInvalid()
|
||||
{
|
||||
mbModelValid = false;
|
||||
}
|
||||
|
||||
void ChartLinePanel::selectionChanged(bool bCorrectType)
|
||||
@@ -203,10 +205,14 @@ void ChartLinePanel::SelectionInvalid()
|
||||
void ChartLinePanel::updateModel(
|
||||
css::uno::Reference<css::frame::XModel> xModel)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
if (mbModelValid)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
}
|
||||
|
||||
mxModel = xModel;
|
||||
mbModelValid = true;
|
||||
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcasterNew->addModifyListener(mxListener);
|
||||
|
@@ -95,6 +95,7 @@ private:
|
||||
void Initialize();
|
||||
|
||||
bool mbUpdate;
|
||||
bool mbModelValid;
|
||||
};
|
||||
|
||||
} } // end of namespace svx::sidebar
|
||||
|
@@ -292,7 +292,8 @@ ChartSeriesPanel::ChartSeriesPanel(
|
||||
mxFrame(rxFrame),
|
||||
mxModel(pController->getModel()),
|
||||
mxListener(new ChartSidebarModifyListener(this)),
|
||||
mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_DATA_SERIES))
|
||||
mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_DATA_SERIES)),
|
||||
mbModelValid(true)
|
||||
{
|
||||
get(mpCBLabel, "checkbutton_label");
|
||||
get(mpCBTrendline, "checkbutton_trendline");
|
||||
@@ -366,6 +367,9 @@ void ChartSeriesPanel::Initialize()
|
||||
|
||||
void ChartSeriesPanel::updateData()
|
||||
{
|
||||
if (!mbModelValid)
|
||||
return;
|
||||
|
||||
OUString aCID = getCID(mxModel);
|
||||
SolarMutexGuard aGuard;
|
||||
bool bLabelVisible = isDataLabelVisible(mxModel, aCID);
|
||||
@@ -422,16 +426,20 @@ void ChartSeriesPanel::NotifyItemUpdate(
|
||||
|
||||
void ChartSeriesPanel::modelInvalid()
|
||||
{
|
||||
|
||||
mbModelValid = false;
|
||||
}
|
||||
|
||||
void ChartSeriesPanel::updateModel(
|
||||
css::uno::Reference<css::frame::XModel> xModel)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
if (mbModelValid)
|
||||
{
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcaster->removeModifyListener(mxListener);
|
||||
}
|
||||
|
||||
mxModel = xModel;
|
||||
mbModelValid = true;
|
||||
|
||||
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
||||
xBroadcasterNew->addModifyListener(mxListener);
|
||||
|
@@ -104,6 +104,8 @@ private:
|
||||
css::uno::Reference<css::util::XModifyListener> mxListener;
|
||||
css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener;
|
||||
|
||||
bool mbModelValid;
|
||||
|
||||
void Initialize();
|
||||
|
||||
DECL_LINK(CheckBoxHdl, CheckBox*);
|
||||
|
Reference in New Issue
Block a user