r18419 by jghali - more Qt5 compatibility fixes for Windows build

scribus-commit scribus-commit at lists.scribus.net
Mon Aug 5 12:40:45 UTC 2013


Author: jghali
Date: Mon Aug  5 12:40:45 2013
New Revision: 18419

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18419
Log:
more Qt5 compatibility fixes for Windows build

Modified:
    trunk/Scribus/scribus/main_win32.cpp
    trunk/Scribus/scribus/scprintengine_gdi.cpp
    trunk/Scribus/scribus/ui/printdialog.cpp
    trunk/Scribus/scribus/util_printer.cpp

Modified: trunk/Scribus/scribus/main_win32.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18419&path=/trunk/Scribus/scribus/main_win32.cpp
==============================================================================
--- trunk/Scribus/scribus/main_win32.cpp (original)
+++ trunk/Scribus/scribus/main_win32.cpp Mon Aug  5 12:40:45 2013
@@ -62,7 +62,11 @@
 static void defaultCrashHandler(DWORD exceptionCode);
 
 // Console IO redirection handling
-void messageHandler( QtMsgType type, const char *msg );
+#ifdef USE_QT5
+void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
+#else
+void messageHandler(QtMsgType type, const char *msg);
+#endif
 bool consoleOptionEnabled(int argc, char* argv[]);
 void redirectIOToConsole(void);
 
@@ -86,7 +90,11 @@
 	if (consoleOptionEnabled(argc, argv))
 	{
 		redirectIOToConsole();
-		qInstallMsgHandler( messageHandler );
+#ifdef USE_QT5
+		qInstallMessageHandler(messageHandler);
+#else
+		qInstallMsgHandler(messageHandler);
+#endif
 	}
 #endif
 	ScribusQApp app(argc, argv);
@@ -296,11 +304,31 @@
 	ExitProcess(255);
 }
 
-void messageHandler( QtMsgType type, const char *msg )
-{
-	cerr << msg << endl;
-	if( type == QtFatalMsg )
-	{
+#ifdef USE_QT5
+void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+	QByteArray localMsg = msg.toLocal8Bit();
+	switch (type)
+	{
+	case QtDebugMsg:
+		cerr << "Debug: " << localMsg.constData()
+			 << "(" << context.file << ":" << context.line << ", "
+			 << context.function << ")"
+			 << endl;
+		break;
+	case QtWarningMsg:
+		cerr << "Warning: " << localMsg.constData()
+			 << "(" << context.file << ":" << context.line << ", "
+			 << context.function << ")"
+			 << endl;
+		break;
+	case QtCriticalMsg:
+		cerr << "Critical: " << localMsg.constData()
+			 << "(" << context.file << ":" << context.line << ", "
+			 << context.function << ")"
+			 << endl;
+		break;
+	case QtFatalMsg:
 		if (ScribusQApp::useGUI)
 		{
 			ScCore->closeSplash();
@@ -313,14 +341,33 @@
 		ExitProcess(255);
 	}
 }
+#else
+void messageHandler( QtMsgType type, const char *msg )
+{
+	cerr << msg << endl;
+	if (type == QtFatalMsg)
+	{
+		if (ScribusQApp::useGUI)
+		{
+			ScCore->closeSplash();
+			QString expHdr = QObject::tr("Scribus Crash");
+			QString expMsg = msg;
+			QMessageBox::critical(ScMW, expHdr, expMsg, QObject::tr("&OK"));
+			ScMW->emergencySave();
+			ScMW->close();
+		}
+		ExitProcess(255);
+	}
+}
+#endif
 
 bool consoleOptionEnabled(int argc, char* argv[])
 {
 	bool value = false;
-	for( int i = 0; i < argc; i++ )
-	{
-		if( strcmp(argv[i], ARG_CONSOLE) == 0 ||
-			strcmp(argv[i], ARG_CONSOLE_SHORT) == 0 )
+	for (int i = 0; i < argc; i++)
+	{
+		if (strcmp(argv[i], ARG_CONSOLE) == 0 ||
+			strcmp(argv[i], ARG_CONSOLE_SHORT) == 0)
 		{
 			value = true;
 			break;

Modified: trunk/Scribus/scribus/scprintengine_gdi.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18419&path=/trunk/Scribus/scribus/scprintengine_gdi.cpp
==============================================================================
--- trunk/Scribus/scribus/scprintengine_gdi.cpp (original)
+++ trunk/Scribus/scribus/scprintengine_gdi.cpp Mon Aug  5 12:40:45 2013
@@ -638,7 +638,7 @@
 	devMode->dmFields = devFlags;
 
 	OpenPrinterW( (LPWSTR) printer.utf16(), &handle, NULL );
-	DocumentPropertiesW( doc->scMW()->winId(), handle, (LPWSTR) printer.utf16(), devMode, devMode, DM_IN_BUFFER | DM_OUT_BUFFER);
+	DocumentPropertiesW( (HWND) doc->scMW()->winId(), handle, (LPWSTR) printer.utf16(), devMode, devMode, DM_IN_BUFFER | DM_OUT_BUFFER);
 	ClosePrinter( handle );
 }
 

Modified: trunk/Scribus/scribus/ui/printdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18419&path=/trunk/Scribus/scribus/ui/printdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/printdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/printdialog.cpp Mon Aug  5 12:40:45 2013
@@ -189,7 +189,7 @@
 	if(!done)
 		return;
 	// Merge stored settings, prompt user and return user settings
-	DocumentPropertiesW( winId(), handle, (LPWSTR) printerS.utf16(), (DEVMODEW*) DevMode.data(), (DEVMODEW*) DevMode.data(), 
+	DocumentPropertiesW((HWND) winId(), handle, (LPWSTR) printerS.utf16(), (DEVMODEW*) DevMode.data(), (DEVMODEW*) DevMode.data(), 
 						DM_IN_BUFFER | DM_IN_PROMPT | DM_OUT_BUFFER);
 	// Free the printer handle
 	ClosePrinter( handle );

Modified: trunk/Scribus/scribus/util_printer.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18419&path=/trunk/Scribus/scribus/util_printer.cpp
==============================================================================
--- trunk/Scribus/scribus/util_printer.cpp (original)
+++ trunk/Scribus/scribus/util_printer.cpp Mon Aug  5 12:40:45 2013
@@ -90,11 +90,11 @@
 	if(!done)
 		return false;
 	// Get size of DEVMODE structure (public + private data)
-	size = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
+	size = DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
 	// Allocate the memory needed by the DEVMODE structure
 	devModeA.resize( size );
 	// Retrieve printer default settings
-	result = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), NULL, DM_OUT_BUFFER);
+	result = DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), NULL, DM_OUT_BUFFER);
 	// Free the printer handle
 	ClosePrinter( handle );
 	return ( result == IDOK );
@@ -113,18 +113,18 @@
 	if(!done)
 		return false;
 	// Get size of DEVMODE structure (public + private data)
-	size = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
+	size = DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
 	// Compare size with DevMode structure size
 	if( devModeA.size() == size )
 	{
 		// Merge printer settings
-		result = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), (DEVMODEW*) devModeA.data(), DM_IN_BUFFER | DM_OUT_BUFFER);
+		result = DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), (DEVMODEW*) devModeA.data(), DM_IN_BUFFER | DM_OUT_BUFFER);
 	}
 	else
 	{
 		// Retrieve default settings
 		devModeA.resize( size );
-		result = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), NULL, DM_OUT_BUFFER);
+		result = DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), NULL, DM_OUT_BUFFER);
 	}
 	done = ( result == IDOK);
 	// Free the printer handle
@@ -186,10 +186,10 @@
 			if( OpenPrinterW( (LPWSTR) printerName.utf16(), &handle, NULL ) )
 			{
 				// Retrieve DEVMODE structure for selected device
-				uint size = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
+				uint size = DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
 				QByteArray devModeW(size, 0);
 				DEVMODEW* devMode = (DEVMODEW*) devModeW.data();
-				DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), devMode, NULL, DM_OUT_BUFFER);
+				DocumentPropertiesW((HWND) ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), devMode, NULL, DM_OUT_BUFFER);
 				ClosePrinter( handle );
 				// Set paper size
 				devMode->dmPaperSize = papers[paperIndex];




More information about the scribus-commit mailing list