wxSingleInstanceChecker message

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

wxSingleInstanceChecker message

Post by Ksawery » Mon Sep 09, 2019 1:21 pm

Hello,

I'm using wxSingleInstanceChecker to ensure that only one instance of my application is running. It works fine, however sometimes I see a message stating "Deleted stale lock file 'home/.../AppName' ". I know that this message only appears when the app is terminated indirectly (e.g. by killing the process in the terminal, or in the IDE debugger). I understand that it doesn't affect the execution of the app, and is useful for debugging purposes, however it won't be understandable to the end-user. Is there a way to suppress this message, or avoid it altogether?

Screenshot from 2019-09-09 15-11-58.png
Screenshot from 2019-09-09 15-11-58.png (9.51 KiB) Viewed 188 times

Regards,
Ksawery

User avatar
doublemax
Moderator
Moderator
Posts: 13989
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxSingleInstanceChecker message

Post by doublemax » Mon Sep 09, 2019 2:49 pm

I'm not sure if it works here, but try wrapping the creation of the wxSingleInstanceChecker instance with wxLogNull:
https://docs.wxwidgets.org/trunk/classwx_log_null.html
Use the source, Luke!

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: wxSingleInstanceChecker message

Post by Ksawery » Tue Sep 10, 2019 8:44 am

Thank you, it worked! I used the following code:

Code: Select all

{
wxLogNull logNo;
wxChecker = new wxSingleInstanceChecker(_T("PomiarWiazki"));
}
Two more things - i'm seeing the following message in the console:

Code: Select all

Gtk-Message: 10:43:55.126: GtkDialog mapped without a transient parent. This is discouraged.
Is this something to be concerned about? This message also pops up in the terminal, and might be confusing to the end-user. It only occurs when attempting to start the application, when one session is already running.

Secondly, can I change the title of an error window? For example, the following window:

Screenshot from 2019-09-10 10-45-52.png
Screenshot from 2019-09-10 10-45-52.png (6.24 KiB) Viewed 146 times

Thank you very much for your help!
Ksawery

User avatar
doublemax
Moderator
Moderator
Posts: 13989
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxSingleInstanceChecker message

Post by doublemax » Tue Sep 10, 2019 9:00 am

Secondly, can I change the title of an error window? For example, the following window:
Is this an internal error message from wxWidgets or is it something you open in your code? If you use wxMessageBox, there is an additonal parameter for the caption.

If it's an internal error message, it probably uses the application name set by wxApp::SetAppName()
Use the source, Luke!

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: wxSingleInstanceChecker message

Post by Ksawery » Tue Sep 10, 2019 9:04 am

I'm using wxLogError() to display the message, after checking if another instance is already running:

Code: Select all

if (wxChecker->IsAnotherRunning())
{
    wxLogError(_T("\nProces już istnieje!"));
    delete wxChecker; // OnExit() won't be called if we return false
    wxChecker = NULL;
    return false;
}

Ksawery
Knows some wx things
Knows some wx things
Posts: 47
Joined: Thu Jul 25, 2019 12:31 pm

Re: wxSingleInstanceChecker message

Post by Ksawery » Tue Sep 10, 2019 9:26 am

Using wxApp::SetAppName() helped set the title of the error window, thanks.

How about the GTK message, is there a way to suppress it or avoid it? It only pops up when displaying the error window.

Edit: I tried using wxMessageBox instead of wxLogError, and i'm still seeing the gtk message.

Regards,
Ksawery

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2252
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: wxSingleInstanceChecker message

Post by evstevemd » Tue Sep 10, 2019 12:32 pm

Ksawery wrote:
Tue Sep 10, 2019 9:26 am
Using wxApp::SetAppName() helped set the title of the error window, thanks.

How about the GTK message, is there a way to suppress it or avoid it? It only pops up when displaying the error window.

Edit: I tried using wxMessageBox instead of wxLogError, and i'm still seeing the gtk message.

Regards,
Ksawery
Is it debug or release mode?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

Post Reply