Download it now!
Bug 46939 - : Crash after trying to rename autotext entry
Summary: : Crash after trying to rename autotext entry
Status: CLOSED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.4.4 release
Hardware: x86 (IA32) Linux (All)
: low critical
Assignee: Caolán McNamara
URL:
Whiteboard: BSA target:3.6.0
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-03 14:10 UTC by adam-art
Modified: 2012-03-08 06:10 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
No longer crashes when renaming AutoTexts. (1.15 KB, patch)
2012-03-06 19:17 UTC, Szabolcs Dézsi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adam-art 2012-03-03 14:10:18 UTC
Steps to reproduce:
1. Open Writer.
2. In any document write anything, eg. "test" and select it.
3. Choose form the menu: Edit> Autotext..
4. Enter a name, eg. "test" for a new autotext entry and a shortcut. You may leave the automatic shortcut which was generated ("t") as is.
5. Press Autotext button on the right and select "New (text only)". This is essential, because the crash won't happen if you choose "New" option.
6. A new autotext entry will show up in "My Autotext" category. Select it.
7. Press the Autotext button again and choose "Change name"
8. A new window will show up. In the two lower boxes write the name to which you want to change the name of the new entry. The crash will happen immediately after you hit "OK" if and only if the new shortcut will be identical (case insensitive) with the old one.

Ps.: I'm using polish locale, so i'm not sure about the exact menu item's names in english. I guess you'll figure it out.

Current behavior:
I was trying to change the name of autotext entry to other name but with the same shortcut. Writer immediately crashed with a message: "terminate called after throwing an instance of 'com::sun::star::container::ElementExistException'".

Expected behavior:
It should be allowed to change the name of an autotext entry w/o changing it's shortcut.

Platform (if different from the browser): 
              
Browser: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
Comment 1 Oliver Brinzing 2012-03-04 06:31:27 UTC
.
Comment 2 Björn Michaelsen 2012-03-06 00:31:56 UTC
Did this bug also happen with previous versions of LibreOffice?

Also: You state 3.4.4 as the affected version bug in launchpad 3.5.0-1ubuntu4/precise is reported.
Comment 3 adam-art 2012-03-06 02:39:13 UTC
Actually, when I reported this bug on Launchpad i meant Ubuntu 11.10. See:
https://bugs.launchpad.net/ubuntu/+source/libreoffice/+bug/945685/comments/0

Libreoffce version in 11.10 is 3.4.4 and is affected.

My description was replaced by the current one by penalvh. He states that it affects also 3.5.0-1ubuntu4.

Now I'm writing from my laptop with Ubuntu 11.04 installed where Libreoffice version is 3.3.4-0ubuntu1. It is also affected.
Comment 4 Szabolcs Dézsi 2012-03-06 19:17:20 UTC
Created attachment 58098 [details]
No longer crashes when renaming AutoTexts.

Hi!

So... after a long debugging session, I managed to trace the crash all the way from glossary.cxx through gloshdl.cxx->swblock.cxx->shellio.cxx->SwXMLTextBlocks.cxx to storage.cxx.

First of all, the crash only happens when I rename an AutoText but set the shortcut to something already existing.

storage.cxx:3282 here's where the exception throw happens. Although don't know why. Someone already was thinking about this very same question, hence the question marks in the comments at the end of the line :)
This thrown exception is caught a few lines later only to create a log entry, and to be rethrown. And this rethrown exception is not handled. -> that is our problem.

So I added a try catch block in the nearest place (not in xstorage.cxx because someone might want to catch that rethrown exception elsewhere).
And that nearest place is: SwXMLTextBlocks.cxx:218
xRoot->renameElement ( aOldStreamName, aNewStreamName );

It can be seen a few lines later, that xBlkRoot is handled the same way, catching a container::ElementExistException, but doing nothing in the catch block.

I tested it, it worked for me. At least I think it's working, if you spot any errors, just let me know.

Szabolcs
Comment 5 Not Assigned 2012-03-08 05:51:26 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=dbe20175fed8e82bec3578ae3af800dac7bc45f4

Resolves: fdo#46939 don't rename autotext when source and dest are the same
Comment 6 Caolán McNamara 2012-03-08 06:09:27 UTC
applied your patch, and moved the offending code inside "newname != oldname" conditional