diff options
| author | Giuseppe Baruffa <gbaruffa@users.noreply.github.com> | 2008-02-11 14:43:11 +0000 |
|---|---|---|
| committer | Giuseppe Baruffa <gbaruffa@users.noreply.github.com> | 2008-02-11 14:43:11 +0000 |
| commit | ac0cc6df623f02e21fb9eb950e73237c794f4a89 (patch) | |
| tree | b40ac18880c2028a1777e84ccc679ac4e8a3e757 /OPJViewer/source/imagjpeg2000.cpp | |
| parent | 29ea3dde47818da3eecb917ebb1db797a3e80d44 (diff) | |
Minor style modifications to comply with c99 compiler flag; removed Microsoft-specific "union-in-struct" syntax; Re-enabled cstr_info struct creation when -W switch is specified. Changed a number of things in opjviewer (e.g., decoding thread does not execute GUI calls anymore), to have it running under linux --> it is better than before, but still crashes
Diffstat (limited to 'OPJViewer/source/imagjpeg2000.cpp')
| -rw-r--r-- | OPJViewer/source/imagjpeg2000.cpp | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/OPJViewer/source/imagjpeg2000.cpp b/OPJViewer/source/imagjpeg2000.cpp index bcf1ca73..66e1146b 100644 --- a/OPJViewer/source/imagjpeg2000.cpp +++ b/OPJViewer/source/imagjpeg2000.cpp @@ -128,46 +128,61 @@ jpeg2000familytype(unsigned char *hdr, int hdr_len) }
-/* sample error callback expecting a FILE* client object */
-void jpeg2000_error_callback(const char *msg, void *client_data) {
- int message_len = strlen(msg) - 1;
- if (msg[message_len] != '\n')
- message_len = MAX_MESSAGE_LEN;
+/* we have to use this to avoid GUI-noGUI threads crashing */
+void printevent(const char *msg)
+{
#ifndef __WXGTK__
- wxMutexGuiEnter();
+ wxMutexGuiEnter();
#endif /* __WXGTK__ */
- wxLogMessage(wxT("[ERROR] %.*s"), message_len, msg);
+ wxLogMessage(wxT("%s"), msg);
#ifndef __WXGTK__
wxMutexGuiLeave();
#endif /* __WXGTK__ */
}
+/* sample error callback expecting a FILE* client object */
+void jpeg2000_error_callback(const char *msg, void *client_data) {
+ char mess[MAX_MESSAGE_LEN + 20];
+ int message_len = strlen(msg);
+
+ if (message_len > MAX_MESSAGE_LEN)
+ message_len = MAX_MESSAGE_LEN;
+
+ if (msg[message_len - 1] == '\n')
+ message_len--;
+
+ sprintf(mess, "[ERROR] %.*s", message_len, msg);
+ printevent(mess);
+}
+
/* sample warning callback expecting a FILE* client object */
void jpeg2000_warning_callback(const char *msg, void *client_data) {
- int message_len = strlen(msg) - 1;
- if (msg[message_len] != '\n')
+ char mess[MAX_MESSAGE_LEN + 20];
+ int message_len = strlen(msg);
+
+ if (message_len > MAX_MESSAGE_LEN)
message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__
- wxMutexGuiEnter();
-#endif /* __WXGTK__ */
- wxLogMessage(wxT("[WARNING] %.*s"), message_len, msg);
-#ifndef __WXGTK__
- wxMutexGuiLeave();
-#endif /* __WXGTK__ */
+
+ if (msg[message_len - 1] == '\n')
+ message_len--;
+
+ sprintf(mess, "[WARNING] %.*s", message_len, msg);
+ printevent(mess);
}
/* sample debug callback expecting no client object */
void jpeg2000_info_callback(const char *msg, void *client_data) {
- int message_len = strlen(msg) - 1;
- if (msg[message_len] != '\n')
+ char mess[MAX_MESSAGE_LEN + 20];
+ int message_len = strlen(msg);
+
+ if (message_len > MAX_MESSAGE_LEN)
message_len = MAX_MESSAGE_LEN;
-#ifndef __WXGTK__
- wxMutexGuiEnter();
-#endif /* __WXGTK__ */
- wxLogMessage(wxT("[INFO] %.*s"), message_len, msg);
-#ifndef __WXGTK__
- wxMutexGuiLeave();
-#endif /* __WXGTK__ */
+
+ if (msg[message_len - 1] == '\n')
+ message_len--;
+
+ sprintf(mess, "[INFO] %.*s", message_len, msg);
+ printevent(mess);
}
/* macro functions */
|
