Results 1 to 2 of 2

Thread: Problems with the implementation of the thread [disphelper, WMI, QThread]

  1. #1
    Join Date
    Jul 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problems with the implementation of the thread [disphelper, WMI, QThread]

    In thread run() function I'm using a disphelper functional.
    This function is implementing a request to WMI for monitor a system events:
    Code:
    Qt Code:
    1. try
    2. {
    3. const wchar_t * Query = (const wchar_t *) this-> TriggerRequest.utf16 ();
    4. dhCheck (dhGetObject (L "winmgmts: {impersonationLevel = impersonate, (Security)}! \ \ \ \. \ \ root \ \ cimv2", NULL, & wmiSvc));
    5. dhCheck (dhGetValue (L "% o", & wmiEventSrc, wmiSvc, L ". ExecNotificationQuery (% S)", Query));
    6. emit this-> TriggerState (this-> TriggerName, 1);
    7. while (TRUE)
    8. {
    9. CDispPtr wmiLatestEvent;
    10. dhCheck (dhGetValue (L "% o", & wmiLatestEvent, wmiEventSrc, L ". NextEvent"));
    11. emit this-> Triggered (this-> TriggerName, this-> GenerateTriggerMsg (wmiLatestEvent), this-> TriggerIcon);
    12. wmiLatestEvent.Dispose ();
    13. }
    14. }
    15. catch (string errstr)
    16. {
    17. ErrorMSG = this-> GenerateErrorMSG (QString:: fromStdString (errstr));
    18. emit this-> TriggerState (this-> TriggerName, -1);
    19. }
    To copy to clipboard, switch view to plain text mode 
    problem follows on line
    Code:
    Qt Code:
    1. dhCheck (dhGetObject (L "winmgmts: {impersonationLevel = impersonate, (Security)}! \ \ \ \. \ \ root \ \ cimv2", NULL, & wmiSvc));
    To copy to clipboard, switch view to plain text mode 
    fails with the message:
    Member:
    Function: GetObject
    Error In: GetObjectEx
    Error: Neioaene? Aneay ioeaea
    Code: 800401e4
    Source: Application "
    But before the program fails with the message Runtime error.
    And even earlier (and now) in another application, this code (in multiple threads) working perfectly.
    also, in class constructor such code works fine without any problems.
    Out of the run() function this code works;
    What's the problem?
    Environment variables, configuration files (*.pro) (except a list of files) are identical to the working and nonworking applications.
    Shl.
    Help pliz.
    3 days of debuging ....

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problems with the implementation of the thread [disphelper, WMI, QThread]

    The error message says that the offending code in the GetObejct() function.
    So probably a parameter or parameters you give to the function, or some other conditions are not valid.
    Maybe it has to do with the fact this is threaded, and you are corrupting data from another thread?
    Its impossible to know with out an in depth knowledge of your application.
    But it does not look like the problem has to do with Qt, rather with how your application works.

    And even earlier (and now) in another application, this code (in multiple threads) working perfectly.
    also, in class constructor such code works fine without any problems.
    Out of the run() function this code works;
    In and out of the run() method the thread affinity is very different for objects created with in the scope of the run() method.
    Read about QThread thread affinity.
    Probably this is causing your your problems - that is, you probably are using thread affinity not as you should.
    P.S
    Please is spelled S p l e a s e, and not pliz.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. How can I get the thread ID out of QThread
    By Artschi in forum Qt Programming
    Replies: 9
    Last Post: 8th November 2017, 03:27
  2. Replies: 5
    Last Post: 22nd February 2011, 21:21
  3. Replies: 10
    Last Post: 22nd July 2009, 23:52
  4. Replies: 4
    Last Post: 26th June 2008, 18:41
  5. Confusing in thread implementation
    By santosh.kumar in forum Qt Programming
    Replies: 0
    Last Post: 16th May 2007, 11:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.