Results 1 to 15 of 15

Thread: COM Objects on Windows 7 with 4.7.2

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    schnitzel,

    I downloaded and installed VB express. Tried it on the DYMO .NET VB example included in the SDK. After it converted the project it compiled it and ran just fine. I was able to open the label, fill in the data fields and it printed my labels including the barcode. So I guess the COM objects are registered and working OK.

    I still can't think of a good reason I have to take the COM object instantiation out of the constructor. This project has a Main Form where I call each job from the menu by creating another form where I do the work and print my labels. Something in Qt must need to be done in the constructor before I can create these two COM objects.

    I hate it when I don't know what is going on...

    Keith

    high_flyer,

    I may be wrong, but I thought COM objects were reference counted and didn't need to be manually deleted. At least that is the way they always worked in Delphi and C#. When the last variable went out of scope that referenced the COM object the object was automatically deleted.

    Is that not true for Qt?

    Keith

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    10
    Thanked 37 Times in 36 Posts

    Default Re: COM Objects on Windows 7 with 4.7.2

    Do they provide a C++ example? If so, are they also allocating the objects using new in the constructor?
    Last edited by schnitzel; 16th March 2011 at 23:31. Reason: updated contents

  3. #3
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    schnitzel,

    They have a Visual C++ example but they use CreateDispatch().

    I took my inspiration for my code from the Qt dumpcpp documentation I found here.

    I have tried lots of things and read lots and I think my usage is correct, it just won't work in the constructor of the form...

    Keith

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

    Default Re: COM Objects on Windows 7 with 4.7.2

    I may be wrong, but I thought COM objects were reference counted and didn't need to be manually deleted. At least that is the way they always worked in Delphi and C#. When the last variable went out of scope that referenced the COM object the object was automatically deleted.

    Is that not true for Qt?
    It has nothing to do with Qt.
    Regarding the reference count on COM objects, I think it depends on what kind of pointer container they are held.
    CComXXX<T> pointer does ref counts, but a plain pointer does not.
    I can't see the declaration of the pointer variable so I don't know for your case.

    You should run you application through a leak detection tool, which can also detect COM leakages to be sure.
    I'd recommend that you ask that on a COM oriented forum, where the people know these issues in more detail.
    ==========================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.

  5. #5
    Join Date
    Mar 2009
    Location
    Ada, OH, USA
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: COM Objects on Windows 7 with 4.7.2

    high_flier, can you recommend a good "leak detection tool" that works on Windows 7?

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

    Default Re: COM Objects on Windows 7 with 4.7.2

    You need more the just a leak detection tool, you need one that can also detect COM leaks (which (can be)/is trickier).
    For "regular" leak detection you can use the CRT leak detection tool:
    http://msdn.microsoft.com/en-us/libr...=vs.71%29.aspx
    In my company we use our own brewed leak detection (which basically intercepts ALL (external as well) allocations/frees before the kernel) since we didn't find anything that could handle our large code base.
    Again, you should ask that on forums that specialize with COM.
    ==========================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. QSharedMemory and C++ objects
    By MattPhillips in forum Qt Programming
    Replies: 7
    Last Post: 29th November 2010, 07:42
  2. Replies: 3
    Last Post: 9th January 2010, 15:47
  3. Replies: 7
    Last Post: 18th July 2006, 21:33
  4. How to Use Objects
    By raphaelf in forum Newbie
    Replies: 1
    Last Post: 2nd June 2006, 09:59
  5. Objects and members
    By mickey in forum General Programming
    Replies: 8
    Last Post: 1st February 2006, 00:13

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
  •  
Qt is a trademark of The Qt Company.