# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1677433688 0 # Node ID 2d95213961129c080611bb9b652bb74f0e67c5be # Parent 531d36ebf37afc3e2b63c5a0ecfa204807885861 C++: Step 6 of the std::string transition. Fix build issues on OS/2, warnings and makefile dependencies. Also while fixing these issues I discovered more needed changes. Switch to using the std::string version of FileBrowse(). diff -r 531d36ebf37a -r 2d9521396112 dw.hpp --- a/dw.hpp Sat Feb 25 22:24:18 2023 +0000 +++ b/dw.hpp Sun Feb 26 17:48:08 2023 +0000 @@ -1926,16 +1926,16 @@ return retval; } int Setup(std::vector flags, std::vector titles) { - int count = (int)flags.size(); + unsigned int count = flags.size(); // Use the smallest of the two lists if(count > titles.size()) { - count = (int)titles.size(); + count = titles.size(); } // Convert our vectors into a arrays of unsigned long and C strings const char **ctitles = (const char **)alloca(sizeof(char *) * count); unsigned long *cflags = (unsigned long *)alloca(sizeof(unsigned long) * count); - for(int z=0; zSetForegroundColor(DW_CLR_WHITE); if(!hpm) @@ -717,8 +717,8 @@ // Connect signals browsefilebutton->ConnectClicked([this, entryfield, copypastefield]() -> int { - char *tmp = this->app->FileBrowse("Pick a file", "dwtest.c", "c", DW_FILE_OPEN); - if(tmp) + std::string tmp = this->app->FileBrowse("Pick a file", "dwtest.c", "c", DW_FILE_OPEN); + if(tmp.size()) { char *errors = ReadFile(tmp); std::string title = "New file load"; @@ -730,8 +730,6 @@ else notification = new DW::Notification(title, image, std::string(APP_TITLE) + " loaded the file into the file browser on the Render tab, with \"File Display\" selected from the drop down list."); - if(current_file) - this->app->Free(current_file); current_file = tmp; entryfield->SetText(current_file); current_col = current_row = 0; @@ -749,8 +747,8 @@ browsefolderbutton->ConnectClicked([this]() -> int { - char *tmp = this->app->FileBrowse("Pick a folder", ".", "c", DW_DIRECTORY_OPEN); - this->app->Debug("Folder picked: %s\n", tmp ? tmp : "None"); + std::string tmp = this->app->FileBrowse("Pick a folder", ".", "c", DW_DIRECTORY_OPEN); + this->app->Debug("Folder picked: " + (tmp.size() ? tmp : "None") + "\n"); return FALSE; }); @@ -1092,7 +1090,7 @@ int fheight, fwidth; // If we have a file to display... - if(current_file) + if(current_file.size()) { int nrows; @@ -1363,7 +1361,7 @@ std::string str = container->QueryStart(DW_CRA_SELECTED); while(str.size()) { - std::string buf = "Selected: " + str + "%s\r\n"; + std::string buf = "Selected: " + str + "\r\n"; mle_point = container_mle->Import(buf, mle_point); str = container->QueryNext(DW_CRA_SELECTED); } @@ -1917,7 +1915,7 @@ unsigned int render_type = SHAPES_DOUBLE_BUFFERED; char **lp; - char *current_file = NULL; + std::string current_file; // Page 4 int mle_point=-1; diff -r 531d36ebf37a -r 2d9521396112 makefile.emx --- a/makefile.emx Sat Feb 25 22:24:18 2023 +0000 +++ b/makefile.emx Sun Feb 26 17:48:08 2023 +0000 @@ -60,7 +60,7 @@ dwtest.obj: dwtest.c $(CC) $(CFLAGS) -c $< -dwtestoo.obj: dwtestoo.cpp +dwtestoo.obj: dwtestoo.cpp dw.hpp $(CC) $(CFLAGS) -std=c++11 -c $<