Bug 312105

Summary: File template wizard tries to generate files in '/'
Product: [Developer tools] kdevplatform Reporter: Andreas Pakulat <apaku>
Component: templatesAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: grave CC: lbeltrame
Priority: HI    
Version: git master   
Target Milestone: 1.3.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description Andreas Pakulat 2012-12-23 09:39:27 UTC
Right after starting up KDevelop there is no selection in the Projects toolview, starting the file-template-wizard in this situation lets one end up with a filename of '/foo.h' and '/foo.cpp' for header and cpp file. This means that KDevelop tries to generate the new file in the filesystem root which obviously won't work.

Even worse, there's no error message the new files are just not opened or created.

I'm not sure what the best default place is to generate the files, but it should be something where the user can write. Maybe use the location of the currently open file if the project selection is empty.

Reproducible: Always

Steps to Reproduce:
1. Start kdevelop
2. Select File->New from template
3. Choose Qt Object, select next
4. Fill in a name, select next
5. Keep selecting next until the last page is shown
Actual Results:  
File to be created is suggested to put into '/'

Expected Results:  
Wizard selects a writable directory to generate the new file.
Comment 1 Andreas Pakulat 2012-12-23 09:44:43 UTC
Just noticed that the project-selection seems to be unrelated to this, so I even hit this when a project is selected. Its unclear when this happens at the moment, the second try was successful with a file inside my project directory. The header is open, the project selected but the third try to generate a file again ended up in '/'. Hence raising severity
Comment 2 Kevin Funk 2012-12-23 10:24:13 UTC
*** Bug 311766 has been marked as a duplicate of this bug. ***
Comment 3 Andreas Pakulat 2013-01-03 12:58:48 UTC
This also affects the generated files when manually fixing the location. The generated implementation then has the complete path to the header except for the leading '/'.
Comment 4 Andreas Pakulat 2013-01-03 13:24:30 UTC
Seems this only happens when creating files in the project root, all is fine with creating files in a subdirectory. Also applies to cmake manager
Comment 5 Milian Wolff 2013-01-03 14:08:40 UTC
Git commit b712a65700bb10d151660512b1400e9d97571347 by Milian Wolff.
Committed on 03/01/2013 at 14:46.
Pushed by mwolff into branch 'master'.

Invalidate outputpage if a target directory is not writable.

M  +3    -0    plugins/filetemplates/outputpage.cpp

http://commits.kde.org/kdevplatform/b712a65700bb10d151660512b1400e9d97571347
Comment 6 Milian Wolff 2013-01-03 14:08:40 UTC
Git commit 775db4291c552a824e4d5e2dd1ec3b4ba7459e4c by Milian Wolff.
Committed on 03/01/2013 at 15:07.
Pushed by mwolff into branch 'master'.

Show a proper error message when a target file is invalid.

M  +28   -17   plugins/filetemplates/outputpage.cpp
M  +0    -2    plugins/filetemplates/outputpage.h
M  +11   -0    plugins/filetemplates/ui/outputlocation.ui

http://commits.kde.org/kdevplatform/775db4291c552a824e4d5e2dd1ec3b4ba7459e4c
Comment 7 Milian Wolff 2013-01-03 14:08:40 UTC
Git commit dcaa1060a651005a395e19f9ac592832a950f956 by Milian Wolff.
Committed on 03/01/2013 at 15:06.
Pushed by mwolff into branch 'master'.

Use the active document's parent folder for new templates as fallback.

Especially for the 'File -> New From Template' menu action this is
required and often just what one wants.

M  +7    -0    plugins/filetemplates/filetemplatesplugin.cpp

http://commits.kde.org/kdevplatform/dcaa1060a651005a395e19f9ac592832a950f956
Comment 8 Milian Wolff 2013-01-03 14:09:23 UTC
Andreas, I cannot reproduce the error by using the context menu entry on a project root item. Or did I misunderstand you? Please close this report if it's fixed now.

Thanks!
Comment 9 Andreas Pakulat 2013-01-03 14:17:40 UTC
Indeed, the context menu works fine. One really has to make sure to do the same steps all the time...