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

Renaming C++ macros with "Ctrl-Shift-R" causes code corruption over all project in some cases.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • Qt Creator 2.6.0-beta, Qt Creator 2.6.0-rc
    • None
    • Windows 7 x86-32

    Description

      This bug's led me to very bad situation with my project.
      All source files, that used the specific macros, was corrupted,
      after renaming the macros. When i found it out it was too late,
      and was need to do much manual routine corrections in all project.

      It was hard to reproduce the bug but i finally succeed on some isolated dummy example below.

      For example we can create two files.

      macrotest.h:

      #define SOME_MACRO_NAME( X ) \
      { \
      X = 1; \
      }

      macrotest.cpp:

      #include "macrotest.h"

      class SomeClass
      {
      public:

      void function1(int a);

      SomeClass() {}
      };

      bool function1(int a) {
      SOME_MACRO_NAME(a)
      return a;
      }

      Now if we rename macros "SOME_MACRO_NAME" with "Ctrl+Shift+R" to some name - all is ok.
      But now let's add to our "macrotest.h" file any class definition like here, for example:

      class AnyClass
      {
      public:
      AnyClass() {}
      };

      #define SOME_MACRO_NAME( X ) \
      { \
      X = 1; \
      }

      Now we can save the file or not - this is not important.
      And then let's try to rename macros in "macrotest.cpp" with "Ctrl+Shift+R" by name "SOME_MACRO_NEW_NAME", for example.
      Then if we look to our previous "macrotest.h" file, we can see strange corrupted code that can look like here:

      class AnyClassSOME_MACRO_NEW_NAME
      #define SOME_MACRO_NAME( X ) \
      { \
      X = 1; \
      }

      Sometimes it worked ok without noising code in the sitution, but i was getting similar code-corruption behavior after simply deleting that "AnyClass" definition and then trying to rename macros in "macrotest.cpp" again. So reproducing and making appear the bug with sequence described above is not stable. Class definition "AnyClass" there should be added and deleted in some not understandable sequence. It needs to be experimented with to catch it.

      Bug also was met in some other cases but it needs be to experimented with it much for isolating exact examples of situations.

      I think it is very serios bug not only for me at all, because code corruptions can take no notice in time and "undo" actions will not help.

      Attachments

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

        Activity

          People

            erikv Erik Verbruggen
            avassen Vasily Shchukin
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes