From cc75b0c7835bacbed44bc86dfb0242502b3db1ba Mon Sep 17 00:00:00 2001
From: cezaryece <czarek@oferuje.pl>
Date: Thu, 29 Aug 2013 11:44:01 +0200
Subject: [PATCH] Faster update of Properties Palette after changin selection
 (fastering text input and changing selection)

---
 Scribus/scribus/ui/propertiespalette.cpp       |   47 +++++++++++++------
 Scribus/scribus/ui/propertiespalette_group.cpp |   29 ++++++------
 Scribus/scribus/ui/propertiespalette_image.cpp |   46 ++++++++-----------
 Scribus/scribus/ui/propertiespalette_line.cpp  |   40 ++++++----------
 Scribus/scribus/ui/propertiespalette_shape.cpp |   29 ++++++------
 Scribus/scribus/ui/propertiespalette_table.cpp |    2 +
 Scribus/scribus/ui/propertiespalette_text.cpp  |   26 +++++------
 Scribus/scribus/ui/propertiespalette_xyz.cpp   |   58 ++++++++++--------------
 Scribus/scribus/util.cpp                       |    8 +++-
 Scribus/scribus/util.h                         |    3 ++
 10 files changed, 148 insertions(+), 140 deletions(-)

diff --git a/Scribus/scribus/ui/propertiespalette.cpp b/Scribus/scribus/ui/propertiespalette.cpp
index b580aba..e33baba 100644
--- a/Scribus/scribus/ui/propertiespalette.cpp
+++ b/Scribus/scribus/ui/propertiespalette.cpp
@@ -407,14 +407,38 @@ void PropertiesPalette::setCurrentItem(PageItem *i)
 		SelTab(TabStack->currentIndex());
 	}
 
-	xyzPal->handleSelectionChanged();
-	shapePal->handleSelectionChanged();
-	groupPal->handleSelectionChanged();
-	imagePal->handleSelectionChanged();
-	linePal->handleSelectionChanged();
-	textPal->handleSelectionChanged();
-	tablePal->handleSelectionChanged();
-
+#pragma omp parallel sections
+	{
+#pragma omp section
+		{
+			xyzPal->handleSelectionChanged();
+		}
+ #pragma omp section
+		{
+			shapePal->handleSelectionChanged();
+		}
+#pragma omp section
+		{
+			groupPal->handleSelectionChanged();
+		}
+#pragma omp section
+		{
+			imagePal->handleSelectionChanged();
+		}
+#pragma omp section
+		{
+			linePal->handleSelectionChanged();
+		}
+#pragma omp section
+		{
+			textPal->handleSelectionChanged();
+		}
+#pragma omp section
+		{
+			tablePal->handleSelectionChanged();
+		}
+	}
+	
 	if (m_item->asOSGFrame())
 	{
 		TabStack->setItemEnabled(idXYZItem, true);
@@ -594,14 +618,11 @@ void  PropertiesPalette::handleSelectionChanged()
 	int currentTab = TabStack->currentIndex();
 	if (TabStack->isItemEnabled(currentTab) && (TabStack->currentIndex() != currentTab))
 		TabStack->setCurrentIndex(currentTab);
+	if (currItem)
+		setCurrentItem(currItem);
 	updateGeometry();
 	repaint();
 	connect(TabStack, SIGNAL(currentChanged(int)), this, SLOT(SelTab(int)));
-
-	if (currItem)
-	{
-		setCurrentItem(currItem);
-	}
 }
 
 void PropertiesPalette::unitChange()
diff --git a/Scribus/scribus/ui/propertiespalette_group.cpp b/Scribus/scribus/ui/propertiespalette_group.cpp
index f76d513..5d93854 100644
--- a/Scribus/scribus/ui/propertiespalette_group.cpp
+++ b/Scribus/scribus/ui/propertiespalette_group.cpp
@@ -137,11 +137,11 @@ void PropertiesPalette_Group::setDoc(ScribusDoc *d)
 	if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
 		return;
 
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 	
 	disconnect(this->transPalWidget, SIGNAL(NewTrans(double)), 0, 0);
 	disconnect(this->transPalWidget, SIGNAL(NewBlend(int)), 0, 0);
@@ -166,17 +166,17 @@ void PropertiesPalette_Group::setDoc(ScribusDoc *d)
 	connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString)));
 	connect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), this, SLOT(handleGroupPatternMaskProps(double, double, double, double, double, double, double, bool, bool)));
 
-	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
 }
 
 void PropertiesPalette_Group::unsetDoc()
 {
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_haveDoc  = false;
 	m_haveItem = false;
@@ -252,7 +252,7 @@ void PropertiesPalette_Group::handleSelectionChanged()
 		setCurrentItem(currItem);
 	}
 	updateGeometry();
-	repaint();
+	//repaint();
 }
 
 void PropertiesPalette_Group::handleUpdateRequest(int updateFlags)
@@ -278,6 +278,8 @@ void PropertiesPalette_Group::setCurrentItem(PageItem *item)
 	m_haveItem = false;
 	m_item = item;
 
+	blockSignalsWithChildrens(this,true);
+	
 	bool   mirrorX, mirrorY;
 	double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY;
 	m_item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation, patternSkewX, patternSkewY);
@@ -339,6 +341,7 @@ void PropertiesPalette_Group::setCurrentItem(PageItem *item)
 		textFlowUsesImageClipping->setEnabled(false);
 	}
 	displayTextFlowMode(m_item->textFlowMode());
+	blockSignalsWithChildrens(this,false);
 }
 
 void PropertiesPalette_Group::displayTextFlowMode(PageItem::TextFlowMode mode)
diff --git a/Scribus/scribus/ui/propertiespalette_image.cpp b/Scribus/scribus/ui/propertiespalette_image.cpp
index 92bac01..d3a041c 100644
--- a/Scribus/scribus/ui/propertiespalette_image.cpp
+++ b/Scribus/scribus/ui/propertiespalette_image.cpp
@@ -135,11 +135,11 @@ void PropertiesPalette_Image::setDoc(ScribusDoc *d)
 	if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
 		return;
 
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_doc  = d;
 	m_item = NULL;
@@ -161,17 +161,17 @@ void PropertiesPalette_Image::setDoc(ScribusDoc *d)
 	imgDpiX->setValues( 1, 30000, 2, 1);
 	imgDpiY->setValues( 1, 30000, 2, 1);
 
-	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
 }
 
 void PropertiesPalette_Image::unsetDoc()
 {
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_haveDoc  = false;
 	m_haveItem = false;
@@ -416,7 +416,7 @@ void PropertiesPalette_Image::handleSelectionChanged()
 		setCurrentItem(currItem);
 	}
 	updateGeometry();
-	repaint();
+	//repaint();
 }
 
 void PropertiesPalette_Image::handleUpdateRequest(int updateFlags)
@@ -441,10 +441,10 @@ void PropertiesPalette_Image::setCurrentItem(PageItem *item)
 
 	m_haveItem = false;
 	m_item = item;
-
+	blockSignalsWithChildrens(this,true);
 	if (m_item->asImageFrame())
 	{
-		imagePageNumber->blockSignals(true);
+
 		if(m_item->PictureIsAvailable)
 		{
 			imagePageNumber->setMaximum(m_item->pixm.imgInfo.numberOfPages);
@@ -456,14 +456,8 @@ void PropertiesPalette_Image::setCurrentItem(PageItem *item)
 
 		compressionMethod->setCurrentIndex(m_item->OverrideCompressionMethod ? m_item->CompressionMethodIndex + 1 : 0);
 		compressionQuality->setCurrentIndex(m_item->OverrideCompressionQuality ? m_item->CompressionQualityIndex + 1 : 0);
-		imagePageNumber->blockSignals(false);
-
-		imageXScaleSpinBox->blockSignals(true);
-		imageYScaleSpinBox->blockSignals(true);
-		imageXOffsetSpinBox->blockSignals(true);
-		imageYOffsetSpinBox->blockSignals(true);
-		imageRotation->blockSignals(true);
 
+		
 		imgEffectsButton->setVisible(m_item->PictureIsAvailable && m_item->isRaster);
 		imgExtProperties->setVisible(m_item->PictureIsAvailable && m_item->pixm.imgInfo.valid);
 		bool setter = m_item->ScaleType;
@@ -505,11 +499,8 @@ void PropertiesPalette_Image::setCurrentItem(PageItem *item)
 		//imageYOffsetSpinBox->setEnabled(setter);
 		//imageRotation->setEnabled(setter);
 
-		imageXScaleSpinBox->blockSignals(false);
-		imageYScaleSpinBox->blockSignals(false);
-		imageXOffsetSpinBox->blockSignals(false);
-		imageYOffsetSpinBox->blockSignals(false);
-		imageRotation->blockSignals(false);
+		foreach (QWidget* obj, findChildren<QWidget *>())
+			obj->blockSignals(false);
 	}
 	m_haveItem = true;
 
@@ -531,6 +522,7 @@ void PropertiesPalette_Image::setCurrentItem(PageItem *item)
 	{
 		setEnabled(false);
 	}
+	blockSignalsWithChildrens(this,false);
 }
 
 void PropertiesPalette_Image::handleLocalXY()
diff --git a/Scribus/scribus/ui/propertiespalette_line.cpp b/Scribus/scribus/ui/propertiespalette_line.cpp
index 33d7a8c..4c7a2c7 100644
--- a/Scribus/scribus/ui/propertiespalette_line.cpp
+++ b/Scribus/scribus/ui/propertiespalette_line.cpp
@@ -124,11 +124,11 @@ void PropertiesPalette_Line::setDoc(ScribusDoc *d)
 	if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
 		return;
 
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_doc  = d;
 	m_item = NULL;
@@ -145,17 +145,17 @@ void PropertiesPalette_Line::setDoc(ScribusDoc *d)
 	startArrow->rebuildList(&m_doc->arrowStyles());
 	endArrow->rebuildList(&m_doc->arrowStyles());
 
-	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
 }
 
 void PropertiesPalette_Line::unsetDoc()
 {
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_haveDoc  = false;
 	m_haveItem = false;
@@ -224,7 +224,7 @@ void PropertiesPalette_Line::handleSelectionChanged()
 		setCurrentItem(currItem);
 	}
 	updateGeometry();
-	repaint();
+	//repaint();
 }
 
 void PropertiesPalette_Line::handleUpdateRequest(int updateFlags)
@@ -252,12 +252,7 @@ void PropertiesPalette_Line::setCurrentItem(PageItem *item)
 	m_haveItem = false;
 	m_item = item;
 
-	lineStyles->blockSignals(true);
-	startArrow->blockSignals(true);
-	endArrow->blockSignals(true);
-	startArrowScale->blockSignals(true);
-	endArrowScale->blockSignals(true);
-	lineMode->blockSignals(true);
+	blockSignalsWithChildrens(this,true);
 
 	if ((m_item->asLine()) || (m_item->asPolyLine()) || (m_item->asSpiral()))
 	{
@@ -317,12 +312,7 @@ void PropertiesPalette_Line::setCurrentItem(PageItem *item)
 	else
 		lineMode->setCurrentIndex(0);
 
-	lineStyles->blockSignals(false);
-	startArrow->blockSignals(false);
-	endArrow->blockSignals(false);
-	startArrowScale->blockSignals(false);
-	endArrowScale->blockSignals(false);
-	lineMode->blockSignals(false);
+	blockSignalsWithChildrens(this,false);
 
 	setter = false;
 
diff --git a/Scribus/scribus/ui/propertiespalette_shape.cpp b/Scribus/scribus/ui/propertiespalette_shape.cpp
index 5d25d01..0b23042 100644
--- a/Scribus/scribus/ui/propertiespalette_shape.cpp
+++ b/Scribus/scribus/ui/propertiespalette_shape.cpp
@@ -93,11 +93,11 @@ void PropertiesPalette_Shape::setDoc(ScribusDoc *d)
 	if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
 		return;
 
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_doc  = d;
 	m_item = NULL;
@@ -109,17 +109,17 @@ void PropertiesPalette_Shape::setDoc(ScribusDoc *d)
 
 	roundRect->setValues( -300, 300, 2, 0);
 
-	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
 }
 
 void PropertiesPalette_Shape::unsetDoc()
 {
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_haveDoc  = false;
 	m_haveItem = false;
@@ -313,7 +313,7 @@ void PropertiesPalette_Shape::handleSelectionChanged()
 	}
 	setCurrentItem(currItem);
 	updateGeometry();
-	repaint();
+	//repaint();
 }
 
 void PropertiesPalette_Shape::handleUpdateRequest(int updateFlags)
@@ -337,6 +337,7 @@ void PropertiesPalette_Shape::setCurrentItem(PageItem *item)
 
 	if (item && !m_doc)
 		setDoc(item->doc());
+	blockSignalsWithChildrens(this,true);
 
 	m_haveItem = false;
 	m_item = item;
@@ -370,6 +371,8 @@ void PropertiesPalette_Shape::setCurrentItem(PageItem *item)
 	setSizeLocked(m_item->sizeLocked());
 //	nonZero->setChecked(!m_item->fillRule);
 //	evenOdd->setChecked(m_item->fillRule);
+	blockSignalsWithChildrens(this,false);
+	
 
 	// Frame type 3 is obsolete: CR 2005-02-06
 	//if (((i->itemType() == PageItem::TextFrame) || (i->itemType() == PageItem::ImageFrame) || (i->itemType() == 3)) &&  (!i->ClipEdited))
diff --git a/Scribus/scribus/ui/propertiespalette_table.cpp b/Scribus/scribus/ui/propertiespalette_table.cpp
index b5aae89..fad94d3 100644
--- a/Scribus/scribus/ui/propertiespalette_table.cpp
+++ b/Scribus/scribus/ui/propertiespalette_table.cpp
@@ -113,8 +113,10 @@ void PropertiesPalette_Table::handleSelectionChanged()
 
 	sideSelector->setSelection(TableSideSelector::All);
 
+	blockSignalsWithChildrens(this,true);
 	updateFillControls();
 	updateStyleControls();
+	blockSignalsWithChildrens(this,false);
 }
 
 void PropertiesPalette_Table::handleCellSelectionChanged()
diff --git a/Scribus/scribus/ui/propertiespalette_text.cpp b/Scribus/scribus/ui/propertiespalette_text.cpp
index eb3e5e2..927db24 100644
--- a/Scribus/scribus/ui/propertiespalette_text.cpp
+++ b/Scribus/scribus/ui/propertiespalette_text.cpp
@@ -179,11 +179,11 @@ void PropertiesPalette_Text::setDoc(ScribusDoc *d)
 	if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
 		return;
 
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_doc  = d;
 	m_item = NULL;
@@ -211,19 +211,19 @@ void PropertiesPalette_Text::setDoc(ScribusDoc *d)
 	paraStyleCombo->setDoc(m_doc);
 	charStyleCombo->setDoc(m_doc);
 
-	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
 	connectSignals(true);
 }
 
 void PropertiesPalette_Text::unsetDoc()
 {
 	disconnectSignals(true);
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_haveDoc  = false;
 	m_haveItem = false;
@@ -317,7 +317,7 @@ void PropertiesPalette_Text::handleSelectionChanged()
 	}
 	connectSignals(true);
 	updateGeometry();
-	repaint();
+	//repaint();
 }
 
 void PropertiesPalette_Text::handleUpdateRequest(int updateFlags)
diff --git a/Scribus/scribus/ui/propertiespalette_xyz.cpp b/Scribus/scribus/ui/propertiespalette_xyz.cpp
index bf007e9..bc25920 100644
--- a/Scribus/scribus/ui/propertiespalette_xyz.cpp
+++ b/Scribus/scribus/ui/propertiespalette_xyz.cpp
@@ -156,11 +156,11 @@ void PropertiesPalette_XYZ::setDoc(ScribusDoc *d)
 	if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
 		return;
 
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_doc  = d;
 	m_item = NULL;
@@ -188,17 +188,17 @@ void PropertiesPalette_XYZ::setDoc(ScribusDoc *d)
 
 	updateSpinBoxConstants();
 
-	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//	connect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
 }
 
 void PropertiesPalette_XYZ::unsetDoc()
 {
-	if (m_doc)
-	{
-		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
-		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
-	}
+//	if (m_doc)
+//	{
+//		disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+//		disconnect(m_doc             , SIGNAL(docChanged())      , this, SLOT(handleSelectionChanged()));
+//	}
 
 	m_haveDoc  = false;
 	m_haveItem = false;
@@ -298,17 +298,7 @@ void PropertiesPalette_XYZ::setCurrentItem(PageItem *i)
 
 	connect(nameEdit, SIGNAL(Leaved()), this, SLOT(handleNewName()));
 
-//CB replaces old emits from PageItem::emitAllToGUI()
-	disconnect(xposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
-	disconnect(yposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
-	disconnect(widthSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
-	disconnect(heightSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
-	disconnect(doLock, SIGNAL(clicked()), this, SLOT(handleLock()));
-	disconnect(noPrint, SIGNAL(clicked()), this, SLOT(handlePrint()));
-	disconnect(noResize, SIGNAL(clicked()), this, SLOT(handleLockSize()));
-	disconnect(flipH, SIGNAL(clicked()), this, SLOT(handleFlipH()));
-	disconnect(flipV, SIGNAL(clicked()), this, SLOT(handleFlipV()));
-	disconnect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));
+	blockSignalsWithChildrens(this,true);
 
 	double selX = m_item->xPos();
 	double selY = m_item->yPos();
@@ -332,17 +322,7 @@ void PropertiesPalette_XYZ::setCurrentItem(PageItem *i)
 		rr = 360 - rr;
 	rotationSpin->setValue(fabs(rr));
 
-//CB TODO reconnect PP signals from here
-	connect(xposSpin    , SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
-	connect(yposSpin    , SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
-	connect(widthSpin   , SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
-	connect(heightSpin  , SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
-	connect(doLock  , SIGNAL(clicked()), this, SLOT(handleLock()));
-	connect(noPrint , SIGNAL(clicked()), this, SLOT(handlePrint()));
-	connect(noResize, SIGNAL(clicked()), this, SLOT(handleLockSize()));
-	connect(flipH   , SIGNAL(clicked()), this, SLOT(handleFlipH()));
-	connect(flipV   , SIGNAL(clicked()), this, SLOT(handleFlipV()));
-	connect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));
+	blockSignalsWithChildrens(this,false);
 
 	bool setter = false;
 	xposSpin->setEnabled(!setter);
@@ -542,7 +522,7 @@ void PropertiesPalette_XYZ::handleSelectionChanged()
 		setCurrentItem(currItem);
 	}
 	updateGeometry();
-	repaint();
+	//repaint();
 }
 
 void PropertiesPalette_XYZ::unitChange()
@@ -638,6 +618,8 @@ void PropertiesPalette_XYZ::displayWH(double x, double y)
 	m_haveItem = false;
 	QTransform ma;
 	QPoint dp;
+	disconnect(widthSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
+	disconnect(heightSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
 	if ((m_lineMode) && (m_item->asLine()))
 	{
 		ma.translate(static_cast<double>(xposSpin->value()) / m_unitRatio, static_cast<double>(yposSpin->value()) / m_unitRatio);
@@ -652,6 +634,8 @@ void PropertiesPalette_XYZ::displayWH(double x, double y)
 		widthSpin->setValue(x*m_unitRatio);
 		heightSpin->setValue(y*m_unitRatio);
 	}
+	connect(widthSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
+	connect(heightSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
 	m_haveItem = tmp;
 }
 
@@ -664,7 +648,11 @@ void PropertiesPalette_XYZ::displayRotation(double r)
 	if (r > 0)
 		rr = 360 - rr;
 	m_haveItem = false;
+
+	disconnect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));
 	rotationSpin->setValue(fabs(rr));
+	connect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));
+
 	m_haveItem = tmp;
 }
 
diff --git a/Scribus/scribus/util.cpp b/Scribus/scribus/util.cpp
index 6ee7da0..e161331 100644
--- a/Scribus/scribus/util.cpp
+++ b/Scribus/scribus/util.cpp
@@ -30,6 +30,7 @@ for which a new license (GPL+exception) is in place.
 #include <QDomElement>
 #include <QMessageBox>
 #include <QProcess>
+#include <QWidget>
 
 #include "pageitem.h"
 #include "pageitem_table.h"
@@ -1191,4 +1192,9 @@ void getUniqueName(QString &name, QStringList list, QString separator, bool prep
 	} while (list.contains(newName));
 	name = newName;
 }
-
+void blockSignalsWithChildrens(QWidget * w, bool block)
+{
+	w->blockSignals(block);
+	foreach (QWidget* obj, w->findChildren<QWidget *>())
+		blockSignalsWithChildrens(obj, block);
+}
diff --git a/Scribus/scribus/util.h b/Scribus/scribus/util.h
index a94d8d3..a1e4977 100644
--- a/Scribus/scribus/util.h
+++ b/Scribus/scribus/util.h
@@ -174,4 +174,7 @@ void SCRIBUS_API setWidgetBoldFont(QWidget* w, bool wantBold);
  * if exist then seprator and numbers are pre/append to name while it will be unique
 */
 void SCRIBUS_API getUniqueName(QString &name, QStringList list, QString separator = "", bool prepend = false);
+
+//set blockSingnals to widget and all childs
+void SCRIBUS_API blockSignalsWithChildrens(QWidget * w, bool block);
 #endif
-- 
1.7.9.5

