From 6555140b9abfced31de84d548911c0565ccea34f Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Thu, 2 Apr 2009 05:13:27 +0000 Subject: [PATCH] changed: variables and functions are copied to the second thread only when they have been changed (performance) flags: variables_id and functions_id in ProgramResources changed: you don't have to be an administrator to use the setup (installer) PrivilegesRequired=none in innosetup.iss changed: small changes in Makefile(s) especially pathes changed: upx 3.03 is used now (for the portable version) git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@116 e52654a7-88a9-db11-a3e9-0013d4bc506e --- help/help.hhp | 2 +- setup/innosetup.iss | 10 +++++++--- src/Makefile | 33 +++++++++++++++----------------- src/Makefileportable | 11 ++++------- src/bigtypes.h | 2 +- src/compileconfig.h | 2 +- src/convert.h | 2 +- src/functions.cpp | 7 ++++++- src/languages.cpp | 8 ++++---- src/languages.h | 2 +- src/parsermanager.cpp | 19 ++++++++++++++++--- src/parsermanager.h | 4 +++- src/programresources.cpp | 41 +++++++++++++++++++++++++++++++++++++++- src/programresources.h | 33 ++++++++++++++++++++++++++++++++ src/resource.h | 2 +- src/tabs.cpp | 2 +- src/variables.cpp | 7 ++++++- 17 files changed, 141 insertions(+), 46 deletions(-) diff --git a/help/help.hhp b/help/help.hhp index 52d8aa4..a1876cf 100644 --- a/help/help.hhp +++ b/help/help.hhp @@ -1,7 +1,7 @@ [OPTIONS] Auto Index=Yes Compatibility=1.1 or later -Compiled file=..\..\output\ttcalc.chm +Compiled file=ttcalc.chm Contents file=toc.hhc Default topic=index.html Display compile progress=No diff --git a/setup/innosetup.iss b/setup/innosetup.iss index 32d12db..b3b579a 100644 --- a/setup/innosetup.iss +++ b/setup/innosetup.iss @@ -4,6 +4,7 @@ [Setup] AppName=TTCalc AppVerName=TTCalc 0.8.3 +AppVersion=0.8.3 AppPublisher=Tomasz Sowa AppPublisherURL=http://ttcalc.sourceforge.net AppSupportURL=http://ttcalc.sourceforge.net @@ -13,11 +14,12 @@ DefaultGroupName=TTCalc AllowNoIcons=yes ; special COPYRIGHT version (without a new line characters in the clause -- it is better displayed in the setup window) LicenseFile=COPYRIGHT -OutputDir=..\..\output +OutputDir=..\setup OutputBaseFilename=ttcalc-setup Compression=lzma SolidCompression=yes ShowUndisplayableLanguages=yes +PrivilegesRequired=none [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -32,9 +34,11 @@ Type: files; Name: "{app}\mingwm10.dll" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "..\..\output\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\output\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\src\ttcalc.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\help\ttcalc.chm"; DestDir: "{app}"; Flags: ignoreversion Source: "..\COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\CHANGELOG"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\README"; DestDir: "{app}"; Flags: ignoreversion ; now we do not use *.ini file in the installer ; NOTE: Don't use "Flags: ignoreversion" on any shared system files diff --git a/src/Makefile b/src/Makefile index 474fe0e..f6385da 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CC = g++ -#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../../ttmath -DTTCALC_CONVERT -CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../../ttmath +#CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath -DTTCALC_CONVERT +CFLAGS = -Wall -pedantic -s -O2 -mwindows -I../../ttmath name = ttcalc.exe # the name of the help is also set in the html help workshop project file @@ -8,37 +8,34 @@ helpname = ttcalc.chm # the name of the setup is also set in the Inno Setup config file setupname = ttcalc-setup.exe - + + -dir_output = ../../output all: ttcalc + include Makefile.dep -$(dir_output)/$(name): $(o) - $(CC) -o $(dir_output)/$(name) $(CFLAGS) $(o) -lcomctl32 - -ttcalc: $(dir_output)/$(name) - +ttcalc: $(o) + $(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 + resource.o: resource.rc #windres -DTTCALC_CONVERT resource.rc resource.o windres resource.rc resource.o -$(dir_output)/$(helpname): $(helpdep) + +help: $(helpdep) Makefile.help.sh + -help: $(dir_output)/$(helpname) - -$(dir_output)/$(setupname): $(setupdep) +setup: $(setupdep) iscc ../setup/innosetup.iss -setup: $(dir_output)/$(setupname) - clean: rm -f *.o rm -f *.s - rm -f $(dir_output)/$(name) - rm -f $(dir_output)/$(helpname) - rm -f $(dir_output)/$(setupname) + rm -f $(name) + rm -f $(helpname) + rm -f $(setupname) diff --git a/src/Makefileportable b/src/Makefileportable index 601d4c6..4d67040 100644 --- a/src/Makefileportable +++ b/src/Makefileportable @@ -1,18 +1,15 @@ CC = g++ -CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../../ttmath -DTTCALC_PORTABLE +CFLAGS = -Wall -pedantic -s -Os -fno-default-inline -mwindows -I../../ttmath -DTTCALC_PORTABLE name = ttcalcp.exe -dir_output = ../../output compressor = upx all: ttcalc include Makefile.dep -$(dir_output)/$(name): $(o) - $(CC) -o $(dir_output)/$(name) $(CFLAGS) $(o) -lcomctl32 - $(compressor) -7 $(dir_output)/$(name) +ttcalc: $(o) + $(CC) -o $(name) $(CFLAGS) $(o) -lcomctl32 + $(compressor) -7 $(name) -ttcalc: $(dir_output)/$(name) - resource.o: resource.rc windres -DTTCALC_PORTABLE resource.rc resource.o diff --git a/src/bigtypes.h b/src/bigtypes.h index 45a6a2e..6df94ec 100644 --- a/src/bigtypes.h +++ b/src/bigtypes.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/compileconfig.h b/src/compileconfig.h index 0a07304..22a1957 100644 --- a/src/compileconfig.h +++ b/src/compileconfig.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/convert.h b/src/convert.h index d05bcf7..acee501 100644 --- a/src/convert.h +++ b/src/convert.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/functions.cpp b/src/functions.cpp index d54ce32..f6f83fe 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -223,6 +223,7 @@ BOOL WmTabCommand_AddFunction(HWND, UINT message, WPARAM wParam, LPARAM lParam) GetPrgRes()->GetThreadController()->StopCalculating(); code = GetPrgRes()->GetFunctions()->Add(name, value, parameters); + GetPrgRes()->FunctionsChanged(); GetPrgRes()->GetThreadController()->StartCalculating(); if( code != ttmath::err_ok ) @@ -290,6 +291,7 @@ adding = false; // if we've changed the name then we're changing the value and parameters code = GetPrgRes()->GetFunctions()->EditValue(name, value, parameters); + GetPrgRes()->FunctionsChanged(); GetPrgRes()->GetThreadController()->StartCalculating(); if( code != ttmath::err_ok ) @@ -339,9 +341,12 @@ int items = ListView_GetSelectedCount(list); all_deleted = false; else ListView_DeleteItem(list, id); + + GetPrgRes()->FunctionsChanged(); } } + GetPrgRes()->GetThreadController()->StartCalculating(); delete [] buffer; diff --git a/src/languages.cpp b/src/languages.cpp index 3461cd2..228814a 100644 --- a/src/languages.cpp +++ b/src/languages.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -337,7 +337,7 @@ void Languages::InitGuiMessagesTab() " a developer or a programmer feel free to contant with the author." ); InsertGuiPair(about_text_portable_version, " portable version"); - InsertGuiPair(about_text_exe_packer, "EXE Packer: UPX 3.00\r\n"); + InsertGuiPair(about_text_exe_packer, "EXE Packer: UPX 3.03\r\n"); InsertGuiPair(about_box_title, "About"); InsertGuiPair(about_box_button_close, "Close"); InsertGuiPair(unknown_error, "An unknown error has occurred"); @@ -462,7 +462,7 @@ void Languages::InitGuiMessagesTab() " poprostu skontaktuj się z autorem." ); InsertGuiPair(about_text_portable_version, " wersja portable"); - InsertGuiPair(about_text_exe_packer, "Paker exe: UPX 3.00\r\n"); + InsertGuiPair(about_text_exe_packer, "Paker exe: UPX 3.03\r\n"); InsertGuiPair(about_box_title, "O programie"); InsertGuiPair(about_box_button_close, "Zamknij"); InsertGuiPair(unknown_error, "Nieznany kod błędu"); @@ -591,7 +591,7 @@ void Languages::InitGuiMessagesTab() " desarrollador o programador, no dudes en contactar con el autor." ); InsertGuiPair(about_text_portable_version, " version portatil"); - InsertGuiPair(about_text_exe_packer, "EXE Packer: UPX 3.00\r\n"); + InsertGuiPair(about_text_exe_packer, "EXE Packer: UPX 3.03\r\n"); InsertGuiPair(about_box_title, "Acerca de"); InsertGuiPair(about_box_button_close, "Cerrar"); InsertGuiPair(unknown_error, "Ocurrio un error desconocido"); diff --git a/src/languages.h b/src/languages.h index b0681c5..99253c8 100644 --- a/src/languages.h +++ b/src/languages.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/parsermanager.cpp b/src/parsermanager.cpp index dd71f54..7bcae0a 100644 --- a/src/parsermanager.cpp +++ b/src/parsermanager.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,6 +50,8 @@ ParserManager::ParserManager() : buffer_len(2048) when_scientific = 15; rounding = -1; remove_zeroes = true; + last_variables_id = 0; + last_functions_id = 0; } @@ -62,6 +64,8 @@ ParserManager::ParserManager(const ParserManager & p) : buffer_len(p.buffer_len) when_scientific = p.when_scientific; rounding = p.rounding; remove_zeroes = p.remove_zeroes; + last_variables_id = p.last_variables_id; + last_functions_id = p.last_functions_id; } @@ -142,8 +146,17 @@ unsigned int i; // - variables = *GetPrgRes()->GetVariables(); - functions = *GetPrgRes()->GetFunctions(); + if( GetPrgRes()->GetVariablesId() != last_variables_id ) + { + variables = *GetPrgRes()->GetVariables(); + last_variables_id = GetPrgRes()->GetVariablesId(); + } + + if( GetPrgRes()->GetFunctionsId() != last_functions_id ) + { + functions = *GetPrgRes()->GetFunctions(); + last_functions_id = GetPrgRes()->GetFunctionsId(); + } // base_input = GetPrgRes()->GetBaseInput(); diff --git a/src/parsermanager.h b/src/parsermanager.h index b48b9f3..f027f36 100644 --- a/src/parsermanager.h +++ b/src/parsermanager.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -121,6 +121,8 @@ private: #endif ttmath::Objects variables, functions; + int last_variables_id; + int last_functions_id; const unsigned int buffer_len; char * buffer; diff --git a/src/programresources.cpp b/src/programresources.cpp index 1544dfc..914236d 100644 --- a/src/programresources.cpp +++ b/src/programresources.cpp @@ -319,6 +319,31 @@ ttmath::Objects * ProgramResources::GetFunctions() return &functions; } + +void ProgramResources::VariablesChanged() +{ + ++variables_id; +} + + +void ProgramResources::FunctionsChanged() +{ + ++functions_id; +} + + +int ProgramResources::GetVariablesId() +{ + return variables_id; +} + + +int ProgramResources::GetFunctionsId() +{ + return functions_id; +} + + Languages * ProgramResources::GetLanguages() { return &languages; @@ -453,6 +478,9 @@ ProgramResources::ProgramResources() decimal_point = 0; angle_deg_rad_grad = 1; // rad is default + + variables_id = 0; + functions_id = 0; } @@ -647,17 +675,26 @@ IniParser::Section::iterator ic; // we're adding variables if( !if_not_exist ) + { variables.Clear(); + VariablesChanged(); + } for( ic = temp_variables.begin() ; ic!=temp_variables.end() ; ++ic ) if( !if_not_exist || !variables.IsDefined(ic->first) ) + { variables.Add(ic->first, ic->second); + VariablesChanged(); + } // we're adding functions if( !if_not_exist ) + { functions.Clear(); + FunctionsChanged(); + } for( ic = temp_functions.begin() ; ic!=temp_functions.end() ; ++ic ) { @@ -666,7 +703,10 @@ IniParser::Section::iterator ic; if( !if_not_exist || !functions.IsDefined(ic->first) ) if( SplitFunction(ic->second, &name, ¶m) ) + { functions.Add(ic->first, name, param); + FunctionsChanged(); + } } } @@ -675,7 +715,6 @@ IniParser::Error ProgramResources::ReadVariablesFunctionsFromFile() { IniParser iparser; IniParser::Section temp_variables, temp_functions; -std::string ini_value[20]; iparser.ConvertValueToSmallLetters(false); iparser.SectionCaseSensitive(false); diff --git a/src/programresources.h b/src/programresources.h index 6a16f57..110c881 100644 --- a/src/programresources.h +++ b/src/programresources.h @@ -218,6 +218,36 @@ public: volatile ThreadController * GetThreadController(); + /*! + if you change some variables by using GetVariable() method + you should call this method in order to inform the second thread that variables have changed + (variables_id will be increment) + */ + void VariablesChanged(); + + + /*! + if you change some functions by using GetFunction() method + you should call this method in order to inform the second thread that functions have changed + (functions_id will be increment) + */ + void FunctionsChanged(); + + + /*! + returning the state of variables_id + (used by the second thread) + */ + int GetVariablesId(); + + + /*! + returning the state of functions_id + (used by the second thread) + */ + int GetFunctionsId(); + + /*! pointers to variables' table, functions' table, the languages' object, convert object and to the characters' buffer @@ -321,6 +351,9 @@ private: Convert convert; volatile ThreadController thread_controller; + int variables_id; + int functions_id; + unsigned int buffer_size; char * buffer; diff --git a/src/resource.h b/src/resource.h index 50156ee..9ed43cc 100644 --- a/src/resource.h +++ b/src/resource.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/tabs.cpp b/src/tabs.cpp index 5b00c43..5e40616 100644 --- a/src/tabs.cpp +++ b/src/tabs.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/variables.cpp b/src/variables.cpp index a622b9e..d87a490 100644 --- a/src/variables.cpp +++ b/src/variables.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2006-2008, Tomasz Sowa + * Copyright (c) 2006-2009, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -254,6 +254,7 @@ BOOL WmTabCommand_AddVariable(HWND, UINT message, WPARAM wParam, LPARAM lParam) GetPrgRes()->GetThreadController()->StopCalculating(); code = GetPrgRes()->GetVariables()->Add(name, value); + GetPrgRes()->VariablesChanged(); GetPrgRes()->GetThreadController()->StartCalculating(); if( code != ttmath::err_ok ) @@ -317,6 +318,7 @@ adding = false; code = GetPrgRes()->GetVariables()->EditValue(name, value); // the code should be err_ok here + GetPrgRes()->VariablesChanged(); GetPrgRes()->GetThreadController()->StartCalculating(); if( code != ttmath::err_ok ) @@ -366,8 +368,11 @@ int items = ListView_GetSelectedCount(list); all_deleted = false; else ListView_DeleteItem(list, id); + + GetPrgRes()->VariablesChanged(); } } + GetPrgRes()->GetThreadController()->StartCalculating();