View Issue Details

IDProjectCategoryView StatusLast Update
0013225ScribusGeneralpublic2015-12-02 09:46
ReporterFirasH Assigned Tojghali  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Platformx86_64OSopenSUSEOS Version13.2
Product Version1.5.1svn 
Target Version1.5.1Fixed in Version1.4.6.svn 
Summary0013225: "Replace All" in Search/Replace dialog freezes Scribus in determined condition
Description"Replace All" in Search/Replace dialog freezes Scribus in determined condition.
Btw I created a .ui file for the dialog starting from search.cpp source code, keeping original objects names etc. I'll attach it here as I cannot sort out how to link the .ui ti the correspondent .cpp and .h files, hope it's useful.
Steps To Reproduce0) Create a new document
1) Insert a Text Frame + Add some text
2) Select the Text Frame and Edit > Search/Replace
3) Uncheck any of the checkboxes under "Search for:" box
4) Click on "Search"

Now "Replace" and "Replace All" are enabled.

5) Click on "Replace All"

Scribus is blocked.

[EDIT] : reproduceable detailed steps

0) Create a new document
1) Insert a Text Frame + Add some text
2) Select the Text Frame and Edit > Search/Replace
3) The "Search for:" column has a 'Text' field, that could have some content
4) Delete that content (if you need to enable "Search for:" column to do this, then do so)
5) Uncheck any of the checkboxes under "Search for:" column
6) Make sure 'Replace with:' section has 'Text' enabled and empty
7) Click on "Search"

Now "Replace" and "Replace All" are enabled.

9) Click "Replace All"
Scribus hangs
Additional Information1.5.1.svn (20245)
1.4.6.svn (20243)
TagsHOST-Oman
PatchYes

Relationships

related to 0011818 new [PATCH] No page range check in PDF export dialog 

Activities

FirasH

2015-07-12 02:39

developer  

13225-search.ui.zip (1,834 bytes)

Kunda

2015-07-14 01:30

updater   ~0035772

Last edited: 2015-10-28 01:55

EDIT: moved backtrace in to file and attached to issue

jghali

2015-07-14 14:22

administrator   ~0035776

Cannot reproduce this issue on Windows. After 4), "Replace" and "Replace All" button do not get enabled.

FirasH

2015-07-14 15:08

developer   ~0035777

The issue happens only when "Replace with:" checkboxes are enabled.
(void SearchReplace::slotDoReplace() in search.cpp)

I don't know how Search/Replace should manage this case... replace everything with the selected style/color/etc. in "Replace with:" when checkboxes under "Search for:" are not enabled or simply avoiding this possibility.

Kunda

2015-10-28 01:56

updater  

bt.txt (6,639 bytes)   
<pre>
(lldb) bt
* thread #1: tid = 0x2b63d, 0x00000001007ef833 Scribus`StoryText::deselectAll() + 1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00000001007ef833 Scribus`StoryText::deselectAll() + 1
    frame #1: 0x0000000100727e1b Scribus`SearchReplace::slotDoReplace() + 2875
    frame #2: 0x0000000100728030 Scribus`SearchReplace::slotReplaceAll() + 44
    frame #3: 0x00000001037f6f49 QtCore`QMetaObject::activate(QObject*, int, int, void**) + 2953
    frame #4: 0x00000001026a3f50 QtWidgets`QAbstractButton::clicked(bool) + 64
    frame #5: 0x00000001023f953a QtWidgets`QAbstractButtonPrivate::emitClicked() + 58
    frame #6: 0x00000001023f93a7 QtWidgets`QAbstractButtonPrivate::click() + 263
    frame #7: 0x00000001023fa3de QtWidgets`QAbstractButton::mouseReleaseEvent(QMouseEvent*) + 270
    frame #8: 0x000000010235485b QtWidgets`QWidget::event(QEvent*) + 1675
    frame #9: 0x00000001023fa133 QtWidgets`QAbstractButton::event(QEvent*) + 179
    frame #10: 0x0000000102314713 QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 307
    frame #11: 0x0000000102317ec1 QtWidgets`QApplication::notify(QObject*, QEvent*) + 9233
    frame #12: 0x00000001037c4253 QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    frame #13: 0x00000001023150c4 QtWidgets`QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) + 1012
    frame #14: 0x000000010236f906 QtWidgets`QWidgetWindow::handleMouseEvent(QMouseEvent*) + 1190
    frame #15: 0x000000010236eb5f QtWidgets`QWidgetWindow::event(QEvent*) + 111
    frame #16: 0x0000000102314713 QtWidgets`QApplicationPrivate::notify_helper(QObject*, QEvent*) + 307
    frame #17: 0x0000000102317b15 QtWidgets`QApplication::notify(QObject*, QEvent*) + 8293
    frame #18: 0x00000001037c4253 QtCore`QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
    frame #19: 0x00000001029cb260 QtGui`QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2032
    frame #20: 0x00000001029b74ba QtGui`QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
    frame #21: 0x0000000105b6d941 libqcocoa.dylib`QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 33
    frame #22: 0x00007fff8ec80a01 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #23: 0x00007fff8ec72b8d CoreFoundation`__CFRunLoopDoSources0 + 269
    frame #24: 0x00007fff8ec721bf CoreFoundation`__CFRunLoopRun + 927
    frame #25: 0x00007fff8ec71bd8 CoreFoundation`CFRunLoopRunSpecific + 296
    frame #26: 0x00007fff9522956f HIToolbox`RunCurrentEventLoopInMode + 235
    frame #27: 0x00007fff952291ee HIToolbox`ReceiveNextEventCommon + 179
    frame #28: 0x00007fff9522912b HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
    frame #29: 0x00007fff8d2679bb AppKit`_DPSNextEvent + 978
    frame #30: 0x00007fff8d266f68 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
    frame #31: 0x00007fff8d432987 AppKit`-[NSApplication _realDoModalLoop:peek:] + 666
    frame #32: 0x00007fff8d65cf44 AppKit`-[NSApplication runModalSession:] + 71
    frame #33: 0x0000000105b6c7ca libqcocoa.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2058
    frame #34: 0x00000001037c1a3c QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 396
    frame #35: 0x00000001024fbd1a QtWidgets`QDialog::exec() + 522
    frame #36: 0x00000001003c8e8f Scribus`ScribusMainWindow::SearchText() + 251
    frame #37: 0x00000001037f6f49 QtCore`QMetaObject::activate(QObject*, int, int, void**) + 2953
    frame #38: 0x000000010230b8e0 QtWidgets`QAction::activate(QAction::ActionEvent) + 288
    frame #39: 0x00000001037f6f49 QtCore`QMetaObject::activate(QObject*, int, int, void**) + 2953
    frame #40: 0x0000000105b703b0 libqcocoa.dylib`-[QCocoaMenuDelegate itemFired:] + 112
    frame #41: 0x00007fff92ff4cd7 libsystem_trace.dylib`_os_activity_initiate + 75
    frame #42: 0x00007fff8d42afb1 AppKit`-[NSApplication sendAction:to:from:] + 452
    frame #43: 0x00007fff8d42ad4e AppKit`-[NSMenuItem _corePerformAction] + 382
    frame #44: 0x00007fff8d42aa7c AppKit`-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
    frame #45: 0x00007fff92ff4cd7 libsystem_trace.dylib`_os_activity_initiate + 75
    frame #46: 0x00007fff8d4f1c10 AppKit`-[NSMenu performActionForItemAtIndex:] + 131
    frame #47: 0x00007fff8d4f1b76 AppKit`-[NSMenu _internalPerformActionForItemAtIndex:] + 35
    frame #48: 0x00007fff8d4f19c2 AppKit`-[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 107
    frame #49: 0x00007fff8d412e6b AppKit`NSSLMMenuEventHandler + 724
    frame #50: 0x00007fff951ffb6c HIToolbox`DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1260
    frame #51: 0x00007fff951fefae HIToolbox`SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 386
    frame #52: 0x00007fff95214cb6 HIToolbox`SendEventToEventTarget + 40
    frame #53: 0x00007fff9524ef45 HIToolbox`SendHICommandEvent(unsigned int, HICommand const*, unsigned int, unsigned int, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 428
    frame #54: 0x00007fff9528cb8d HIToolbox`SendMenuCommandWithContextAndModifiers + 59
    frame #55: 0x00007fff9528cb30 HIToolbox`SendMenuItemSelectedEvent + 188
    frame #56: 0x00007fff9528ca09 HIToolbox`FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*) + 96
    frame #57: 0x00007fff9528d481 HIToolbox`MenuSelectCore(MenuData*, Point, double, unsigned int, OpaqueMenuRef**, unsigned short*) + 702
    frame #58: 0x00007fff9528d0fe HIToolbox`_HandleMenuSelection2 + 446
    frame #59: 0x00007fff8d330de0 AppKit`_NSHandleCarbonMenuEvent + 277
    frame #60: 0x00007fff8d267d0d AppKit`_DPSNextEvent + 1828
    frame #61: 0x00007fff8d266f68 AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 346
    frame #62: 0x00007fff8d25cbf3 AppKit`-[NSApplication run] + 594
    frame #63: 0x0000000105b6c89a libqcocoa.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2266
    frame #64: 0x00000001037c1a3c QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 396
    frame #65: 0x00000001037c47fa QtCore`QCoreApplication::exec() + 346
    frame #66: 0x00000001007d8a09 Scribus`mainApp(int, char**) + 90
    frame #67: 0x00007fff9450d5c9 libdyld.dylib`start + 1
    frame #68: 0x00007fff9450d5c9 libdyld.dylib`start + 1
</pre>
bt.txt (6,639 bytes)   

Kunda

2015-10-28 02:10

updater   ~0037012

This bug is tricky.. I can recreate it but not consistently.

Kunda

2015-10-28 03:01

updater   ~0037013

Ok.. Here is how to recreate the bug:
0) Create a new document
1) Insert a Text Frame + Add some text
2) Select the Text Frame and Edit > Search/Replace
3) The "Search for:" column has a 'Text' field, that should have a '2' value
4) Delete the '2' (if you need to enable "Search for:" column to do this, then do so)
5) Uncheck any of the checkboxes under "Search for:" column
6) Make sure 'Replace with:' section has 'Text' enabled and empty
7) Click on "Search"

Now "Replace" and "Replace All" are enabled.

9) Click "Replace All"
Scribus hangs

See attached screencast

Kunda

2015-10-28 03:03

updater  

JLuc

2015-10-30 20:57

developer   ~0037126

I confirm detailed steps do hang scribus. I edited the report.

aliyousuf

2015-11-16 07:20

reporter   ~0037508

What are right behaviour for this problem?

aliyousuf

2015-11-17 07:28

reporter   ~0037523

If click on "Replace",replace only one "space".
If click on "Replace All",replace more than "space" that mean there are loop to replace all the space.

On other try this :
0) Create a new document
1) Insert a Text Frame + Add some text
2) Select the Text Frame and Edit > Search/Replace
3) The "Search for:" column has a 'Text' field,
4) Delete the '2' (if you need to enable "Search for:" column to do this, then do so)
5) Uncheck any of the checkboxes under "Search for:" column
6) Make sure 'Replace with:' section has 'Text' enabled and write "e" as example .
7) Click on "Search"

Now "Replace" and "Replace All" are enabled.

9) Click "Replace"
10) see the text frame "e",when click on "Replace" ,add "e" on text fram
11)Click "Replace All" the scribus is hang.

aliyousuf

2015-11-17 07:29

reporter  

out.ogv (2,504,434 bytes)   

aliyousuf

2015-11-17 07:30

reporter   ~0037524

I upload out.ogv to explain more.

JLuc

2015-11-17 08:25

developer   ~0037526

Why should we open this video ?
Can you explain what is to bee seen on this video ?

Kunda

2015-11-17 11:42

updater   ~0037530

aliyousuf, hey thanks for the clip. It looks like you've triggered the bug in a different way or perhaps found another bug

Why do you think this bug is occurring ?

aliyousuf

2015-11-19 05:21

reporter   ~0037549

Last edited: 2015-11-19 05:23

It is some bug but I want to explain it more
This bug occur because when click on "Replace ",Its replace only one space with "e".if you click on "Replace All",its replace all space with "e".On other word,"Replace" mean replace only one if its found and "Replace All" mean replace more than one time if its found.

aliyousuf

2015-11-19 05:26

reporter   ~0037550

Explanation above explain video "out.ogv".

aliyousuf

2015-11-19 09:23

reporter   ~0037551

I upload issue.patch to solve this problem.

If any check box is checked on col "search for" then you can use "Replace"and "Replace All" else can not use "Replace"and "Replace All".

Kunda

2015-11-19 11:25

updater   ~0037552

Setting this issue 'sticky'

JLuc

2015-11-21 19:54

developer   ~0037577

Tested OK.

Please look and merge.

Note : "search" button could also be grayed additionnaly but that's not a problem when it isnt.

jghali

2015-11-22 00:09

administrator   ~0037582

The patch is according to my tests incomplete : proceed so as to get the replace buttons enabled, uncheck all checkbox in the replace columns, click "Replace All". Scribus hangs again.

aliyousuf

2015-11-22 05:41

reporter   ~0037586

jghali,Can explain more?

jghali

2015-11-22 23:12

administrator   ~0037594

aliyousuf, that means that even with your patch i can still reproduce the issue:

0) Create a new document
1) Insert a Text Frame + Add some text
2) Select the Text Frame and Edit > Search/Replace
3) The "Search for:" column has a 'Text' field, that could have some content
4) If necessary modify that content so you're sure search will get a result
5) Click on "Search"

"Replace" and "Replace All" will now be enabled

6) Uncheck any of the checkboxes under "Replace with:" column
7) Click "Replace All"

Scribus hangs again.

jghali

2015-11-23 21:26

administrator  

13225_replace_all_loop.patch (6,644 bytes)   
Index: scribus/ui/search.cpp
===================================================================
--- scribus/ui/search.cpp	(revision 20567)
+++ scribus/ui/search.cpp	(working copy)
@@ -288,6 +288,7 @@
 	connect( DoSearch, SIGNAL( clicked() ), this, SLOT( slotSearch() ) );
 	connect( DoReplace, SIGNAL( clicked() ), this, SLOT( slotReplace() ) );
 	connect( AllReplace, SIGNAL( clicked() ), this, SLOT( slotReplaceAll() ) );
+	connect( STextVal, SIGNAL( textChanged(QString) ), this, SLOT( updateSearchButtonState() ) );
 	connect( SText, SIGNAL( clicked() ), this, SLOT( enableTxSearch() ) );
 	connect( SStyle, SIGNAL( clicked() ), this, SLOT( enableStyleSearch() ) );
 	connect( SAlign, SIGNAL( clicked() ), this, SLOT( enableAlignSearch() ) );
@@ -391,12 +392,17 @@
 	int sEff = 0;
 	int sFillSh = 100;
 	int sStrokeSh = 100;
+	bool searchForReplace = false;
 	bool rep = false;
 	bool found = true;
 	if ((RFill->isChecked()) || (RStroke->isChecked()) || (RStyle->isChecked()) || (RFont->isChecked())
 		|| (RStrokeS->isChecked()) || (RFillS->isChecked()) || (RSize->isChecked()) || (RText->isChecked())
-		|| (REffect->isChecked()))
+		|| (REffect->isChecked())  || (RAlign->isChecked()))
 		rep = true;
+	if ((SFill->isChecked()) || (SStroke->isChecked()) || (SStyle->isChecked()) || (SFont->isChecked())
+			|| (SStrokeS->isChecked()) || (SFillS->isChecked()) || (SSize->isChecked()) || (SText->isChecked())
+			|| (SEffect->isChecked())  || (SAlign->isChecked()))
+		searchForReplace = true;
 	if (SText->isChecked())
 		sText = STextVal->text();
 	if (CaseIgnore->isChecked())
@@ -496,7 +502,7 @@
 				if (m_item->itemText.charStyle(a).fillColor() != fCol)
 					found = false;
 			}
-			if (found)
+			if (found && searchForReplace)
 			{
 				m_item->itemText.select(a, sText.length());
 				m_item->HasSel = true;
@@ -632,7 +638,7 @@
 				storyTextEdit->setTextCursor(cursor);
 			}
 		}
-		if (found)
+		if (found && searchForReplace)
 		{
 			// m_doc->scMW()->CurrStED->updateProps(); FIXME
 			if (rep)
@@ -839,51 +845,61 @@
 	CaseIgnore->setEnabled(setter);
 	if (setter)
 		STextVal->setFocus();
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableStyleSearch()
 {
 	SStyleVal->setEnabled(SStyleVal->count() ? SStyle->isChecked() : false);
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableAlignSearch()
 {
 	SAlignVal->setEnabled(SAlign->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableFontSearch()
 {
 	SFontVal->setEnabled(SFont->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableSizeSearch()
 {
 	SSizeVal->setEnabled(SSize->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableEffSearch()
 {
 	SEffVal->setEnabled(SEffect->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableFillSearch()
 {
 	SFillVal->setEnabled(SFill->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableFillSSearch()
 {
 	SFillSVal->setEnabled(SFillS->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableStrokeSearch()
 {
 	SStrokeVal->setEnabled(SStroke->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableStrokeSSearch()
 {
 	SStrokeSVal->setEnabled(SStrokeS->isChecked());
+	updateSearchButtonState();
 }
 
 void SearchReplace::enableTxReplace()
@@ -891,51 +907,61 @@
 	RTextVal->setEnabled(RText->isChecked());
 	if (RText->isChecked())
 		RTextVal->setFocus();
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableStyleReplace()
 {
 	RStyleVal->setEnabled(RStyle->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableAlignReplace()
 {
 	RAlignVal->setEnabled(RAlign->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableFontReplace()
 {
 	RFontVal->setEnabled(RFont->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableSizeReplace()
 {
 	RSizeVal->setEnabled(RSize->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableEffReplace()
 {
 	REffVal->setEnabled(REffect->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableFillReplace()
 {
 	RFillVal->setEnabled(RFill->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableFillSReplace()
 {
 	RFillSVal->setEnabled(RFillS->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableStrokeReplace()
 {
 	RStrokeVal->setEnabled(RStroke->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::enableStrokeSReplace()
 {
 	RStrokeSVal->setEnabled(RStrokeS->isChecked());
+	updateReplaceButtonsState();
 }
 
 void SearchReplace::clear()
@@ -996,6 +1022,40 @@
 	enableStrokeSReplace();
 }
 
+void SearchReplace::updateReplaceButtonsState()
+{
+	bool replaceEnabled = false;
+	if (RFill->isChecked() || RStroke->isChecked() || RStyle->isChecked() || RFont->isChecked()  ||
+		RStrokeS->isChecked() || RFillS->isChecked() || RSize->isChecked() || REffect->isChecked() ||
+		RAlign->isChecked())
+	{
+		replaceEnabled = true;
+	}
+	replaceEnabled |= RText->isChecked();
+	if (m_itemMode)
+		replaceEnabled &= (m_item->itemText.lengthOfSelection() > 0);
+	else if (m_doc->scMW()->CurrStED != NULL)
+		replaceEnabled &= m_doc->scMW()->CurrStED->Editor->textCursor().hasSelection();
+	else
+		replaceEnabled = false;
+	replaceEnabled &= m_notFound;
+	DoReplace->setEnabled(replaceEnabled);
+	AllReplace->setEnabled(replaceEnabled);
+}
+
+void SearchReplace::updateSearchButtonState()
+{
+	bool searchEnabled = false;
+	if (SFill->isChecked() || SStroke->isChecked() || SStyle->isChecked() || SFont->isChecked() ||
+		SStrokeS->isChecked() || SFillS->isChecked() || SSize->isChecked() || SEffect->isChecked() ||
+		SAlign->isChecked())
+	{
+		searchEnabled = true;
+	}
+	searchEnabled |= (SText->isChecked() && !STextVal->text().isEmpty());
+	DoSearch->setEnabled(searchEnabled);
+}
+
 void SearchReplace::readPrefs()
 {
 	SStroke->setChecked(m_prefs->getBool("SStroke", false));
Index: scribus/ui/search.h
===================================================================
--- scribus/ui/search.h	(revision 20567)
+++ scribus/ui/search.h	(working copy)
@@ -115,6 +115,8 @@
 	virtual void enableFillSReplace();
 	virtual void enableStrokeReplace();
 	virtual void enableStrokeSReplace();
+	virtual void updateReplaceButtonsState();
+	virtual void updateSearchButtonState();
 	virtual void writePrefs();
 	virtual void clear();
 
@@ -137,6 +139,7 @@
 	QGridLayout* ReplaceLayout;
 	QHBoxLayout* OptsLayout;
 	QHBoxLayout* ButtonsLayout;
+
 	virtual void readPrefs();
 
 	/// Number of matches found thus far in a search
13225_replace_all_loop.patch (6,644 bytes)   

jghali

2015-11-23 21:28

administrator   ~0037614

Based on aliyousuf work, I did my own attempt at fixing this issue. I uploaded the patch. I think I filled the remaining gaps.

jghali

2015-11-23 23:09

administrator   ~0037620

I committed the patch, please test. If ok, i'll backport the fix to 1.4.6.svn

aliyousuf

2015-11-24 05:22

reporter  

issue.patch (9,452 bytes)   
Index: scribus/ui/search.cpp
===================================================================
--- scribus/ui/search.cpp	(revision 20560)
+++ scribus/ui/search.cpp	(working copy)
@@ -1,4 +1,4 @@
-/*
+/*
 For general Scribus (>=1.3.2) copyright and licensing information please refer
 to the COPYING file provided with the program. Following this notice may exist
 a copyright and/or license notice that predates the release of Scribus 1.3.2
@@ -267,7 +267,7 @@
 	ButtonsLayout->setSpacing( 5 );
 	ButtonsLayout->setMargin( 0 );
 	DoSearch = new QPushButton( tr( "&Search" ), this );
-	DoSearch->setDefault( true );
+	DoSearch->setEnabled(false);
 	ButtonsLayout->addWidget( DoSearch );
 	DoReplace = new QPushButton( tr( "&Replace" ), this );
 	DoReplace->setEnabled(false);
@@ -356,6 +356,11 @@
 
 	m_prefs = PrefsManager::instance()->prefsFile->getContext("SearchReplace");
 	readPrefs();
+	RText->setChecked(false);
+	RTextVal->setEnabled(false);
+	DoReplace->setEnabled(false);
+	AllReplace->setEnabled(false);
+	setEnabledR(false);
 }
 
 void SearchReplace::slotSearch()
@@ -375,6 +380,7 @@
 	int maxChar = m_item->itemText.length() - 1;
 	DoReplace->setEnabled(false);
 	AllReplace->setEnabled(false);
+	setEnabledR(false);
 	if (m_itemMode)
 	{
 		m_item->itemText.deselectAll();
@@ -498,6 +504,7 @@
 			}
 			if (found)
 			{
+				setEnabledR(true);
 				m_item->itemText.select(a, sText.length());
 				m_item->HasSel = true;
 				if (rep)
@@ -529,6 +536,8 @@
 			m_item->update();
 			DoReplace->setEnabled(false);
 			AllReplace->setEnabled(false);
+			setEnabledR(false);
+			clearReplaceCheckbox();
 			ScMessageBox::information(this, tr("Search/Replace"), tr("Search finished"));
 			m_item->itemText.setCursorPosition(0);
 			m_notFound = false;
@@ -634,8 +643,9 @@
 		}
 		if (found)
 		{
+			setEnabledR(true);
 			// m_doc->scMW()->CurrStED->updateProps(); FIXME
-			if (rep)
+			if (rep )
 			{
 				DoReplace->setEnabled(true);
 				AllReplace->setEnabled(true);
@@ -661,6 +671,7 @@
 {
 //	if (m_itemMode)
 //		m_doc->view()->slotDoCurs(false);
+	DoReplace->setEnabled(isReplacecheck());
 	slotDoReplace();
 	if (m_itemMode)
 	{
@@ -671,7 +682,7 @@
 
 void SearchReplace::slotDoReplace()
 {
-	if (m_itemMode)
+	if (m_itemMode && STextVal->text() != "" && SText->isChecked())
 	{
 		QString repl, sear;
 		int cs, cx;
@@ -812,6 +823,7 @@
 
 void SearchReplace::slotReplaceAll()
 {
+	AllReplace->setEnabled(isReplacecheck());
 	if (m_itemMode)
 	{
 //		m_doc->view()->slotDoCurs(false);
@@ -834,61 +846,73 @@
 void SearchReplace::enableTxSearch()
 {
 	bool setter = SText->isChecked();
-	STextVal->setEnabled(setter);
+	STextVal->setEnabled(SText->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 	Word->setEnabled(setter);
 	CaseIgnore->setEnabled(setter);
 	if (setter)
 		STextVal->setFocus();
 }
-
 void SearchReplace::enableStyleSearch()
 {
 	SStyleVal->setEnabled(SStyleVal->count() ? SStyle->isChecked() : false);
+	DoSearch->setEnabled(isSeachCheck());
+
 }
 
 void SearchReplace::enableAlignSearch()
 {
 	SAlignVal->setEnabled(SAlign->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableFontSearch()
 {
 	SFontVal->setEnabled(SFont->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableSizeSearch()
 {
 	SSizeVal->setEnabled(SSize->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableEffSearch()
 {
 	SEffVal->setEnabled(SEffect->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableFillSearch()
 {
 	SFillVal->setEnabled(SFill->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableFillSSearch()
 {
 	SFillSVal->setEnabled(SFillS->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
-
 void SearchReplace::enableStrokeSearch()
 {
 	SStrokeVal->setEnabled(SStroke->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableStrokeSSearch()
 {
 	SStrokeSVal->setEnabled(SStrokeS->isChecked());
+	DoSearch->setEnabled(isSeachCheck());
 }
 
 void SearchReplace::enableTxReplace()
 {
 	RTextVal->setEnabled(RText->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 	if (RText->isChecked())
 		RTextVal->setFocus();
 }
@@ -896,46 +920,73 @@
 void SearchReplace::enableStyleReplace()
 {
 	RStyleVal->setEnabled(RStyle->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableAlignReplace()
 {
 	RAlignVal->setEnabled(RAlign->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableFontReplace()
 {
 	RFontVal->setEnabled(RFont->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableSizeReplace()
 {
 	RSizeVal->setEnabled(RSize->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableEffReplace()
 {
 	REffVal->setEnabled(REffect->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableFillReplace()
 {
 	RFillVal->setEnabled(RFill->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableFillSReplace()
 {
 	RFillSVal->setEnabled(RFillS->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableStrokeReplace()
 {
 	RStrokeVal->setEnabled(RStroke->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::enableStrokeSReplace()
 {
 	RStrokeSVal->setEnabled(RStrokeS->isChecked());
+	setEnabledR(isReplacecheck());
+	DoReplace->setEnabled(isReplacecheck());
+	AllReplace->setEnabled(isReplacecheck());
 }
 
 void SearchReplace::clear()
@@ -1030,7 +1081,7 @@
 	RFont->setChecked(m_prefs->getBool("RFont", false));
 	RStyle->setChecked(m_prefs->getBool("RStyle", false));
 	RAlign->setChecked(m_prefs->getBool("RAlign", false));
-	RText->setChecked(m_prefs->getBool("RText", true));
+	RText->setChecked(m_prefs->getBool("RText", false));
 	RTextVal->setText(m_prefs->get("RTextVal", ""));
 	tmp = m_prefs->getInt("RStyleVal", findParagraphStyle(m_doc, m_doc->currentStyle));
 	if (tmp < 0 || tmp >= RStyleVal->count())
@@ -1108,3 +1159,69 @@
 	m_prefs->set("CaseIgnore", CaseIgnore->isChecked());
 	accept();
 }
+
+bool SearchReplace::isSeachCheck()
+{
+	if ((SFill->isChecked()) || (SStroke->isChecked()) || (SStyle->isChecked()) || (SFont->isChecked())
+				|| (SStrokeS->isChecked()) || (SFillS->isChecked()) || (SSize->isChecked()) || (SText->isChecked())
+				|| (SEffect->isChecked()))
+		return true;
+	else
+		return false;
+}
+
+bool SearchReplace::isReplacecheck()
+{
+	if (((RFill->isChecked()) || (RStroke->isChecked()) || (RStyle->isChecked()) || (RFont->isChecked())
+			|| (RStrokeS->isChecked()) || (RFillS->isChecked()) || (RSize->isChecked()) || (RText->isChecked())
+			|| (REffect->isChecked())))
+			return true;
+		else
+			return false;
+}
+
+void SearchReplace::setEnabledR(bool stter)
+{
+	RStroke->setEnabled(stter);
+	REffect->setEnabled(stter);
+	RAlign->setEnabled(stter);
+	RStrokeS->setEnabled(stter);
+	RFill->setEnabled(stter);
+	RFillS->setEnabled(stter);
+	RSize->setEnabled(stter);
+	RFont->setEnabled(stter);
+	RStyle->setEnabled(stter);
+	RText->setEnabled(stter);
+}
+
+void SearchReplace::clearReplaceCheckbox()
+{
+	REffect->setChecked(false);
+	int currentParaStyle = findParagraphStyle(m_doc, m_doc->currentStyle);
+	RAlignVal->setCurrentIndex(m_doc->currentStyle.alignment());
+	RStroke->setChecked(false);
+	RStrokeS->setChecked(false);
+	RFill->setChecked(false);
+	RFillS->setChecked(false);
+	RSize->setChecked(false);
+	RFont->setChecked(false);
+	RStyle->setChecked(false);
+	RText->setChecked(false);
+	RTextVal->setText("");
+	RStyleVal->setCurrentIndex(currentParaStyle);
+	RAlignVal->setCurrentIndex(m_doc->currentStyle.alignment());
+	setCurrentComboItem(RFontVal, m_doc->currentStyle.charStyle().font().scName());
+	setCurrentComboItem(RFillVal, m_doc->currentStyle.charStyle().fillColor());
+	setCurrentComboItem(RStrokeVal, m_doc->currentStyle.charStyle().strokeColor());
+	RSizeVal->setValue(m_doc->currentStyle.charStyle().fontSize() / 10.0);
+	enableTxReplace();
+	enableStyleReplace();
+	enableFontReplace();
+	enableSizeReplace();
+	enableEffReplace();
+	enableFillReplace();
+	enableFillSReplace();
+	enableStrokeReplace();
+	enableStrokeSReplace();
+
+}
Index: scribus/ui/search.h
===================================================================
--- scribus/ui/search.h	(revision 20560)
+++ scribus/ui/search.h	(working copy)
@@ -142,7 +142,11 @@
 	/// Number of matches found thus far in a search
 	int matchesFound;
 	int m_firstMatchPosition;
-
+private:
+	bool isSeachCheck();
+	bool isReplacecheck();
+	void setEnabledR(bool);
+	void clearReplaceCheckbox();
 };
 
 #endif // SEARCHREPLACE_H
issue.patch (9,452 bytes)   

aliyousuf

2015-11-25 06:41

reporter   ~0037667

I worked on this issue,and I send the patch

Kunda

2015-11-27 14:24

updater   ~0037704

aliyousuf, for sure.
Jean committed the patch in r20574 with the following:
0013225: "Replace All" in Search/Replace dialog freezes Scribus in determined condition <aliyousuf+additional fix by scribus team> 

Kunda

2015-11-27 14:25

updater   ~0037705

Thanks to everyone who worked on this!
Closing

Issue History

Date Modified Username Field Change
2015-07-12 02:39 FirasH New Issue
2015-07-12 02:39 FirasH File Added: 13225-search.ui.zip
2015-07-14 01:30 Kunda Note Added: 0035772
2015-07-14 01:31 Kunda Assigned To => Kunda
2015-07-14 01:31 Kunda Status new => confirmed
2015-07-14 01:31 Kunda Assigned To Kunda =>
2015-07-14 14:22 jghali Note Added: 0035776
2015-07-14 15:08 FirasH Note Added: 0035777
2015-10-28 01:55 Kunda Note Edited: 0035772
2015-10-28 01:56 Kunda File Added: bt.txt
2015-10-28 02:10 Kunda Note Added: 0037012
2015-10-28 03:01 Kunda Note Added: 0037013
2015-10-28 03:03 Kunda File Added: search-replace-bug.m4v
2015-10-28 03:04 Kunda Target Version => 1.5.1
2015-10-30 20:57 JLuc Steps to Reproduce Updated
2015-10-30 20:57 JLuc Note Added: 0037126
2015-10-30 21:00 Kunda Steps to Reproduce Updated
2015-10-30 21:06 JLuc Steps to Reproduce Updated
2015-11-16 07:20 aliyousuf Note Added: 0037508
2015-11-16 08:34 aliyousuf Tag Attached: HOST-Oman
2015-11-17 05:04 aliyousuf Tag Detached: HOST-Oman
2015-11-17 07:28 aliyousuf Note Added: 0037523
2015-11-17 07:29 aliyousuf File Added: out.ogv
2015-11-17 07:30 aliyousuf Note Added: 0037524
2015-11-17 08:25 JLuc Note Added: 0037526
2015-11-17 11:42 Kunda Note Added: 0037530
2015-11-19 05:21 aliyousuf Note Added: 0037549
2015-11-19 05:22 aliyousuf Note Edited: 0037549
2015-11-19 05:22 aliyousuf Note Edited: 0037549
2015-11-19 05:23 aliyousuf Note Edited: 0037549
2015-11-19 05:26 aliyousuf Note Added: 0037550
2015-11-19 06:54 aliyousuf Tag Attached: HOST-Oman
2015-11-19 09:15 aliyousuf File Added: issue.patch
2015-11-19 09:23 aliyousuf Note Added: 0037551
2015-11-19 11:25 Kunda Note Added: 0037552
2015-11-19 11:25 Kunda Sticky Issue No => Yes
2015-11-20 00:48 Kunda Patch No => Yes
2015-11-21 19:53 JLuc Tag Attached: patch_tested_ok
2015-11-21 19:54 JLuc Note Added: 0037577
2015-11-22 00:09 jghali Note Added: 0037582
2015-11-22 05:41 aliyousuf Note Added: 0037586
2015-11-22 23:12 jghali Note Added: 0037594
2015-11-23 10:10 aliyousuf File Deleted: issue.patch
2015-11-23 10:10 aliyousuf File Added: issue.patch
2015-11-23 11:19 aliyousuf Tag Detached: HOST-Oman
2015-11-23 11:21 aliyousuf File Deleted: issue.patch
2015-11-23 11:47 JLuc Tag Detached: patch_tested_ok
2015-11-23 11:51 JLuc Tag Attached: HOST-Oman
2015-11-23 21:26 jghali File Added: 13225_replace_all_loop.patch
2015-11-23 21:28 jghali Note Added: 0037614
2015-11-23 23:09 jghali Note Added: 0037620
2015-11-23 23:09 jghali Status confirmed => resolved
2015-11-23 23:09 jghali Fixed in Version => 1.5.1svn
2015-11-23 23:09 jghali Resolution open => fixed
2015-11-23 23:09 jghali Assigned To => jghali
2015-11-24 00:19 Kunda Sticky Issue Yes => No
2015-11-24 05:22 aliyousuf File Added: issue.patch
2015-11-24 12:43 jghali Fixed in Version 1.5.1svn => 1.4.6.svn
2015-11-25 06:41 aliyousuf Note Added: 0037667
2015-11-27 14:24 Kunda Note Added: 0037704
2015-11-27 14:25 Kunda Note Added: 0037705
2015-11-27 14:25 Kunda Status resolved => closed
2015-12-02 09:46 JLuc Relationship added related to 0011818