Page MenuHome

thumbhandler2.patch

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

thumbhandler2.patch

Index: release/windows/installer/00.sconsblender.nsi
===================================================================
--- release/windows/installer/00.sconsblender.nsi (revision 34776)
+++ 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 34776)
+++ source/creator/creator.c (working copy)
@@ -471,15 +473,16 @@
return 0;
}
static int register_extension(int UNUSED(argc), 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;
}
@@ -1081,7 +1090,8 @@
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, "-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 34776)
+++ source/creator/CMakeLists.txt (working copy)
@@ -411,6 +422,19 @@
)
endif()
endif()
+
+ 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()
elseif(APPLE)
set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
Index: BLI_winstuff.h
===================================================================
--- BLI_winstuff.h (revision 34820)
+++ BLI_winstuff.h (working copy)
@@ -124,7 +124,7 @@
struct dirent direntry;
} DIR;
-void RegisterBlendExtension(char * str);
+void RegisterBlendExtension(void);
DIR *opendir (const char *path);
struct dirent *readdir(DIR *dp);
int closedir (DIR *dp);
Index: intern/winstuff.c
===================================================================
--- intern/winstuff.c (revision 34820)
+++ intern/winstuff.c (working copy)
@@ -38,6 +38,7 @@
#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"
@@ -59,39 +60,110 @@
return 1;
}
+void RegisterBlendExtension_Fail(HKEY root)
+{
+ if (root)
+ RegCloseKey(root);
+ if (!G.background)
+ MessageBox(0,"Could not register file extension.","Blender error",MB_OK|MB_ICONERROR);
+ printf("failure\n");
+ TerminateProcess(GetCurrentProcess(),1);
+}
-void RegisterBlendExtension(char * str) {
+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 = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &root, &dwd);
+ if (lresult != ERROR_SUCCESS)
+ {
+ // try HKCU on failure
+ usr_mode = TRUE;
+ lresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &root, &dwd);
+ 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);
+ 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);
+ }
+ printf("success (%s)\n",usr_mode ? "user" : "system");
+ TerminateProcess(GetCurrentProcess(),0);
}
DIR *opendir (const char *path) {
Index: SConstruct
===================================================================
--- SConstruct (revision 34776)
+++ SConstruct (working copy)
@@ -149,13 +149,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)
@@ -637,6 +637,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
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 34776)
+++ CMakeLists.txt (working copy)
@@ -393,6 +393,7 @@
if(CMAKE_CL_64)
message("64 bit compiler detected.")
set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
+ add_definitions(-DWIN64) # -DWIN32 needed too, as it's used all over to target Windows generally
endif()
add_definitions(-DWIN32)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
47/48/c26ee077e007d4f9c5f960566259

Event Timeline