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

Windows QPA: RegisterClassEx failed when mixing Qt versions with identical Qt namespaces

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P4: Low P4: Low
    • 5.15.1
    • 5.14.1, 5.14.2
    • QPA: Windows
    • None
    • Windows
    • 4857fee0fc6a9b277a779266d521d4dc1ca3bd95 (qt/qtbase/dev) 7efb907b5dc942ed610cbbcd3dacae5f1b2f4b37 (qt/qtbase/5.15)

      You need to create two different *.dll targets with the same Qt package (I have tested it with Qt 5.14.1 and Qt 5.14.2). Load Target_A and all is fine. Now load Target_B and you will end up in qErrnoWarning () in file "qwindowscontext.cpp" in method "QWindowsContext::registerWindowClass".
      ATOM atom = RegisterClassEx(&wc);

      The problem is that Target_B needs to register WNDCLASSEX which are already registered form Target_A. It has worked in previous version (Qt 5.13).

      Here is the problematic bug/source
      const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo) == TRUE && wcinfo.lpfnWndProc != proc;

      GetClassInfo () will return a BOOL. And the source is assuming it is fine with TRUE. But it is not. MSDN tells us
      "If the function finds a matching class and successfully copies the data, the return value is nonzero."
      In fact the result code is something like 4050. Which is nonzero. A BOOL is defined as an int. TRUE will not help here. The fix is 

      const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(cname.utf16()), &wcinfo) > 0 && wcinfo.lpfnWndProc != proc;

      "> 0" instead of "== TRUE"

      I hope that helps.

       

       

       

       

       

       

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

            kleint Friedemann Kleint
            michaspork Michael Spork
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes