Bug 321986 - New from Template: Can't create class without comments at the beginning of the file
Summary: New from Template: Can't create class without comments at the beginning of th...
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Application templates (show other bugs)
Version: 4.5.60
Platform: Other Linux
: NOR wishlist
Target Milestone: 4.6.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-05 10:29 UTC by Kevin Funk
Modified: 2013-11-11 19:35 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.6


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Funk 2013-07-05 10:29:54 UTC
See "Steps to Reproduce".

Reproducible: Always

Steps to Reproduce:
1. Select "New from Template" action
2. Select "QObject subclass"
3. ... (next, next)
4.  In the license page, it is NOT possible to select "None" or similar in the combo box
Actual Results:  
You always get a comment at the start of the content (both in .h and .cpp), e.g.:

/*
 *
 */

#ifndef SDSAD_H
#define SDSAD_H

#include <../../home/krf/devel/src/qt/src/corelib/kernel/qobject.h>

class sdsad : public QObject
{
    Q_OBJECT

private:
};

#endif // SDSAD_H

Expected Results:  
No comments, with the yet-to-created "None" selected in the combo box:

#ifndef SDSAD_H
#define SDSAD_H

#include <../../home/krf/devel/src/qt/src/corelib/kernel/qobject.h>

class sdsad : public QObject
{
    Q_OBJECT

private:
};

#endif // SDSAD_H
Comment 1 Kevin Funk 2013-07-05 10:30:20 UTC
Adding Milian as he worked on the file-template engine at some point.
Comment 2 Milian Wolff 2013-07-05 11:32:53 UTC
Yeah, I also noticed that. Someone with a bit of grantlee knowledge should simply add the appropriate check to kdevelop/file_templates/common/cpp_header.h to check that license is actually non-empty. If it is empty, it should just skip the license_header block. Probably just a matter of

{% if license %}
...
{% endif %}

Could you try that out with an "empty" license (i.e. create a custom, empty one)? Once we can verify that this works, we'll need to add a simple "None" item to the license checkbox.
Comment 3 Kevin Funk 2013-07-13 15:37:37 UTC
Git commit 2f558438544aa8c723de368497ad5b66c2b0eb96 by Kevin Funk.
Committed on 13/07/2013 at 14:26.
Pushed by kfunk into branch '4.5'.

cpp_header.h: Conditionally add license header

If no license text is given, don't add any comment at all.
I'm not adding "None" or similar to the combo box, because I think that
just clutters the box with another redundant item.

If you don't want a license, select "Other" and leave the text edit empty.

M  +2    -0    file_templates/common/cpp_header.h

http://commits.kde.org/kdevelop/2f558438544aa8c723de368497ad5b66c2b0eb96
Comment 4 Kevin Funk 2013-11-11 16:57:01 UTC
Git commit 94ae9e853badab1bb31049e9c03108b187c2ca6c by Kevin Funk.
Committed on 11/11/2013 at 16:31.
Pushed by kfunk into branch '4.6'.

Really fix all file templates

REVIEW: 113797
FIXED-IN: 4.6

M  +1    -0    file_templates/CMakeLists.txt
M  +1    -4    file_templates/classes/c_gobject/class.c
M  +1    -4    file_templates/classes/c_gobject/class.h
M  +1    -4    file_templates/classes/c_gobject_private/class.c
M  +1    -4    file_templates/classes/c_gobject_private/class.h
M  +1    -4    file_templates/classes/c_gobject_properties/class.c
M  +1    -4    file_templates/classes/c_gobject_properties/class.h
M  +1    -4    file_templates/classes/private_pointer/class.cpp
M  +1    -4    file_templates/classes/private_pointer/class_p.h
M  +4    -0    file_templates/classes/python_basic/class.py
M  +1    -8    file_templates/common/cpp_header.h
M  +1    -6    file_templates/common/cpp_header_onlyfunctions.h
M  +1    -6    file_templates/common/cpp_implementation.cpp
A  +9    -0    file_templates/common/license_header_cpp.txt
M  +1    -4    file_templates/testing/cpp_qtestlib/class.cpp
M  +1    -4    file_templates/testing/cpp_qtestlib/class.h
M  +1    -4    file_templates/testing/cpp_qtestlib_kde/class.cpp
M  +1    -4    file_templates/testing/cpp_qtestlib_kde/class.h
M  +1    -4    file_templates/testing/cpp_qtestlib_kdevelop/class.cpp
M  +1    -4    file_templates/testing/cpp_qtestlib_kdevelop/class.h
M  +4    -1    file_templates/testing/php_phpunit/class.php
M  +4    -0    file_templates/testing/python_pyunit/class.py

http://commits.kde.org/kdevelop/94ae9e853badab1bb31049e9c03108b187c2ca6c