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

解决打开文件时可能造成的野指针问题 #27

Merged
merged 33 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
837cd65
增加macOS支持cmake编译
DaChengTechnology Jan 13, 2022
ac1aa98
Merge branch 'main' of https://github.com/scarsty/node-editor into sc…
DaChengTechnology Jan 13, 2022
94bea9b
修复Cannot create __weak reference
DaChengTechnology Jan 13, 2022
d5d78ec
a
DaChengTechnology Jan 13, 2022
dc72952
Merge branch 'main' into main
DaChengTechnology Jan 13, 2022
5a317e1
add MRC
DaChengTechnology Jan 13, 2022
820082c
Merge branch 'main' of https://github.com/scarsty/node-editor into sc…
DaChengTechnology Jan 13, 2022
3b02201
fix yaml
DaChengTechnology Jan 13, 2022
09ffe10
可以生成app 但是 会报空指针
DaChengTechnology Jan 19, 2022
da7a303
Merge remote-tracking branch 'upstream/main'
DaChengTechnology Jan 19, 2022
fde185d
macOS 运行成功
DaChengTechnology Jan 20, 2022
56fbbf8
改名
DaChengTechnology Jan 20, 2022
493d57d
nn
DaChengTechnology Jan 20, 2022
ee6d266
Merge branch 'main' of https://github.com/DaChengTechnology/node-editor
DaChengTechnology Jan 20, 2022
1cdd9cd
修改名字
DaChengTechnology Jan 20, 2022
cb66d4d
Merge branch 'main' of https://github.com/scarsty/nn-editor into scar…
DaChengTechnology Jan 20, 2022
d16013e
1
DaChengTechnology Jan 20, 2022
2109d10
修改cmake
DaChengTechnology Jan 20, 2022
355bf5c
fix 25ad188654dd93c1e6cb562999874d5f83da57e3
DaChengTechnology Jan 20, 2022
fe81310
Merge branch 'main' into main
DaChengTechnology Jan 20, 2022
401f3e2
修复 info位置
DaChengTechnology Jan 20, 2022
b2f4a3b
修复info
DaChengTechnology Jan 20, 2022
962cdf6
Merge branch 'main' of https://github.com/DaChengTechnology/node-editor
DaChengTechnology Jan 20, 2022
825aa51
Merge branch 'main' into main
DaChengTechnology Jan 20, 2022
52d2bbc
Merge branch 'scarsty:main' into main
DaChengTechnology Jan 21, 2022
e60ea8a
修复编译
DaChengTechnology Jan 21, 2022
986ca84
fix install
DaChengTechnology Jan 21, 2022
ac83292
fix resouce
DaChengTechnology Jan 21, 2022
0e62fe9
review main
DaChengTechnology Jan 21, 2022
a69ce7a
fix arc
DaChengTechnology Jan 21, 2022
c0fc3f0
修复node内存
DaChengTechnology Jan 24, 2022
8c549be
Merge branch 'main' of https://github.com/scarsty/nn-editor into scar…
DaChengTechnology Jan 24, 2022
9d2a209
修改node
DaChengTechnology Jan 27, 2022
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
Prev Previous commit
Next Next commit
macOS 运行成功
  • Loading branch information
DaChengTechnology committed Jan 20, 2022
commit fde185d8cee2e205709987227ee2aff815c29d2e
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(APPLE)
enable_language(OBJC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-weak")
set(CMAKE_OBJCCXX_FLAGS "${CMAKE_OBJCXX_FLAGS} -x objective-c++ -fobjc-weak")
set(CMAKE_EXE_LINKER_FLAGS "-framework Metal -framework QuartzCore -framework Foundation")
set(CMAKE_EXE_LINKER_FLAGS "-framework Metal -framework QuartzCore -framework Foundation -framework Cocoa")
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/node-editor/Info.plist)
Expand Down
3 changes: 3 additions & 0 deletions node-editor/MacOSCode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace MacOSCode{
char* openFile();
}
18 changes: 16 additions & 2 deletions node-editor/color_node_editor.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "node_editor.h"
#include "node_editor.h"

#include <imnodes.h>
#include <imgui.h>
Expand Down Expand Up @@ -28,6 +28,10 @@
#include <commdlg.h>
#endif

#ifdef __APPLE__
#include "MacOSCode.h"
#endif

namespace example
{
namespace ex1
Expand Down Expand Up @@ -296,6 +300,15 @@ class ColorNodeEditor
{
return "";
}
#else
#ifdef __APPLE__
need_dialog_ = 0;
std::string filePathName;
char* n = MacOSCode::openFile();
if(n){
filePathName =n;
}
return filePathName;
#else
std::string filePathName;
ImGuiFileDialog::Instance()->OpenModal("ChooseFileDlgKey", "Choose File", "{.ini,.param}", ".");
Expand All @@ -314,6 +327,7 @@ class ColorNodeEditor
need_dialog_ = 0;
}
return filePathName;
#endif
#endif
}

Expand Down Expand Up @@ -882,7 +896,7 @@ class ColorNodeEditor
}
};

static ColorNodeEditor color_editor;
static ColorNodeEditor color_editor = ColorNodeEditor();
} // namespace

void NodeEditorInitialize(int argc, char* argv[])
Expand Down
38 changes: 34 additions & 4 deletions node-editor/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,39 @@
#include <stdio.h>
#include <SDL.h>
#include "node_editor.h"
#include <imnodes.h>

#import <Metal/Metal.h>
#import <QuartzCore/QuartzCore.h>
#import <Cocoa/Cocoa.h>

namespace MacOSCode{
char* openFile(){
@autoreleasepool {
id panl = [NSOpenPanel openPanel];
[panl setAllowsMultipleSelection:NO];
[panl setCanChooseDirectories:NO];
[panl setCanCreateDirectories:YES];
[panl setCanChooseFiles:YES];
if([panl runModal]==NSModalResponseOK){
NSString* filepath = [[[panl URLs] firstObject] path];
if(filepath){
if([filepath length] > 0){
char* f = new char[[filepath length]]();
memcpy(f, [filepath cStringUsingEncoding:NSUTF8StringEncoding], [filepath length]);
return f;
}else{
return NULL;
}
}else{
return NULL;
}
}else{
return NULL;
}
}
}
}

int main(int argc, char* argv[])
{
Expand All @@ -17,7 +47,7 @@ int main(int argc, char* argv[])
ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls

ImNodes::CreateContext();
// Setup style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
Expand All @@ -29,14 +59,14 @@ int main(int argc, char* argv[])
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
// - Read 'docs/FONTS.txt' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
//io.Fonts->AddFontDefault();
// io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
//ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
//IM_ASSERT(font != NULL);

io.Fonts->AddFontFromFileTTF("/System/Library/Fonts/PingFang.ttc", 15.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
// Setup SDL
// (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems,
// depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!)
Expand Down Expand Up @@ -141,4 +171,4 @@ int main(int argc, char* argv[])
SDL_Quit();

return 0;
}
}