Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81047

class static property wrong initiation in qt applications

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.12.4
    • None
    • Windows

    Description

       

      //代码占位符
      class FA{
      public:
          static QVector<FA*> allFA;
          static int Register(FA* p);
      };
      QVector<FA*> FA::allFA = QVector<FA*>();
      int FA::Register(FA* p){
          allFA.push_back(p);
          return 1;
      }class CA:public FA{
      public:
          static CA* pC;
          static int result;
          static CA* getInstance();
      };
      
      CA* CA::pC = nullptr;
      int CA::result = Register(getInstance());
      CA* CA::getInstance(){
          if (!pC)
              pC = new CA;
          return pC;
      }
      
      class CB:public FA{
      public:
          static CB* pC;
          static int result;
          static CB* getInstance();
      };
      
      CB* CB::pC = nullptr;
      int CB::result = Register(getInstance());
      CB* CB::getInstance(){
          if (!pC)
              pC = new CB;
          return pC;
      }
      

      If use vector in C++, there are two point in allFA.

      *But use *QVector in QT application, there is nothing in allFA.

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            peior peior wu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes