Page MenuHome

winstuff_thumbhandler4.patch

Authored By
Tom Edwards (artfunkel)
Nov 13 2013, 2:56 PM
Size
17 KB
Subscribers
None

winstuff_thumbhandler4.patch

Index: release/windows/installer/00.sconsblender.nsi
===================================================================
--- release/windows/installer/00.sconsblender.nsi (revision 35829)
+++ release/windows/installer/00.sconsblender.nsi (working copy)
@@ -69,7 +69,7 @@
;Data
Caption "Blender [VERSION] Installer"
-OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe"
+OutFile "[DISTDIR]\..\Blender [VERSION]-windows[BITNESS].exe"
;InstallDir "$PROGRAMFILES[BITNESS]\Blender Foundation\Blender"
; Install to user profile dir. While it is non-standard, it allows
; users to install without having to have the installer run in elevated mode.
@@ -142,7 +142,7 @@
${EndIf}
FunctionEnd
-Section "Blender-[VERSION] (required)" SecCopyUI
+Section "Blender [VERSION] (required)" SecCopyUI
SectionIn RO
; Set output path to the installation directory.
@@ -178,21 +178,13 @@
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0
SectionEnd
-Section "Add Desktop Blender-[VERSION] shortcut" Section3
+Section "Add Blender [VERSION] to the desktop" Section3
CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0
SectionEnd
-Section "Open .blend files with Blender-[VERSION]" Section4
+Section "Open .blend files with Blender [VERSION]" Section4
- ${If} ${RunningX64}
- SetRegView 64
- ${EndIf}
- WriteRegStr HKCR ".blend" "" "blendfile"
- WriteRegStr HKCR "blendfile" "" "Blender .blend File"
- WriteRegStr HKCR "blendfile\shell" "" "open"
- WriteRegStr HKCR "blendfile\DefaultIcon" "" $INSTDIR\blender.exe,1
- WriteRegStr HKCR "blendfile\shell\open\command" "" \
- '"$INSTDIR\blender.exe" "%1"'
+ ExecShell "open" '"$INSTDIR\blender.exe" -r' SW_HIDE
SectionEnd
Index: source/creator/creator.c
===================================================================
--- source/creator/creator.c (revision 35829)
+++ source/creator/creator.c (working copy)
@@ -247,6 +247,7 @@
BLI_argsPrintArgDoc(ba, "--window-border");
BLI_argsPrintArgDoc(ba, "--window-borderless");
BLI_argsPrintArgDoc(ba, "--window-geometry");
+ BLI_argsPrintArgDoc(ba, "--start-console");
printf("\n");
printf ("Game Engine Specific Options:\n");
@@ -287,6 +288,7 @@
#ifdef WIN32
BLI_argsPrintArgDoc(ba, "-R");
+ BLI_argsPrintArgDoc(ba, "-r");
#endif
BLI_argsPrintArgDoc(ba, "--version");
@@ -483,15 +485,22 @@
return 0;
}
+extern int wm_start_with_console; // blender/windowmanager/intern/wm_init_exit.c
+static int start_with_console(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
+{
+ wm_start_with_console = 1;
+ return 0;
+}
+
static int register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data)
{
#ifdef WIN32
- char *path = BLI_argsArgv(data)[0];
- RegisterBlendExtension(path);
+ if (data)
+ G.background = 1;
+ RegisterBlendExtension();
#else
(void)data; /* unused */
#endif
-
return 0;
}
@@ -1094,7 +1103,9 @@
BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL);
BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL);
BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL);
- BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension (windows only)", register_extension, ba);
+ BLI_argsAdd(ba, 2, "-con", "--start-console", "\n\tStart with the console window open (ignored if -b is set)", start_with_console, NULL);
+ BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL);
+ BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba);
/* third pass: disabling things and forcing settings */
BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle);
Index: source/creator/CMakeLists.txt
===================================================================
--- source/creator/CMakeLists.txt (revision 35829)
+++ source/creator/CMakeLists.txt (working copy)
@@ -101,6 +101,17 @@
)
if(WIN32 AND NOT UNIX)
+ string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
+ string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
+ string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
+ add_definitions(
+ -DBLEN_VER_RC_STR="${BLENDER_VERSION}"
+ -DBLEN_VER_RC_1=${bver1}
+ -DBLEN_VER_RC_2=${bver2}
+ -DBLEN_VER_RC_3=${bver3}
+ -DBLEN_VER_RC_4=0
+ )
+
list(APPEND SRC
../icons/winblender.rc
)
@@ -541,6 +552,19 @@
set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)
set(TARGETDIR_VER ${TARGETDIR}/blender.app/Contents/MacOS/${BLENDER_VERSION})
+
+ add_custom_command(TARGET blender
+ POST_BUILD
+ MAIN_DEPENDENCY blender
+ COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb64.dll\" \"${TARGETDIR}\\\"
+ )
+ if(NOT CMAKE_CL_64)
+ add_custom_command(TARGET blender
+ POST_BUILD
+ MAIN_DEPENDENCY blender
+ COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb.dll\" \"${TARGETDIR}\\\"
+ )
+ endif()
# setup Info.plist
execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BLENDER_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
Index: source/blender/windowmanager/intern/wm_init_exit.c
===================================================================
--- source/blender/windowmanager/intern/wm_init_exit.c (revision 35829)
+++ source/blender/windowmanager/intern/wm_init_exit.c (working copy)
@@ -114,20 +114,26 @@
BKE_reports_clear(CTX_wm_reports(C));
}
+int wm_start_with_console = 0;
+#ifdef WIN32
+int IsConsoleEmpty(void);
+#endif
-
/* only called once, for startup */
void WM_init(bContext *C, int argc, const char **argv)
{
+ if (!G.background) {
- if (!G.background) {
wm_ghost_init(C); /* note: it assigns C to ghost! */
- wm_init_cursor_data();
+ wm_init_cursor_data();
+#ifdef WIN32
+ if (IsConsoleEmpty()) // never hide if the console window pre-existed
+ WM_toggle_console(C, wm_start_with_console);
+#endif
}
GHOST_CreateSystemPaths();
wm_operatortype_init();
-
set_free_windowmanager_cb(wm_close_and_free); /* library.c */
set_blender_test_break_cb(wm_window_testbreak); /* blender.c */
DAG_editors_update_cb(ED_render_id_flush_update); /* depsgraph.c */
@@ -352,6 +358,8 @@
sound_exit();
+ WM_toggle_console(C, 1); // never leave behind invisible consoles
+
/* first wrap up running stuff, we assume only the active WM is running */
/* modal handlers are on window level freed, others too? */
/* note; same code copied in wm_files.c */
Index: source/blender/blenlib/BLI_winstuff.h
===================================================================
--- source/blender/blenlib/BLI_winstuff.h (revision 35829)
+++ source/blender/blenlib/BLI_winstuff.h (working copy)
@@ -127,7 +127,8 @@
struct dirent direntry;
} DIR;
-void RegisterBlendExtension(char * str);
+int IsConsoleEmpty(void);
+void RegisterBlendExtension(void);
DIR *opendir (const char *path);
struct dirent *readdir(DIR *dp);
int closedir (DIR *dp);
Index: source/blender/blenlib/intern/winstuff.c
===================================================================
--- source/blender/blenlib/intern/winstuff.c (revision 35829)
+++ source/blender/blenlib/intern/winstuff.c (working copy)
@@ -37,12 +37,14 @@
#include <stdlib.h>
#include <stdio.h>
+#include <conio.h>
#include "MEM_guardedalloc.h"
#include "BLI_path_util.h"
#include "BLI_string.h"
#include "BKE_utildefines.h"
+#include "BKE_global.h"
#define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY
#include "BLI_winstuff.h"
@@ -64,39 +66,116 @@
return 1;
}
+int IsConsoleEmpty(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO csbi = {0};
+ HANDLE hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
-void RegisterBlendExtension(char * str) {
+ return GetConsoleScreenBufferInfo(hStdOutput, &csbi) && csbi.dwCursorPosition.X == 0 && csbi.dwCursorPosition.Y == 0;
+}
+
+void RegisterBlendExtension_Fail(HKEY root)
+{
+ printf("failed\n");
+ if (root)
+ RegCloseKey(root);
+ if (!G.background)
+ MessageBox(0,"Could not register file extension.","Blender error",MB_OK|MB_ICONERROR);
+ TerminateProcess(GetCurrentProcess(),1);
+}
+
+void RegisterBlendExtension(void) {
LONG lresult;
HKEY hkey = 0;
+ HKEY root = 0;
+ BOOL usr_mode = FALSE;
DWORD dwd = 0;
- char buffer[128];
-
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ char buffer[256];
+ char BlPath[MAX_PATH];
+ char InstallDir[FILE_MAXDIR];
+ char SysDir[FILE_MAXDIR];
+ char* ThumbHandlerDLL;
+ char RegCmd[MAX_PATH*2];
+ char MBox[256];
+ BOOL IsWOW64;
+
+ printf("Registering file extension...");
+ GetModuleFileName(0,BlPath,MAX_PATH);
+
+ // root is HKLM by default
+ lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
+ if (lresult != ERROR_SUCCESS)
+ {
+ // try HKCU on failure
+ usr_mode = TRUE;
+ lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(0);
+ }
+
+ lresult = RegCreateKeyEx(root, "blendfile", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
- sprintf(buffer, "\"%s\" \"%%1\"", str);
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ sprintf(buffer,"%s","Blender File");
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\DefaultIcon", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ lresult = RegCreateKeyEx(root, "blendfile\\shell\\open\\command", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ if (lresult == ERROR_SUCCESS) {
+ sprintf(buffer, "\"%s\" \"%%1\"", BlPath);
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
+ RegCloseKey(hkey);
+ }
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
+ lresult = RegCreateKeyEx(root, "blendfile\\DefaultIcon", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
- sprintf(buffer, "\"%s\",1", str);
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ sprintf(buffer, "\"%s\",1", BlPath);
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".blend", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
-
+ lresult = RegCreateKeyEx(root, ".blend", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
sprintf(buffer, "%s", "blendfile");
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
+
+ BLI_getInstallationDir(InstallDir);
+ GetSystemDirectory(SysDir,FILE_MAXDIR);
+#ifdef WIN64
+ ThumbHandlerDLL = "BlendThumb64.dll";
+#else
+ IsWow64Process(GetCurrentProcess(),&IsWOW64);
+ if (IsWOW64 == TRUE)
+ ThumbHandlerDLL = "BlendThumb64.dll";
+ else
+ ThumbHandlerDLL = "BlendThumb.dll";
+#endif
+ snprintf(RegCmd,MAX_PATH*2,"%s\\regsvr32 /s \"%s\\%s\"",SysDir,InstallDir,ThumbHandlerDLL);
+ system(RegCmd);
+
+ RegCloseKey(root);
+ printf("success (%s)\n",usr_mode ? "user" : "system");
+ if (!G.background)
+ {
+ sprintf(MBox,"File extension registered for %s.",usr_mode ? "the current user. To register for all users, run as an administrator" : "all users");
+ MessageBox(0,MBox,"Blender",MB_OK|MB_ICONINFORMATION);
+ }
+ TerminateProcess(GetCurrentProcess(),0);
}
DIR *opendir (const char *path) {
Index: source/icons/blender.exe.manifest
===================================================================
--- source/icons/blender.exe.manifest (revision 0)
+++ source/icons/blender.exe.manifest (revision 0)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+ <security>
+ <requestedPrivileges>
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
\ No newline at end of file
Index: source/icons/winblender.rcscons
===================================================================
--- source/icons/winblender.rcscons (revision 35829)
+++ source/icons/winblender.rcscons (working copy)
@@ -1,2 +0,0 @@
-APPICON ICON "source\\icons\\winblender.ico"
-BLENDERFILE ICON "source\\icons\\winblenderfile.ico"
Index: source/icons/SConscript
===================================================================
--- source/icons/SConscript (revision 35829)
+++ source/icons/SConscript (working copy)
@@ -1,9 +1,12 @@
#!/usr/bin/python
Import ('env')
+import btools
-if env['OURPLATFORM'] == 'linuxcross':
- source = 'linuxcrossblender.rcscons'
-else:
- source = 'winblender.rcscons'
+env['RCFLAGS'].append("-DWINDRES")
+env['RCFLAGS'].append("-DBLEN_VER_RC_STR_M=" + btools.VERSION)
+env['RCFLAGS'].append("-DBLEN_VER_RC_1=" + btools.VERSION[0])
+env['RCFLAGS'].append("-DBLEN_VER_RC_2=" + btools.VERSION[2])
+env['RCFLAGS'].append("-DBLEN_VER_RC_3=" + btools.VERSION[3])
+env['RCFLAGS'].append("-DBLEN_VER_RC_4=0")
-env.BlenderRes('winresource', source, ['core'], priority=[95])
+env.BlenderRes('winresource', 'winblender.rc', ['core'], priority=[95])
Index: source/icons/winblender.rc
===================================================================
--- source/icons/winblender.rc (revision 35829)
+++ source/icons/winblender.rc (working copy)
@@ -1,2 +1,40 @@
-APPICON ICON "winblender.ico"
-BLENDERFILE ICON "winblenderfile.ico"
+#define BLENDERFILE 1
+#define IDR_VERSION1 1
+
+#ifdef WINDRES
+ #include "winresrc.h"
+ #define IDC_STATIC (-1)
+ #define STRINGIFY_(x) #x
+ #define STRINGIFY(x) STRINGIFY_(x)
+ #define BLEN_VER_RC_STR STRINGIFY(BLEN_VER_RC_STR_M)
+ 1 RT_MANIFEST "blender.exe.manifest"
+#endif
+
+APPICON ICON DISCARDABLE "winblender.ico"
+BLENDERFILE ICON DISCARDABLE "winblenderfile.ico"
+
+IDR_VERSION1 VERSIONINFO
+FILEVERSION BLEN_VER_RC_1, BLEN_VER_RC_2, BLEN_VER_RC_3, BLEN_VER_RC_4
+PRODUCTVERSION BLEN_VER_RC_1, BLEN_VER_RC_2, BLEN_VER_RC_3, BLEN_VER_RC_4
+FILEOS 0x00000004
+FILETYPE 0x00000001
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "04090000"
+ BEGIN
+ VALUE "FileVersion", BLEN_VER_RC_STR
+ VALUE "ProductVersion", BLEN_VER_RC_STR
+ VALUE "CompanyName", "Blender Foundation"
+ VALUE "FileDescription", "Blender"
+ VALUE "LegalCopyright", "GPLv2 (Blender Foundation)"
+ VALUE "OriginalFilename", "blender.exe"
+ VALUE "ProductName", "Blender"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0409, 0x0000
+ END
+END
+
Index: source/icons/linuxcrossblender.rcscons
===================================================================
--- source/icons/linuxcrossblender.rcscons (revision 35829)
+++ source/icons/linuxcrossblender.rcscons (working copy)
@@ -1,2 +0,0 @@
-APPICON ICON "source/icons/winblender.ico"
-BLENDERFILE ICON "source/icons/winblenderfile.ico"
Index: SConstruct
===================================================================
--- SConstruct (revision 35829)
+++ SConstruct (working copy)
@@ -153,13 +153,13 @@
if cxx:
env['CXX'] = cxx
-if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32':
- if bitness == 64:
- platform = 'win64-vc'
- else:
- platform = 'win32-vc'
-elif env['CC'] in ['gcc'] and sys.platform=='win32':
- platform = 'win32-mingw'
+if sys.platform=='win32':
+ if bitness==64:
+ env.Append(CFLAGS=['-DWIN64']) # -DWIN32 needed too, as it's used all over to target Windows generally
+ if env['CC'] in ['cl', 'cl.exe']:
+ platform = 'win64-vc' if bitness == 64 else 'win32-vc'
+ elif env['CC'] in ['gcc']:
+ platform = 'win32-mingw'
env.SConscriptChdir(0)
@@ -641,6 +641,14 @@
'${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
'${BF_FFMPEG_LIBPATH}/avutil-50.dll',
'${BF_FFMPEG_LIBPATH}/swscale-0.dll']
+
+ # Since the thumb handler is loaded by Explorer, architecture is
+ # strict: the x86 build fails on x64 Windows. We need to ship
+ # both builds in x86 packages.
+ if bitness == 32:
+ dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
+ dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
+
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
allinstall += windlls

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
09/46/00faaf3b9a9bd9256695860c8b81

Event Timeline