Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win console #583

Merged
merged 9 commits into from
May 13, 2015
Merged

Win console #583

merged 9 commits into from
May 13, 2015

Conversation

daschuer
Copy link
Member

This Pull Request hopefully allows to build mixxx and mixxx-test with subsystem:Windows.
The console is created via custom code after main.

The build flag DEBUGCONSOLE was also removed since Mixxx for windows should now work almost similar as Linux.

Related Bug:
https://bugs.launchpad.net/mixxx/+bug/1453782

Since I cannot build on windows this PR is untested.

UINT oldCodePage;
bool shouldResetCodePage = false;
if (GetConsoleWindow() != NULL) {
if(AttachConsole(ATTACH_PARENT_PROCESS)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please pull all of this out into a helper function in util/console.h or similar to prevent duplication

@daschuer
Copy link
Member Author

Done! Looking forward to see if it builds.

// LOCALE_IDEFAULTANSICODEPAGE "1252" // ANSI Codepage used by Qt toLocal8Bit
// LOCALE_IDEFAULTCODEPAGE "850" // OEM Codepage Console

UINT m_oldCodePage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local shadows member variable

@daschuer
Copy link
Member Author

fixed

rryan added a commit that referenced this pull request May 13, 2015
@rryan rryan merged commit 999b7c8 into mixxxdj:1.12 May 13, 2015
@default-kramer
Copy link
Contributor

Hey I'm back, sorry for the delay. These changes look good, but for some reason I don't have console output anymore on Windows 7. The only way I can see stdout and stderr is to pipe to a file. All the Qt logging is visible in stderr, so I personally don't think this is a problem.

I don't see how this PR could have caused this change in behavior, but I don't know what else it could be. If I type "dist32\mixxx.exe" on the command prompt it behaves as if I had typed "start dist32\mixxx.exe". In other words, Mixxx seems disconnected from the console immediately, before the code even has a chance to run. Did something change with the build process or Qt configuration maybe?

@daschuer
Copy link
Member Author

These changes look good, but for some reason I don't have console output anymore on Windows 7

So It seams I have failed :-( I can confirm this on WinXp: No console when starting in cmd.exe.
Can you take care of it? According to what I have read it should work. So Maybe there is just a bug in the code?
Thank you.

@default-kramer
Copy link
Contributor

Ah, I see it now. This 304e5f6 change is most likely responsible. I will uncomment and try it.

@rryan
Copy link
Member

rryan commented May 13, 2015

@default-kramer -- indeed -- that was part of the plan. Remove subsystem:console from mixxx-test.exe and see if the console changes made recently cause the console to work.

@rryan
Copy link
Member

rryan commented May 13, 2015

The way the build is currently structured makes it hard to build mixxx.exe and mixxx-test.exe with different subsystem arguments. It's probably do-able though.

@rryan
Copy link
Member

rryan commented May 13, 2015

Also, mixxx-test output works on the build server despite subsystem:windows: http://builds.mixxx.org/jenkins/job/1.12-release/architecture=i386,platform=windows/34/console

@default-kramer
Copy link
Contributor

When I switch back to subsystem:console, the console reappears as expected. But it always appears, even when Mixxx is not launched from a console. I think there is a way to conditionally hide it, although it may still appear in the taskbar which would probably not be acceptable.

I don't think it is possible to use subsystem:windows and attach to the console that launched Mixxx. The console is not blocked, so I could be typing in another command. I don't think that Mixxx would be allowed to hijack a console that belongs to the user and start spewing output while the user is trying to enter another command.

So I think the choice is between:

  1. subsystem:console with conditionally hiding the console
  2. subsystem:windows with conditionally creating a new console

Would either or both of these be acceptable?

@daschuer
Copy link
Member Author

  1. Has the disadvantage that the console will be shown at least for a spit of a second. So 2.) should be our favorite choice.

@rryan: What if you start mixxx-test.exe inside cmd.exe? Do you see the output?

@default-kramer Dos this example show a console output fromcmd.exe when compiled as subsystem windows?
http://www.tillett.info/2013/05/13/how-to-create-a-windows-program-that-works-as-both-as-a-gui-and-console-application/

There is a problem anyway: we need to put the Console() call above the command line explanations to have them on the console. Maybe it fixes the problem at all?

@default-kramer
Copy link
Contributor

@daschuer I had the same thought and tried moving Console() to the very beginning of main() but it didn't work. However, the example you linked to does work! So I should be able to get it working now.

@daschuer
Copy link
Member Author

Cool! Thank you for taking care.

@daschuer daschuer deleted the win_console branch January 8, 2016 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants