Can I using debugger in IntelliJ check from where was called method (source call) ?
For example I have method public Object getSomething(int i) and I toggle breakpoint at this method. Debugger stoped and there is my question - Can I check from where was called this method ?
I am using OS X system on MacBook.
You can use Ctrl+Alt+F7 to jump to the callers of the method.
(⌘+⌥+F7 on MAC)
Edit: I think Ctrl+F7 (⌘+F7 or ⌥+F7) will be helpful, this will take you straight to the caller of the function.
Edit2: Alt+5 (⌘+5) pulls up the Debugger window where you can see all the previous calls made. There you can choose the caller of your method in question.
Related
I want to prevent users from closing a window by Alt + F4 or by clicking the close button.
How to achieve this?
I guess the windows API can do it, but I don't have any experience, and I can't find a specific solution.
Of course, it's good to be able to implement it,don't have to use a specific API.
Background: it is very difficult to find the last place in Word after closing it for a few days. After word2013, word2013 brought with it a way to return to the previous reading position, but that thing is very unstable and often can't be saved. When word is closed, I want to stop closing and pop up a notice to remind me to add a bookmark before exiting.
EDIT: This won't work, as it turned out. At least the message hook won't work because the message is posted and not sent, and about the CBT hook I'm not sure either, and I can't test it at the moment to give an evidence-based statement. The solution is probably to subclass the window but this is also non-trivial and I can't explain it properly and with working examples right now. I can't delete this answer though because it already has a comment. See here for more info. So take it with a grain of salt. I'm turning the answer to community wiki, feel free to edit it and fix/improve the solution!
EDIT2: Seems even subclassing won't be enough because Word is doing things its own way.
You need a windows hook. Either a CBT hook or a getmessage hook will do.
You have to create a DLL for this to work. The hook handler must be located in the DLL. It must have the same bitness as Word (probably 64 Bit). Then you call SetWindowsHookEx to install a global hook.
In the hook, you will have to check whether the current action is a window-closing attempt (in a CBT hook you would check for a HCBT_SYSCOMMAND of SC_CLOSE, in a getmessage hook you would check for a WM_CLOSE message), and whether it is about a Word window (for example using the window class - not sure if it has a recognizable class, you'd have to check - or the process' executable file name which you can get using GetModuleFileName since you will run inside Word's process) and prevent the action (by returning 1 from a CBT hook or returning 0 from a getmessage hook - to allow, call CallNextHookEx).
I am testing a user-defined override to BeforeSaveEntities on the Breeze Server Side. I have a breakpoint where I am observing the saveMap, and I call a method on the sub-class of the EFContextProvider to loop through each entity being saved.
Then when I click the Debug Stop button in Visual Studio, the Save still occurs. If I change the return from BeforeSaveEntities return from passing back the original saveMap to null, it does not.
This was a bit unsettling when I was going to "test" deleting...as I'm trying to write code that will do a "soft" delete.
Anyway, my question is, is there a workaround so I don't have to setup a "return null" during testing?
But more importantly, if I throw an EntityErrorsException it does stop the save as expected. :)
Thanks. Bob
This happens because you are just detaching the Visual Studio debugger from the running IIS/IIS Express instance. As soon as you detach the debugger, the request's execution continues on the webserver and thus, the rest of the code is executed.
A quick workaround would be to wrap your null return code in a compiler condition and check for the DEBUG symbol. Something along these lines:
#if DEBUG
return null;
#endif
Production code should be built using the RELEASE compiler symbol instead of the DEBUG symbol to enable deletion.
I wrote plugin for FireFox which offer method for choosing file. This method calls Win API function GetOpenFileName. When dialog "Open File" is shown and I do not switch to other window then all works ok. If I clicks browser window then all is blocked and after some time I see message that plugin has crashed. This problem is only in FireFox and is absent in Chrome and Safari. I think it is connected with fact that GetOpenFileName has own message loop.
Is there simple way to correct this behaviour?
e.g. function SHBrowseForFolder works fine in FireFox.
In FireFox sources I see class MessageLoop and methods SetNestableTasksAllowed() which probably can solve this problem (at least this conclusion can be done from explanation in header). But in xulrunner-sdk-13.0.1 there is no header with class MessageLoop although there is xul.lib with function GetIOMessageLoop. Probably it is possible to take headers from FireFox sources but I think it will not be easy to use them in my project in VS 2010
The main thing you need to understand here is that you must never block the main thread in an NPAPI plugin. The functions you're talking about are all blocking calls, so you must never use them on the main thread.
If you call them on a different thread your problem should go away; note that when you do this you'll probably want to have a callback function (javascript functions come in as a NPObject that you can call InvokeDefault on) and you can only call NPN_InvokeDefault on the main thread, so you'll have to device a way to do the callback on the main thread.
Sometimes when I press the "step into" button in the Xcode debugger, it instead steps over the method call.
This happens even though the method is a method I wrote, and the source code is in the same project.
Can anyone explain how to prevent this?
This may also happen when the method is being called on a nil object.
From Apple's developer docs:
A nil value is the safest way to initialize an object pointer if you don’t have another value to use, because it’s perfectly acceptable in Objective-C to send a message to nil. If you do send a message to nil, obviously nothing happens.
This is not necessarily so obvious if you've used pretty much any other language, because they largely don't include this "feature."
I have had issues with LLDB. Switching to GDB corrected this. Product->Edit Scheme->Run->Debugger.
You may need to Clean your targets in XCode. Under the Build menu try Cleaning All and see if that resolves your issue.
I cannot open a new window in QT. I new in QT so I think I am missing something. I only write the code below and settings windows just shows itself and closes. I have commented out destructor but still problem persists.
SettingsWindow s;
s.show();
What do I do wrong ? By the way I cannot either debug it, debuger does not stop when it reaches to the first line for example.
Thanks
This can't possibly be the only code you wrote.
However, judging from your description the first thing that comes to mind is probably a missing call to QApplication::exec(). Somewhere in the code you haven't shown here there's an instance of QApplication, probably named app. After calling show on your window, make sure there's a call to exec.
Since you are using a non-pointer var, your window is destroy when it go our of scope (at the end of the function). If you use a pointer when exiting the function the memory is not deleted so you Windows will still be shown. But you will not be able to clean memory when closing the window if you can't anymore access to your pointer.
Maybe you need to create your window as member of the calling class in order to be able to destroy the window AND clean memory once you don't need anymore to display it (for example in the calling class destructor).