-
Notifications
You must be signed in to change notification settings - Fork 238
Fixing memory leaks using exceptions #2620
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
Changes from all commits
2ecdb7f
affd49d
e090359
e6b31f3
ae873c1
5d0cf53
14128cb
271d2b1
d1aad2a
d04c899
de39150
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,11 +319,41 @@ typedef unsigned char uint8_t; | |
| // definition for custom event | ||
| #define MS_PACKET_RECEIVED 0 | ||
|
|
||
| /* Classes ********************************************************************/ | ||
| /* Exception Classes **********************************************************/ | ||
|
|
||
| class CInfoExit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't add this class. It's only used to replace
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's what you call a "normal" situation... |
||
| { | ||
| public: | ||
| CInfoExit ( QString strMsg ) : strInfoMsg ( strMsg ) {} | ||
|
|
||
| QString GetInfoMessage() const { return strInfoMsg; } | ||
|
|
||
| protected: | ||
| QString strInfoMsg; | ||
| }; | ||
|
|
||
| class CErrorExit | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd call this something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Again, this is a 'universal' solution, so not only usable for commandline errors, so why name it that way just because we now use it for commandline errors?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we can leave it as is - if we use it in future (and I think there is work coming up by @pgScorpio which uses it) |
||
| { | ||
| public: | ||
| CErrorExit ( QString strNewErrorMsg, int iNewExitCode = 1 ) : strErrorMsg ( strNewErrorMsg ), iExitCode ( iNewExitCode ) {} | ||
|
|
||
| QString GetErrorMessage() const { return strErrorMsg; } | ||
|
|
||
| int GetExitCode() const { return iExitCode; } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The exit code is always 1 on error in the code below, so
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree the exit code is (strangely enough) always 1 in this code, but as said we should provide a framework with general solutions, not prohibiting any 'normal' behavior. |
||
|
|
||
| protected: | ||
| QString strErrorMsg; | ||
| int iExitCode; | ||
| }; | ||
|
|
||
| class CGenErr | ||
| { | ||
| public: | ||
| CGenErr ( QString strNewErrorMsg, QString strNewErrorType = "" ) : strErrorMsg ( strNewErrorMsg ), strErrorType ( strNewErrorType ) {} | ||
| CGenErr ( QString strNewErrorMsg, QString strNewErrorType = "", int iNewExitCode = 1 ) : | ||
| strErrorMsg ( strNewErrorMsg ), | ||
| strErrorType ( strNewErrorType ), | ||
| iExitCode ( iNewExitCode ) | ||
| {} | ||
|
|
||
| QString GetErrorText() const | ||
| { | ||
|
|
@@ -338,11 +368,16 @@ class CGenErr | |
| } | ||
| } | ||
|
|
||
| int GetExitCode() const { return iExitCode; } | ||
|
|
||
| protected: | ||
| QString strErrorMsg; | ||
| QString strErrorType; | ||
| int iExitCode; | ||
| }; | ||
|
|
||
| /* Event Classes **************************************************************/ | ||
|
|
||
| class CCustomEvent : public QEvent | ||
| { | ||
| public: | ||
|
|
@@ -359,6 +394,9 @@ class CCustomEvent : public QEvent | |
| }; | ||
|
|
||
| /* Prototypes for global functions ********************************************/ | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used - remove.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, Provide a Framework that should (and will) be used in the near future... |
||
| extern const QString GetAppName(); | ||
|
|
||
| // command line parsing, TODO do not declare functions globally but in a class | ||
| QString UsageArguments ( char** argv ); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.