google / UIforETW

User interface for recording and managing ETW traces
https://randomascii.wordpress.com/2015/04/14/uiforetw-windows-performance-made-easier/
Apache License 2.0
1.55k stars 201 forks source link

Fix poor detection of a dupe instance #148

Open eugenesvk opened 3 years ago

eugenesvk commented 3 years ago

Old FindWindow() function could mistake an Explorer folder 'UI for ETW' for another instance of 'UI for ETW' (since window title is identical) New custom function registers a unique window message that allows to uniquely identify another instance of 'UI for ETW' Bonus: restore the minimized window of 'UI for ETW'

Resolves: #147

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

randomascii commented 3 years ago

It looks basically good but I'll need the cla/google signed before I can accept the patch.

eugenesvk commented 3 years ago

@googlebot I signed it!

randomascii commented 3 years ago

I get four instances of this error when compiling:

1>C:\src\github\UIforETW\UIforETW\Settings.cpp(17,10): fatal error C1853: 'x64\Release\UIforETW_devrel.pch' precompiled header file is from a different version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)

I don't mind switching to C++17 but I don't think that global constructors are a great idea. How about:

int GetAreYouMeId() { static const UINT uwmAreYouMe = RegisterWindowMessage(L"678fd291e05741edb987c0a4f5650866"); return uwmAreYouMe; }

Then it gets constructed on first use instead of before WinMain

randomascii commented 3 years ago

The return type in my sample function should be UINT.

randomascii commented 1 year ago

I noticed this was still open and decided to see why. Part of the reason is that I pasted the wrong error message into my last comment. The actual error message is:

1>C:\src\github\UIforETW\UIforETW\UIforETW.h(46,19): error C7525: inline variables require at least '/std:c++17' (compiling source file Settings.cpp)

That message happens on this line:

inline const UINT uwmAreYouMe = RegisterWindowMessage(L"678fd291e05741edb987c0a4f5650866");

I continue to think that that isn't a great idea. Inline data is great. Global constructors that run before main are not.