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

解决崩溃问题,并把代码改成ARC #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added AppIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions DUImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ - (BOOL) performDragOperation: (id < NSDraggingInfo >) sender
NSPasteboard *pboard = [sender draggingPasteboard];
BOOL successful = NO;

if ([[pboard types] containsObject: NSPasteboardTypeFileURL])
{
NSArray *files = [pboard propertyListForType: NSPasteboardTypeFileURL];
[controller startConversion: [files objectAtIndex: 0]];
if (pboard.pasteboardItems.count <= 1) {
//直接获取文件路径

NSString *fileURL = [[NSURL URLFromPasteboard:pboard] path];
[controller startConversion:fileURL];
successful = NO;
}



return successful;
}

Expand Down
20 changes: 12 additions & 8 deletions DUWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,29 @@ - (NSDragOperation) draggingEntered: (id < NSDraggingInfo >) sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
NSDragOperation opType = NSDragOperationNone;

if ([[pboard types] containsObject: NSPasteboardTypeFileURL])
opType = NSDragOperationCopy;

return opType;
}

- (BOOL) performDragOperation: (id < NSDraggingInfo >) sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
BOOL successful = NO;

if ([[pboard types] containsObject: NSPasteboardTypeFileURL])
{
NSArray *files = [pboard propertyListForType: NSPasteboardTypeFileURL];
[controller startConversion: [files objectAtIndex: 0]];

// 判断是否拖进单文件

if (pboard.pasteboardItems.count <= 1) {
//直接获取文件路径

NSString *fileURL = [[NSURL URLFromPasteboard:pboard] path];
[controller startConversion:fileURL];
successful = NO;
}



return successful;
}

Expand Down
34 changes: 14 additions & 20 deletions DictUnifier.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
07048BBB13DDF11D00BD86F9 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 07048BBA13DDF11D00BD86F9 /* libz.dylib */; };
07048BBD13DDF12400BD86F9 /* Python.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07048BBC13DDF12400BD86F9 /* Python.framework */; };
071DC178114CA6420062577C /* lua.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 071DC176114CA6420062577C /* lua.cpp */; };
075208FD1B799D2700CD10AD /* libglib-2.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 075208FC1B799D2700CD10AD /* libglib-2.0.a */; };
07687D941143E9C30032F3CD /* DictUnifier.icns in Resources */ = {isa = PBXBuildFile; fileRef = 07687D931143E9C30032F3CD /* DictUnifier.icns */; };
07687DB91143EF690032F3CD /* done.png in Resources */ = {isa = PBXBuildFile; fileRef = 07687DB71143EF690032F3CD /* done.png */; };
Expand Down Expand Up @@ -42,13 +39,14 @@
07D57A2711475FF30033F5A4 /* convert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D57A1A11475FF30033F5A4 /* convert.cpp */; };
07D57A2811475FF30033F5A4 /* dict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D57A1C11475FF30033F5A4 /* dict.cpp */; };
07D57A2911475FF30033F5A4 /* index.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D57A1E11475FF30033F5A4 /* index.cpp */; };
07D57A2B11475FF30033F5A4 /* python.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D57A2211475FF30033F5A4 /* python.cpp */; };
07D57A2C11475FF30033F5A4 /* sdconv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D57A2411475FF30033F5A4 /* sdconv.cpp */; };
07D57A2D11475FF30033F5A4 /* storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D57A2511475FF30033F5A4 /* storage.cpp */; };
07D57A7F114761780033F5A4 /* sdconv in CopyFiles */ = {isa = PBXBuildFile; fileRef = 07D579C411475D930033F5A4 /* sdconv */; };
07D86040114811A2006EA8A6 /* DictUnifierAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 07D8603F114811A2006EA8A6 /* DictUnifierAppDelegate.m */; };
07D860471148128D006EA8A6 /* DUWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 07D860461148128D006EA8A6 /* DUWindow.m */; };
07D86066114812F0006EA8A6 /* DUImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 07D86065114812F0006EA8A6 /* DUImageView.m */; };
3A07337326E9E12F007E0174 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A07337226E9E12F007E0174 /* libz.tbd */; };
3A91E82528B9BEA10067F474 /* AppIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 3A91E82428B9BEA10067F474 /* AppIcon.png */; };
77C8C1F90C07829500965286 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77C8C1F70C07829500965286 /* MainMenu.xib */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
Expand Down Expand Up @@ -128,11 +126,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
07048BBA13DDF11D00BD86F9 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = ../../../../../usr/lib/libz.dylib; sourceTree = "<group>"; };
07048BBC13DDF12400BD86F9 /* Python.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Python.framework; path = ../../../../../System/Library/Frameworks/Python.framework; sourceTree = "<group>"; };
071D72BB215BFB68005B3C8B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
071DC176114CA6420062577C /* lua.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua.cpp; sourceTree = "<group>"; };
071DC177114CA6420062577C /* lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua.h; sourceTree = "<group>"; };
075208FC1B799D2700CD10AD /* libglib-2.0.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libglib-2.0.a"; path = "../../../usr/local/Cellar/glib/2.44.1/lib/libglib-2.0.a"; sourceTree = "<group>"; };
07687D931143E9C30032F3CD /* DictUnifier.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = DictUnifier.icns; sourceTree = "<group>"; };
07687DB71143EF690032F3CD /* done.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = done.png; sourceTree = "<group>"; };
Expand Down Expand Up @@ -170,8 +164,6 @@
07D57A1E11475FF30033F5A4 /* index.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = index.cpp; sourceTree = "<group>"; };
07D57A1F11475FF30033F5A4 /* index.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = index.h; sourceTree = "<group>"; };
07D57A2111475FF30033F5A4 /* mdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mdk.h; sourceTree = "<group>"; };
07D57A2211475FF30033F5A4 /* python.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = python.cpp; sourceTree = "<group>"; };
07D57A2311475FF30033F5A4 /* python.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = python.h; sourceTree = "<group>"; };
07D57A2411475FF30033F5A4 /* sdconv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sdconv.cpp; sourceTree = "<group>"; };
07D57A2511475FF30033F5A4 /* storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = storage.cpp; sourceTree = "<group>"; };
07D57A2611475FF30033F5A4 /* storage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = storage.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -246,6 +238,8 @@
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32CA4F630368D1EE00C91783 /* DictUnifier_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DictUnifier_Prefix.pch; sourceTree = "<group>"; };
3A07337226E9E12F007E0174 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; };
3A91E82428B9BEA10067F474 /* AppIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = AppIcon.png; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* DictUnifier.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DictUnifier.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand All @@ -255,9 +249,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3A07337326E9E12F007E0174 /* libz.tbd in Frameworks */,
075208FD1B799D2700CD10AD /* libglib-2.0.a in Frameworks */,
07048BBD13DDF12400BD86F9 /* Python.framework in Frameworks */,
07048BBB13DDF11D00BD86F9 /* libz.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -312,8 +305,6 @@
07D57A1911475FF30033F5A4 /* sdconv */ = {
isa = PBXGroup;
children = (
071DC176114CA6420062577C /* lua.cpp */,
071DC177114CA6420062577C /* lua.h */,
07D57A2E114760350033F5A4 /* include */,
07D57A1A11475FF30033F5A4 /* convert.cpp */,
07D57A1B11475FF30033F5A4 /* convert.h */,
Expand All @@ -322,8 +313,6 @@
07D57A1E11475FF30033F5A4 /* index.cpp */,
07D57A1F11475FF30033F5A4 /* index.h */,
07D57A2111475FF30033F5A4 /* mdk.h */,
07D57A2211475FF30033F5A4 /* python.cpp */,
07D57A2311475FF30033F5A4 /* python.h */,
07D57A2411475FF30033F5A4 /* sdconv.cpp */,
07D57A2511475FF30033F5A4 /* storage.cpp */,
07D57A2611475FF30033F5A4 /* storage.h */,
Expand Down Expand Up @@ -447,8 +436,6 @@
29B97314FDCFA39411CA2CEA /* DictUnifier */ = {
isa = PBXGroup;
children = (
07048BBC13DDF12400BD86F9 /* Python.framework */,
07048BBA13DDF11D00BD86F9 /* libz.dylib */,
07D57A1911475FF30033F5A4 /* sdconv */,
07D5799111475C5E0033F5A4 /* bin */,
07D5795E11475B760033F5A4 /* templates */,
Expand All @@ -473,6 +460,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
3A91E82428B9BEA10067F474 /* AppIcon.png */,
076D37D6114A37FC00D55901 /* Localizable.strings */,
07687DB71143EF690032F3CD /* done.png */,
07687DB81143EF690032F3CD /* dropper.png */,
Expand All @@ -487,6 +475,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
3A07337226E9E12F007E0174 /* libz.tbd */,
075208FC1B799D2700CD10AD /* libglib-2.0.a */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
Expand Down Expand Up @@ -579,6 +568,7 @@
07687DB91143EF690032F3CD /* done.png in Resources */,
07687DBA1143EF690032F3CD /* dropper.png in Resources */,
076D37D7114A37FC00D55901 /* Localizable.strings in Resources */,
3A91E82528B9BEA10067F474 /* AppIcon.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -608,10 +598,8 @@
07D57A2711475FF30033F5A4 /* convert.cpp in Sources */,
07D57A2811475FF30033F5A4 /* dict.cpp in Sources */,
07D57A2911475FF30033F5A4 /* index.cpp in Sources */,
07D57A2B11475FF30033F5A4 /* python.cpp in Sources */,
07D57A2C11475FF30033F5A4 /* sdconv.cpp in Sources */,
07D57A2D11475FF30033F5A4 /* storage.cpp in Sources */,
071DC178114CA6420062577C /* lua.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -683,6 +671,7 @@
"$(inherited)",
/usr/local/lib,
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
OTHER_LDFLAGS = "";
PRODUCT_NAME = sdconv;
SDKROOT = "";
Expand All @@ -706,6 +695,7 @@
"$(inherited)",
/usr/local/lib,
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
OTHER_LDFLAGS = "";
PRODUCT_NAME = sdconv;
SDKROOT = "";
Expand All @@ -716,6 +706,7 @@
C01FCF4B08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
Expand All @@ -732,6 +723,7 @@
"$(inherited)",
"\"$(SRCROOT)\"",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = "org.jjgod.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = DictUnifier;
SDKROOT = "";
Expand All @@ -744,6 +736,7 @@
C01FCF4C08A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3;
Expand All @@ -758,6 +751,7 @@
"$(inherited)",
"\"$(SRCROOT)\"",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
PRODUCT_BUNDLE_IDENTIFIER = "org.jjgod.${PRODUCT_NAME:identifier}";
PRODUCT_NAME = DictUnifier;
SDKROOT = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Loading