Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
Qt Creator 4.12.2
-
None
Description
Summary
The class method refactor tool "Add definition..." doesn't include class name in the definition if the previous method uses a function-try-block. For years I've been bothered by this bug in the QT creator refactoring tools, not being able to pinpoint the cause, and not investigating because it's a minor thing, and I just manually type it every time. And today I found the cause.
Example
Given the following header and source file:
class Foo { public: void method1(); }
#include "Foo.h"
Using the refactor tools on getValue, I'm provided with the option to "Add definition in Foo.cpp". The result:
#include "Foo.h"
void Foo::method1()
{
}
All is well. Declaring a new method, the header becomes:
class Foo { public: void method1(); void method2(); }
Using the refactor tools again on method2, the cpp becomes:
#include "Foo.h"
void Foo::method1()
{
}
void Foo::method2()
{
}
All is still well. Adding a function-try-block to method2, the cpp becomes:
#include "Foo.h" void Foo::method1() { } void Foo::method2() try { } catch (const std::exception& ex) { }
Declaring one more method, the header becomes:
class Foo { public: void method1(); void method2(); void method3(); }
Using the refactor tools again on method3, the cpp shows the problem:
#include "Foo.h" void Foo::method1() { } void Foo::method2() try { } catch (const std::exception& ex) { } void method3() { }
Note the missing class scope on the definition of method3.