Can you configure Qt Creator to kill the running application before building or running? - qt-creator

I'm developing a QApplication and I find that I often forget to close my application before rebuilding and re-running it. This becomes a problem when I accidentally look at an instance of my application built 10 minutes ago and expect to see code changes from 30 seconds ago.
It is also annoying because I have to move my hand all the way over to the mouse, move the mouse all the way over to the running application, and close it every time I want to rebuild and I am lazy and I don't want to do that.
Is it possible to configure Qt Creator to close my QApplication when I start building or running it again?

There is an option to do that in Qt Creator:
Open the Preferences => Build & Run => General
Change “Stop application before building” from “None” to “Same Project”

To whomever might stumble here later, an easier way to o this is to put a "killall" command (as suggested by tangbongbong) is the first build step under Projects(ctrl+5) -> Build and Run
In the screenshot below my executable name was "Tutano" and I added the -9 option to ensure it would be killed.
Screenshot
- sorry, I'm new here so can't post an image directly

Try to add the following Custom Process Step at the top of the Build Steps

I am on Windows so the killall does not work.
But I figured this out (enter the values in the same form that Julien has posted as a screenshot):
Command: taskkill
Arguments: /FI "STATUS eq Running" /IM APPNAME.exe /F
You need to replace APPNAME with your application's name, of course.
The /FI "STATUS eq Running" is a filter that enables qmake to proceed after this pre-build-step, even if the application is not yet running (else it would not find the process to kill and then exit). Without the /F the application won't get closed, at least for me.
However, if your application has a icon in the trayarea, the icon won't disappear. The icon gets removed when you move the mouse over it.

Yes.
One way is to create a very simple script that kills your existing running process and starts a new one. If your program executable is FooBarProgram then go to the build directory that Qt has created and create this file FooBarProgramLauncher
#!/bin/bash
killall FooBarProgram
./FooBarProgram
Now change the Qt project configuration to run your launcher instead running your program directly:
Open the project in Qt Creator
Select "Projects" from the pane on the left
Select the "Build & Run" tab if not already selected
Select the "Run" subtab
Under the "Run" heading, click the "Add" button, select "Custom Executable"
On the "Command" line, click the "Browse" button and select FooBarProgramLauncher
Now whenever you tell Qt to run your program it will run FooBarProgramLauncher instead which in turn will kill any running instances of FooBarProgram and then run the newly compiled executable.

Related

C:\windows\SysWow64\CScript.exe window pop up

I created a macro in Excel and i am running it from a .vbs file. It's working fine on my laptop. I copied the same work on a new laptop and each time i am running the vbs file this window appears on the screen.
I have made some research and read that the situation i mentioned is happening when loading CheckNDISPort service on the startup. But i don't believe it's the reason because when i go to task manager and check in the startUp tab i don't find this service. Also when i restart my laptop i don't get this window, only when i am running my vbs file. I am sure there is any problem with my vbs file too because on the other laptops it's working fine.
Any suggestion please how to get ride of this pop up ? For now i am closing the window each time or ending the task from task manager but everytime i run it again so it pops up again.
Thank you very much.
Windows Scripting Host has two interpreter front-ends, wscript.exe and cscript.exe. cscript.exe is a console application and if cscript.exe is set as the default a console window will open every time you execute a script.
Run cmd.exe elevated as administrator and run wscript.exe //h:wscript.
Depending on the Windows version, you might also be able to right-click a .vbs file, select "Open with...", choose %windir%\system32\wscript.exe and check the "default" checkbox.

Disable "The last time you opened *, it unexpectedly quit while reopening windows" dialog in OSX 10.8

I managed to successfully silence the CrashReport dialog, but when my application crashes and I restart it, I get the annoying dialog as from Title. Is there a way to prevent it to appear, and just let the application run without interruption?
Try this to get rid of the reopening windows:
defaults write -app "Application Name" NSQuitAlwaysKeepsWindows -bool false
You may also disable it for every application by selecting this option in the preferences: "Close windows when quitting an application"
And for others reading this thread, to remove the CrashReport do this:
defaults write com.apple.CrashReporter DialogType none
Also note that in the source of this information they say:
For this to work one needs to check the box, open the program in
question and immediately close it. On the next re-opening it will work
without Resume.
You may also have to delete:
/Users/…/Library/Saved\ Application\ State/org.python.python.savedState/
I was having a similar problem with google chrome and I could solve it by reading the following link:
https://support.google.com/chrome/thread/22716083?hl=en
Drew Z recommends the following solution there which worked for me:
In the Mac menu bar at the top of the screen, click Go.
Select Go to Folder.
Enter ~/Library/Application Support/Google/Chrome/ in the text field, then press Go.
Locate the folder called "Default" in the directory window that opens and rename it as "Backup default."
Try opening Google Chrome again. A new "Default" folder is automatically created as you start using the browser.
Voila! I've just solved this problem by deleting all Unity-related files inside ~Library/Caches folder on my Mac!
For those trying to accomplish this
defaults write -app "Application Name" NSQuitAlwaysKeepsWindows -bool false
with Python, you may get the error Couldn't find an application named "Python"; defaults unchanged.
To solve this, repeat the process to get the "reopen windows?" pop-up again, but do not choose an option in the pop-up – leave it alone for now. Right-click on the Python application's icon on the dock and choose "Show in Finder". Right-click on the application icon within Finder, hold the option key, and click Copy "Python" as pathname". Paste that in as the "Application Name" for the command above and it should work.
You can disable this for a specific Xcode scheme by going to Edit Scheme, choosing the Options tab, and checking the box labeled "Launch application without state restoration."
However, this will only apply when you actually launch the application from Xcode; it won't disable the dialog when launching by double-clicking in Finder, or when launching from the terminal.
(As best I can tell, there no way for AppKit/NSApplication-based apps to do what UIKit apps can do with UIApplicationDelegate's application:shouldRestoreApplicationState: and disable persistent state entirely for the application.)

Run exe silently in deployment

I'm trying to build a package and deploy it silently. I have the script ready executing an exe silently, however since the exe uninstalls a program, I still see the window "Configuring..." pop up. I am using
Set Shell = CreateObject("WScript.Shell")
Shell.Run("Uninstaller.exe 0,true)
This is working fine, as in it's running the uninstaller silently, however once the uninstaller starts doing its job, another window pops up saying "configuring application name". Is there a way to hide that?
It seems that the window you are seeing is part of the .EXE you're running.
Perhaps the "Uninstaller.exe" has a switch or parameter to make it run silently?
EDIT
If you can use a 3rd party tool, AutoIt provides an easy way to hide a window. Look at the WinSetState function.

Running Applescript: WorkFlowServiceRunner will not terminate

I am trying to make a keyboard shortcut to launch terminal in OS X Mountain Lion.
After some research I found out that I can use Automator to achieve this:
http://mac.tutsplus.com/tutorials/tips-shortcuts/how-to-launch-any-app-with-a-keyboard-shortcut/
It works, but I noticed that whenever I launch a terminal using this method, a process called WorkFlowServiceRunner starts and never terminates. To make matters worse when I launch more terminals (or launch different applications using shortcuts, again, through Automator) multiple WorkFlowServiceRunner processes start and quickly eat up the memory.
I've also tried writing my own applescripts but the problem does not go away. This clearly looks like a memory leak. Is this a bug in OS X Automator? Is there a way to write an applescript so that the WorkFlowServiceRunner terminates after doing its job (e.g. launch a terminal)? Automator seems to be the most "native" way of getting this done and I do not want to use any 3rd party apps.
I have noticed this from time to time.
One way around it would be to make your own service apps with a Cocoa-AppleScript Applet.
It is not very hard to do. And I will try and guide you through it. It should only take you a couple of minutes.
Step 1.
Open your Application Applescript Editor. And go to the "File" Menu -> "New from Template" -> Cocoa-AppleScript Applet.app
Step 2,
Paste this code into the new documents.
property NSWorkspace : class "NSWorkspace"
tell current application's NSApp to setServicesProvider_(me)
NSUpdateDynamicServices()
my runAService()
on runAService()
NSWorkspace's sharedWorkspace()'s launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_("com.apple.Terminal", current application's NSWorkspaceLaunchDefault, missing value, missing value)
tell me to quit
end runAService
Step 3,
Compile
(click this to compile)
and Save the app.
*Make sure the show startup screen is unchecked in the Save dialogue.
Giving the app a name like LaunchTerminal.app
Step 4,
Click the "Bundle Contents" button on the top right hand side of the document.
This will open the applications contents view.
Click the Action button and then "Reveal in finder" sub menu.
step 5,
In the contents folder that opens in the finder you will see a file name "info.plist"
Open Terminal.app and type and run this code using the path to this file:
BUT make sure you do not include the ".plist" part of the name when entering it in Terminal.app
/usr/bin/defaults write /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info NSServices -array-add '{NSMenuItem={default="Launch Terminal";}; NSMessage="runAService"; NSSendTypes=();}'
( You can drag n drop the file into terminal to get the posix path string )
The path part looks like this: /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info
This code should add an array to the plist file which is part of the apps way of broadcasting it has a service.
step 6,
Compile and Save the App again.
Just to make sure it picks up the changes. ( I found I had to do this even though I should not have to)
step 7,
Double click the app to run it for the first time.
The App will quit straight away. But the first run should have broadcast that it has a service that should be registered with the system
step 8,
Open system Preferences and go to Services -> General (section)
And you will see the "Launch Terminal" service.
Set up your short cut as normal.
Hope this helps..
UPDATE :
I noticed that the tell application "Terminal" to activate. Would not open my default Window groups if I had closed them all and quit Terminal before. The normal behaviour if I have done this is for my default window group to open. ( I have two Tabs open at startup each cd'd to a different path).
So I have change the open application to a cocoa way of doing it.
A do shell script with open the/application/path/. will work also.
Try using Butler or QuicKeys. They both have endless "Trial periods."

"Reload file?" error in codeblocks

I'm using codeblocks to as my IDE for C++ and every 10mins or so I get the following
error message:
"Reload File? File c:...node.cpp is modified outside the IDE. Do you want to reload
it? (you will lose andy unsaved work)" Yes/No/All/Cancel
If I click yes by mistake sometimes I lose the last couple of minutes of work. If I
click no then everything remains ok.
So I downloaded "Process Monitor" to find out what program was accessing my cpp file
and it tells me that SVCHost may be the culprit.
As far as I'm aware SVCHost is responsible for all sorts of things. Does anyone have any idea what I can do to stop receiving this error message?
N.B. This error message didn't appear for the first month or so that I used codeblocks,
but I have no idea what I've done that might have caused the problem.
[Screenshot][http://i44.tinypic.com/sgk3sx.jpg]
I came across the same problem and I resolved it by removing a tick in front of "check for externally modified files" in
Settings -> Environment -> General settings
You're right in that svchost is a generic process name that is used by a multitude of different services. I think the reason was to prevent a lot of processes for every tiny little service that might want to do something - a group of them will share a single svchost process.
Process Explorer from Sysinternals can be used to figure out what services are being performed by a specific svchost process by finding the process ID (1296 in your JPEG file) and double-clicking on the entry.
Then, in the properties dialog that appears, choose the services tab and it will show you the particular services using that process.
If you don't want to (or can't) install Process Explorer, you can use the command-line:
tasklist /svc /fi "imagename eg svchost.exe"
to get a list of all the services in each process.

Resources