Skip to content

Commit

Permalink
解决打开文件时可能造成的野指针问题 (#27)
Browse files Browse the repository at this point in the history
* 增加macOS支持cmake编译

* 修复Cannot create __weak reference

* a

* add MRC

* fix yaml

* 可以生成app 但是 会报空指针

* macOS 运行成功

* 改名

* nn

* 修改名字

* 1

* 修改cmake

* fix 25ad188

* 修复 info位置

* 修复info

* 修复编译

* fix install

* fix resouce

* review main

* fix arc

* 修复node内存

* 修改node
  • Loading branch information
DaChengTechnology authored Jan 27, 2022
1 parent 542de6d commit 31a658c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
34 changes: 17 additions & 17 deletions nn-editor/main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@
#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;
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;
}
}else{
return NULL;
}
}
}
}

int main(int argc, char* argv[])
{
Expand Down
11 changes: 6 additions & 5 deletions nn-editor/nn_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ class ColorNodeEditor
{
filePathName =n;
}
delete n;
return filePathName;
#else
std::string filePathName;
Expand Down Expand Up @@ -361,8 +362,9 @@ class ColorNodeEditor

// The node editor window
std::string window_title = u8"Neural Net Editor";
ImGui::SetWindowSize(window_title.c_str(), ImGui::GetIO().DisplaySize);
ImGui::Begin(window_title.c_str(), NULL, flags);
ImGui::SetWindowSize(window_title.c_str(), ImGui::GetIO().DisplaySize);
window_title.clear();

//if (ImGui::) //close window
if (ImGui::BeginMenuBar())
Expand Down Expand Up @@ -476,6 +478,7 @@ class ColorNodeEditor
// emulate_three_button_mouse ? &ImGui::GetIO().KeyAlt : NULL;
//}
//ImGui::Columns(1);
ImNodes::BeginNodeEditor();

{
select_id_ = -1;
Expand All @@ -486,8 +489,6 @@ class ColorNodeEditor
erase_select_ = 0;
}

ImNodes::BeginNodeEditor();

// Handle new nodes
// These are driven by the user, so we place this code before rendering the nodes
{
Expand Down Expand Up @@ -765,7 +766,6 @@ class ColorNodeEditor
}
}
ImNodes::MiniMap(0.5f, minimap_location_);
ImNodes::EndNodeEditor();

// Handle new links
// These are driven by Imnodes, so we place the code after EndNodeEditor().
Expand Down Expand Up @@ -927,7 +927,8 @@ class ColorNodeEditor
}

//refresh_pos_link();


ImNodes::EndNodeEditor();
ImGui::End();
first_run_ = 0;
}
Expand Down

0 comments on commit 31a658c

Please sign in to comment.