diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/axis-manip.h | 8 | ||||
| -rw-r--r-- | src/document-private.h | 1 | ||||
| -rw-r--r-- | src/document.cpp | 7 | ||||
| -rw-r--r-- | src/document.h | 3 | ||||
| -rw-r--r-- | src/sp-item-transform.cpp | 11 | ||||
| -rw-r--r-- | src/ui/dialog/filter-effects-dialog.cpp | 5 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 103 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.h | 2 |
8 files changed, 104 insertions, 36 deletions
diff --git a/src/axis-manip.h b/src/axis-manip.h index d81da4164..9392e2ddd 100644 --- a/src/axis-manip.h +++ b/src/axis-manip.h @@ -238,11 +238,11 @@ inline Box3D::Axis get_perpendicular_axis_direction (Box3D::Axis dirs) { return Box3D::NONE; } -inline gchar * string_from_axes (Box3D::Axis axes) { +inline gchar * string_from_axes (Box3D::Axis axis) { GString *pstring = g_string_new(""); - if (axes & Box3D::X) g_string_append_printf (pstring, "X"); - if (axes & Box3D::Y) g_string_append_printf (pstring, "Y"); - if (axes & Box3D::Z) g_string_append_printf (pstring, "Z"); + if (axis & Box3D::X) g_string_append_printf (pstring, "X"); + if (axis & Box3D::Y) g_string_append_printf (pstring, "Y"); + if (axis & Box3D::Z) g_string_append_printf (pstring, "Z"); return pstring->str; } diff --git a/src/document-private.h b/src/document-private.h index 065101174..35f21910c 100644 --- a/src/document-private.h +++ b/src/document-private.h @@ -52,6 +52,7 @@ struct SPDocumentPrivate { GHashTable *resources; ResourcesChangedSignalMap resources_changed_signals; + sigc::signal<void> destroySignal; SPDocument::ModifiedSignal modified_signal; SPDocument::URISetSignal uri_set_signal; SPDocument::ResizedSignal resized_signal; diff --git a/src/document.cpp b/src/document.cpp index 112503320..18e626b5b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -141,6 +141,8 @@ SPDocument::SPDocument() : } SPDocument::~SPDocument() { + priv->destroySignal.emit(); + // kill/unhook this first if ( profileManager ) { delete profileManager; @@ -230,6 +232,11 @@ SPDocument::~SPDocument() { //delete this->_whiteboard_session_manager; } +sigc::connection SPDocument::connectDestroy(sigc::signal<void>::slot_type slot) +{ + return priv->destroySignal.connect(slot); +} + SPDefs *SPDocument::getDefs() { if (!root) { diff --git a/src/document.h b/src/document.h index e5567d3b6..ee903449d 100644 --- a/src/document.h +++ b/src/document.h @@ -85,6 +85,9 @@ public: SPDocument(); virtual ~SPDocument(); + sigc::connection connectDestroy(sigc::signal<void>::slot_type slot); + + unsigned int keepalive : 1; unsigned int virgin : 1; ///< Has the document never been touched? unsigned int modified_since_save : 1; diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 1ab8edd51..086da56ff 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -115,7 +115,6 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua gdouble w0 = bbox_visual.width(); // will return a value >= 0, as required further down the road gdouble h0 = bbox_visual.height(); - gdouble r0 = sqrt(stroke_x*stroke_y); // r0 is redundant, used only for those cases where stroke_x = stroke_y // We also know the width and height of the new visual bounding box gdouble w1 = x1 - x0; // can have any sign @@ -132,6 +131,16 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua h1 = fabs(h1); // w0 and h0 will always be positive due to the definition of the width() and height() methods. + // Check whether the stroke is negative; i.e. the geometric bounding box is larger than the visual bounding box, which + // occurs for example for clipped objects (see launchpad bug #811819) + if (stroke_x < 0 || stroke_y < 0) { + Geom::Affine direct = Geom::Scale(flip_x * w1 / w0, flip_y* h1 / h0); // Scaling of the visual bounding box + // How should we handle the stroke width scaling of clipped object? I don't know if we can/should handle this, + // so for now we simply return the direct scaling + return (p2o * direct * o2n); + } + gdouble r0 = sqrt(stroke_x*stroke_y); // r0 is redundant, used only for those cases where stroke_x = stroke_y + // We will now try to calculate the affine transformation required to transform the first visual bounding box into // the second one, while accounting for strokewidth diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index b763776c6..65bebbd14 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1430,7 +1430,10 @@ void FilterEffectsDialog::FilterModifier::on_document_replaced(SPDesktop * /*des if (_resource_changed) { _resource_changed.disconnect(); } - _resource_changed = document->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters)); + if (document) + { + _resource_changed = document->connectResourcesChanged("filter",sigc::mem_fun(*this, &FilterModifier::update_filters)); + } update_filters(); } diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 807618b4d..5e77a28ab 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -745,10 +745,11 @@ void SwatchesPanel::setDesktop( SPDesktop* desktop ) class DocTrack { public: - DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) : - doc(doc->doRef()), + DocTrack(SPDocument *doc, sigc::connection &docDestroy, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) : + doc(doc), updatePending(false), lastGradientUpdate(0.0), + docDestroy(docDestroy), gradientRsrcChanged(gradientRsrcChanged), defsChanged(defsChanged), defsModified(defsModified) @@ -773,10 +774,10 @@ public: } } if (doc) { + docDestroy.disconnect(); gradientRsrcChanged.disconnect(); defsChanged.disconnect(); defsModified.disconnect(); - doc->doUnref(); doc = NULL; } } @@ -797,6 +798,7 @@ public: SPDocument *doc; bool updatePending; double lastGradientUpdate; + sigc::connection docDestroy; sigc::connection gradientRsrcChanged; sigc::connection defsChanged; sigc::connection defsModified; @@ -892,11 +894,12 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document ) } docPerPanel[panel] = document; if (!found) { + sigc::connection conn0 = document->connectDestroy(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDocumentDestroy), document)); sigc::connection conn1 = document->connectResourcesChanged( "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) ); sigc::connection conn2 = document->getDefs()->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) ); sigc::connection conn3 = document->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) ); - DocTrack *dt = new DocTrack(document, conn1, conn2, conn3); + DocTrack *dt = new DocTrack(document, conn0, conn1, conn2, conn3); docTrackings.push_back(dt); if (docPalettes.find(document) == docPalettes.end()) { @@ -925,11 +928,13 @@ static void recalcSwatchContents(SPDocument* doc, { std::vector<SPGradient*> newList; - const GSList *gradients = doc->getResourceList("gradient"); - for (const GSList *item = gradients; item; item = item->next) { - SPGradient* grad = SP_GRADIENT(item->data); - if ( grad->isSwatch() ) { - newList.push_back(SP_GRADIENT(item->data)); + if (doc) { + const GSList *gradients = doc->getResourceList("gradient"); + for (const GSList *item = gradients; item; item = item->next) { + SPGradient* grad = SP_GRADIENT(item->data); + if ( grad->isSwatch() ) { + newList.push_back(SP_GRADIENT(item->data)); + } } } @@ -968,6 +973,37 @@ static void recalcSwatchContents(SPDocument* doc, } } +void SwatchesPanel::handleDocumentDestroy(SPDocument *document) +{ + if (document) { + for (std::vector<DocTrack*>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it){ + if ((*it)->doc == document) { + delete *it; + docTrackings.erase(it); + break; + } + } + + if (docPalettes.find(document) != docPalettes.end()) { + docPalettes.erase(document); + } + + for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) { + if (it->second == document) { + SwatchesPanel* swp = it->first; + std::vector<SwatchPage*> pages = swp->_getSwatchSets(); + if ((swp->_currentIndex >= static_cast<int>(pages.size())) && (pages.size() > 0)) + { + swp->_setSelectedIndex(swp->_getSwatchSets().size() - 1); + } + swp->_rebuild(); + docPerPanel.erase(it); + break; + } + } + } +} + void SwatchesPanel::handleGradientsChange(SPDocument *document) { SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0; @@ -1142,38 +1178,45 @@ void SwatchesPanel::_handleAction( int setId, int itemId ) switch( setId ) { case 3: { - std::vector<SwatchPage*> pages = _getSwatchSets(); - if ( itemId >= 0 && itemId < static_cast<int>(pages.size()) ) { - _currentIndex = itemId; + _setSelectedIndex(itemId); + } + break; + } +} - if ( !_prefs_path.empty() ) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString(_prefs_path + "/palette", pages[_currentIndex]->_name); - } +void SwatchesPanel::_setSelectedIndex( int index ) +{ + std::vector<SwatchPage*> pages = _getSwatchSets(); + if ( index >= 0 && index < static_cast<int>(pages.size()) ) { + _currentIndex = index; - _rebuild(); - } + if ( !_prefs_path.empty() ) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(_prefs_path + "/palette", pages[_currentIndex]->_name); } - break; + + _rebuild(); } } void SwatchesPanel::_rebuild() { std::vector<SwatchPage*> pages = _getSwatchSets(); - SwatchPage* curr = pages[_currentIndex]; - _holder->clear(); + if (_currentIndex < static_cast<int>(pages.size())) { + SwatchPage* curr = pages[_currentIndex]; + _holder->clear(); - if ( curr->_prefWidth > 0 ) { - _holder->setColumnPref( curr->_prefWidth ); - } - _holder->freezeUpdates(); - // TODO restore once 'clear' works _holder->addPreview(_clear); - _holder->addPreview(_remove); - for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); ++it) { - _holder->addPreview(&*it); + if ( curr->_prefWidth > 0 ) { + _holder->setColumnPref( curr->_prefWidth ); + } + _holder->freezeUpdates(); + // TODO restore once 'clear' works _holder->addPreview(_clear); + _holder->addPreview(_remove); + for ( boost::ptr_vector<ColorItem>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); ++it) { + _holder->addPreview(&*it); + } + _holder->thawUpdates(); } - _holder->thawUpdates(); } } //namespace Dialogs diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h index ca4c1687d..3abb81d98 100644 --- a/src/ui/dialog/swatches.h +++ b/src/ui/dialog/swatches.h @@ -43,11 +43,13 @@ public: virtual int getSelectedIndex() {return _currentIndex;} // temporary protected: + static void handleDocumentDestroy(SPDocument *document); static void handleGradientsChange(SPDocument *document); virtual void _updateFromSelection(); virtual void _handleAction( int setId, int itemId ); virtual void _setDocument( SPDocument *document ); + virtual void _setSelectedIndex( int index ); virtual void _rebuild(); virtual std::vector<SwatchPage*> _getSwatchSets() const; |
