Windows: wxDDEServerObject.empty()... warning message

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
leamas
Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri Nov 22, 2019 5:54 pm

Windows: wxDDEServerObject.empty()... warning message

Post by leamas »

Dear forum,

We have a (too) large application opencpn. While otherwise seemingly working as normal, I get warning message below when exiting program. Windows is not familiar to me. I have no idea what this actually could mean.
Image
Anyone here who has?
User avatar
doublemax
Moderator
Moderator
Posts: 18704
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Windows: wxDDEServerObject.empty()... warning message

Post by doublemax »

Technically this message just means there is an instance of wxDDEServer still existing when the application is terminated.

I suspect this code part, I don't see any code where "m_server" is destroyed.
https://github.com/OpenCPN/OpenCPN/blob ... .cpp#L1072

This should also create a memory leak.
Use the source, Luke!
leamas
Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri Nov 22, 2019 5:54 pm

Re: Windows: wxDDEServerObject.empty()... warning message

Post by leamas »

So many thanks! Definitely owe you a beer when we meet!
leamas
Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri Nov 22, 2019 5:54 pm

Re: Windows: wxDDEServerObject.empty()... warning message

Post by leamas »

hm... Some delay here, sorry. Anyway: this is actually about a pending PR and in this a singleton setup:

Code: Select all

static InstanceCheck& GetWxInstanceChk() {
  static WxInstanceCheck wx_check;
  return wx_check;
}
The WxInstanceCheck carries a plain wxSingleInstanceChecker, not a pointer:

Code: Select all

/**  Thin wrapper for wxSingleInstanceChecker implementing InstanceCheck */
class WxInstanceCheck : public InstanceCheck {
public:
  WxInstanceCheck();

  bool IsMainInstance() override { return !m_checker.IsAnotherRunning(); }

  void CleanUp() override;

private:
  wxSingleInstanceChecker m_checker;
};
This is C++11, so the static variable destructor will eventually be invoked when the program terminates. But as I understand it, the wxWidgets checks runs before that. Which then would mean we have a disturbing error message which not is really true (?)

If so, is there some way to get around this without reverting to non-RAII raw pointers?
User avatar
doublemax
Moderator
Moderator
Posts: 18704
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Windows: wxDDEServerObject.empty()... warning message

Post by doublemax »

Just rewrite WxInstanceCheck to use a wxSingleInstanceChecker* pointer internally, and explicitly call CleanUp() before the app terminates. The rest of the code should be unaffected.
Use the source, Luke!
leamas
Earned a small fee
Earned a small fee
Posts: 19
Joined: Fri Nov 22, 2019 5:54 pm

Re: Windows: wxDDEServerObject.empty()... warning message

Post by leamas »

Embarrassed. Really. I somehow missed your reply here, assumed it was missing and have done other things for too long time.

So many thanks for just not the general answer but some specifics after actually reading my code. BBL.
Post Reply