From: Jon A. Cruz Date: Tue, 6 Apr 2010 07:29:20 +0000 (-0700) Subject: Fixed use of dialogs in more than one window, and tile problem with selection. Fixes... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f77fbbae517ab9a0c194068e88cbdf0f43b72f9b;p=inkscape.git Fixed use of dialogs in more than one window, and tile problem with selection. Fixes bug #556233. --- diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 088f63031..a210fe163 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -45,14 +45,13 @@ namespace UI { namespace Dialogs { -IconPreviewPanel& -IconPreviewPanel::getInstance() +IconPreviewPanel &IconPreviewPanel::getInstance() { - static IconPreviewPanel &instance = *new IconPreviewPanel(); + IconPreviewPanel *instance = new IconPreviewPanel(); - instance.refreshPreview(); + instance->refreshPreview(); - return instance; + return *instance; } //######################################################################### diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index e0191c589..6be346582 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -31,6 +31,7 @@ #include "sp-item.h" #include "widgets/icon.h" #include "tile.h" +#include "desktop.h" /* * Sort items by their x co-ordinates, taking account of y (keeps rows intact) @@ -161,7 +162,7 @@ void TileDialog::Grid_Arrange () sp_document_ensure_up_to_date(sp_desktop_document(desktop)); Inkscape::Selection *selection = sp_desktop_selection (desktop); - const GSList *items = selection->itemList(); + const GSList *items = selection ? selection->itemList() : 0; cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); @@ -193,6 +194,7 @@ void TileDialog::Grid_Arrange () // require the sorting done before we can calculate row heights etc. + g_return_if_fail(selection); const GSList *items2 = selection->itemList(); GSList *rev = g_slist_copy((GSList *) items2); GSList *sorted = NULL; @@ -373,7 +375,8 @@ void TileDialog::on_row_spinbutton_changed() updating = true; SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); GSList const *items = selection->itemList(); int selcount = g_slist_length((GSList *)items); @@ -398,7 +401,8 @@ void TileDialog::on_col_spinbutton_changed() // in turn, prevent listener from responding updating = true; SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail(selection); GSList const *items = selection->itemList(); int selcount = g_slist_length((GSList *)items); @@ -560,32 +564,33 @@ void TileDialog::updateSelection() // in turn, prevent listener from responding updating = true; SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); - const GSList *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); - - if (NoOfColsSpinner.get_value()>1 && NoOfRowsSpinner.get_value()>1){ - // Update the number of rows assuming number of columns wanted remains same. - double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); - NoOfRowsSpinner.set_value(NoOfRows); - - // if the selection has less than the number set for one row, reduce it appropriately - if (selcountsetInt("/dialogs/gridtiler/NoOfCols", NoOfCols); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + GSList const *items = selection ? selection->itemList() : 0; + + if (items) { + int selcount = g_slist_length((GSList *)items); + + if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ + // Update the number of rows assuming number of columns wanted remains same. + double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); + NoOfRowsSpinner.set_value(NoOfRows); + + // if the selection has less than the number set for one row, reduce it appropriately + if (selcount < NoOfColsSpinner.get_value()) { + double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); + NoOfColsSpinner.set_value(NoOfCols); + prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); + } + } else { + double PerRow = ceil(sqrt(selcount)); + double PerCol = ceil(sqrt(selcount)); + NoOfRowsSpinner.set_value(PerRow); + NoOfColsSpinner.set_value(PerCol); + prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast(PerCol)); } - } else { - double PerRow = ceil(sqrt(selcount)); - double PerCol = ceil(sqrt(selcount)); - NoOfRowsSpinner.set_value(PerRow); - NoOfColsSpinner.set_value(PerCol); - prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast(PerCol)); - } - updating=false; - + updating = false; } @@ -632,7 +637,8 @@ TileDialog::TileDialog() SPDesktop *desktop = getDesktop(); - Inkscape::Selection *selection = sp_desktop_selection (desktop); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { GSList const *items = selection->itemList(); diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 075b2b33f..9ade64935 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -66,10 +66,7 @@ public: void VertAlign_changed(); void HorizAlign_changed(); - static TileDialog& getInstance() { - static TileDialog instance; - return instance; - } + static TileDialog& getInstance() { return *new TileDialog(); } private: TileDialog(TileDialog const &d); // no copy