Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-23485

Add definition in *.cpp insert the new method into an existing one when using aggregate initialization in the latter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Not Evaluated Not Evaluated
    • None
    • Qt Creator 4.11.0
    • C/C++/Obj-C++ Support
    • None
    • Arch Linux
      Qt 5.14.0
    • Linux/X11

      Suppose you have a class in myclass.h

       

      class MyClass()
      {
      public:
          MyClass();
          void existing();
          void notExistingYet();
      };
      

      and the associated myclass.cpp is

       

      #include "myclass.h"
      
      struct blah {
       int a;
       int b;
       int c;
      };
      
      MyClass::MyClass() {}
      
      void MyClass::existing()
      {
          struct blah my_blah{
            1, 2, 3
          };
          do_something_with(my_blah);
      }
      

      and you decide to implement notExistingYet() hitting Refactor -> Add definition in *.cpp.

       

      Then myclass.cpp becomes:

      #include "myclass.h"
      
      struct blah {
         int a;
         int b;
         int c;
      };
      
      MyClass::MyClass() {}
      
      void MyClass::existing()
      {
          struct blah my_blah{
            1, 2, 3
          }
      
          void MyClass::notExistingYet()
          {
               
          };
          do_something_with(my_blah);
      }
      

      i.e. it misses the initialization opening brace and takes the initialization closing brace as the method ending brace, putting the new method inside the old one.

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kosjar Nikolai Kosjar
            astrinus Stefano Gronchi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes