From 67003cad592b4ce04d0d6b7e71e4aa2df03422f9 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Sat, 19 Nov 2016 18:19:21 -0500
Subject: [PATCH] =?UTF-8?q?cherry-pick=20Albert=20Gr=C3=A4f's=20branch:=20?=
 =?UTF-8?q?Comment=20out=20a=20bunch=20of=20debugging=20statements=20which?=
 =?UTF-8?q?=20add=20a=20lot=20of=20noise=20to=20the=20console.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pd/nw/dialog_canvas.html |  8 --------
 pd/nw/dialog_data.html   |  5 -----
 pd/nw/dialog_font.html   |  2 --
 pd/nw/dialog_gatom.html  |  1 -
 pd/nw/dialog_iemgui.html |  1 -
 pd/nw/dialog_prefs.html  | 15 ---------------
 pd/nw/dialog_text.html   |  1 -
 pd/nw/pd_canvas.js       |  5 -----
 pd/nw/pdgui.js           | 32 +++++++++++++++++++-------------
 pd/src/g_scalar.c        |  1 -
 10 files changed, 19 insertions(+), 52 deletions(-)

diff --git a/pd/nw/dialog_canvas.html b/pd/nw/dialog_canvas.html
index c66ca6a7b..c38445ab1 100644
--- a/pd/nw/dialog_canvas.html
+++ b/pd/nw/dialog_canvas.html
@@ -333,7 +333,6 @@ function flag_change(elem) {
     // get value from radio group, checked from checkboxes
     if (name === "array_style") {
         value = document.querySelector('input[name="array_style"]:checked').value;
-        pdgui.post("array style found: " + value);
         // Toggle visibility of the fill color button-- only show for bar
         // graph style (= 3)
         toggle_fill_color(+value);
@@ -343,7 +342,6 @@ function flag_change(elem) {
     }
     //pdgui.post("value is " + value);
     flag = array_attr.array_flags;
-    pdgui.post("flag before is " + flag);
     switch (name) {
         case "array_save":
             flag &= ~1;    // clear the save bit
@@ -360,7 +358,6 @@ function flag_change(elem) {
             break;
     }
     array_attr.array_flags = flag;
-    pdgui.post("array is " + array_attr);
 }
 
 function flag2_change(elem) {
@@ -372,7 +369,6 @@ function flag2_change(elem) {
     // "+" for casting boolean to number
     value = +elem.checked;
     array_attr[name] = value;
-    pdgui.post("array is " + array_attr);
 }
 
 function array_delete_change(elem) {
@@ -390,8 +386,6 @@ function attr_change(elem) {
     if (elem.name === "array-fill") {
         array-fill
     }
-    pdgui.post("name is " + elem.name);
-    pdgui.post("value is " + elem.value);
 }
 
 function array_choose(array_index) {
@@ -430,7 +424,6 @@ function array_choose(array_index) {
 
 var arrays_select = document.getElementById("arrays_select");
 arrays_select.addEventListener("change", function(evt) {
-    pdgui.post("changing to array index " + evt.target.value);
     array_choose(evt.target.value);
 });
 
@@ -720,7 +713,6 @@ function populate_form(attr_object) {
                     var hex_string = Number(attr_object[prop]).toString(16);
                     var color_string = "#" +
                         (hex_string === "0" ? "000000" : hex_string);
-                    pdgui.post("color is " + color_string);
                     elem[0].value = color_string;
                 } else if (elem[0].type === "checkbox") {
                     // The attr here is a string, so we need to
diff --git a/pd/nw/dialog_data.html b/pd/nw/dialog_data.html
index 1fcaf0b16..15f09ae4b 100644
--- a/pd/nw/dialog_data.html
+++ b/pd/nw/dialog_data.html
@@ -42,7 +42,6 @@ function apply() {
         vector_textarea = document.querySelector("textarea"),
         i,
         datum;
-    pdgui.post("we're applying changes! textarea is " + vector_textarea);
     // start with the template header
     data_string += template_string;
     // add the data separator
@@ -75,9 +74,6 @@ function apply() {
         pdgui.pdsend(pd_object_callback, "data", line);
     });
 
-    pdgui.post("outgoing data string is:");
-    pdgui.post(data_string);
-
     pdgui.pdsend(pd_object_callback, "end");
 }
 
@@ -92,7 +88,6 @@ function ok() {
 }
 
 function change_size() {
-    pdgui.post("changing the size");
     apply();
 }
 
diff --git a/pd/nw/dialog_font.html b/pd/nw/dialog_font.html
index 3cd6fd8cc..2b162ced1 100644
--- a/pd/nw/dialog_font.html
+++ b/pd/nw/dialog_font.html
@@ -101,7 +101,6 @@ var current_size;
 var canvas;
 
 function apply() {
-    pdgui.post("we're applying font size changes!");
     pdgui.pdsend(canvas, "font",
         +document.querySelector('input[name="font_size"]:checked').value,
         current_size,
@@ -121,7 +120,6 @@ function ok() {
 }
 
 function change_size() {
-    pdgui.post("changing the size");
     apply();
 }
 
diff --git a/pd/nw/dialog_gatom.html b/pd/nw/dialog_gatom.html
index fd9494713..6b7f86ce5 100644
--- a/pd/nw/dialog_gatom.html
+++ b/pd/nw/dialog_gatom.html
@@ -191,7 +191,6 @@ function gatom_escape(str) {
 }
 
 function update_attr(elem) {
-    pdgui.post("updated value detected. I am " + elem.name + " and my v is " + elem.value);
     new_attrs[elem.name] = elem.value;
 }
 
diff --git a/pd/nw/dialog_iemgui.html b/pd/nw/dialog_iemgui.html
index cf20d846b..f53475d55 100644
--- a/pd/nw/dialog_iemgui.html
+++ b/pd/nw/dialog_iemgui.html
@@ -356,7 +356,6 @@ function strip_problem_chars(arg) {
 }
 
 function update_attr(elem) {
-    pdgui.post("updating attr " + elem.name);
     if (!new_attrs.hasOwnProperty(elem.name)) {
         pdgui.post("warning: new_attrs[" + elem.name + "] doesn't exist");
     }
diff --git a/pd/nw/dialog_prefs.html b/pd/nw/dialog_prefs.html
index e3fc34166..313c43886 100644
--- a/pd/nw/dialog_prefs.html
+++ b/pd/nw/dialog_prefs.html
@@ -356,8 +356,6 @@ function attr_change(elem) {
     attr = pd_audio_attrs;
     id = elem.id;
     attr[attr.indexOf(id) + 1] = elem.value;
-    pdgui.post("id is " + elem.id);
-    pdgui.post("value is " + elem.value);
 }
 
 function alsa_ports_change(elem, type) {
@@ -414,7 +412,6 @@ function kludge_chans(type, attrs, index) {
 function apply(save_prefs) {
     var attrs = pd_audio_attrs,
         midi_use_alsa;
-    pdgui.post("applying preferences");
 
     // Audio dialog
     pdgui.pdsend(
@@ -469,7 +466,6 @@ function apply(save_prefs) {
 
 function cancel() {
     var i, attrs, gfxstub;
-    pdgui.post("closing the window at this point");
     // There seems to be a bug in nwjs 0.13 beta3 that doesn't call the
     // "close" event below. This has the symptom of making it impossible
     // to click the "Ok" button and open the preferences dialog again after
@@ -495,9 +491,7 @@ function get_attr(name, attrs) {
 }
 
 function populate_apis(elem, apis, current_api) {
-    pdgui.post("curent api is " + current_api);
     var i, opt, api_select = elem;
-    pdgui.post("apis are " + apis);
     for (i = 0; i < apis.length; i += 2) {
         opt = document.createElement("option");
         opt.textContent = apis[i];
@@ -510,8 +504,6 @@ function populate_apis(elem, apis, current_api) {
 function populate_devs(type, attrs) {
     var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
     var i, j, opt, elem, chan_elem, chans;
-    pdgui.post("devs are " + devs);
-    pdgui.post("type is " + type + 1);
     chans = get_attr("pd-" + type + "chans", attrs);
     for (i = 0; i < 4; i++) {
         elem = document.getElementById(type + (i+1));
@@ -539,8 +531,6 @@ function populate_midi_devs(type, attrs) {
     var dev_names = get_attr(type === "in" ?
         "midi-indev-names" : "midi-outdev-names", attrs);
     var i, j, opt, elem;
-    pdgui.post("dev names are " + dev_names);
-    pdgui.post("type is " + type);
     for (i = 0; i < 4; i++) {
         elem = document.getElementById("midi_" + type + (i+1));
         // if the user changed the API, we need to remove the old devs
@@ -590,8 +580,6 @@ function audio_prefs_callback(attrs) {
     pd_audio_attrs = attrs;
     var api_select = document.getElementById("audio_api");
     var callback, i, j, elem, devs, opt;
-    pdgui.post("audio attrs are " + attrs);
-    pdgui.post("attrs length " + attrs.length);
     // We can get this callback multiple times while the dialog
     // is open.  This is because an API change requires a query
     // for new properties. So we only populate the api options
@@ -656,8 +644,6 @@ function set_chans(type, chans_array) {
 function midi_prefs_callback(attrs) {
     pd_midi_attrs = attrs;
     var api_select = document.getElementById("midi_api");
-    pdgui.post("midi attrs are " + attrs);
-    pdgui.post("attrs length " + attrs.length);
 
     if (api_select.getElementsByTagName("option").length < 1) {
         populate_apis(
@@ -773,7 +759,6 @@ function populate_form(attr_array) {
             if (elem[0].type === "checkbox") {
                 // The attr here is a string, so we need to
                 // force it to number, hence the "+" below
-                pdgui.post("found a CHECKED ITEM!!!");
                 elem[0].checked = +attr_array[i+1];
             } else {
                 elem[0].value = attr_array[i+1];
diff --git a/pd/nw/dialog_text.html b/pd/nw/dialog_text.html
index b5bc5d5b4..3ed14d27f 100644
--- a/pd/nw/dialog_text.html
+++ b/pd/nw/dialog_text.html
@@ -55,7 +55,6 @@ var dirty = false;
 
 function apply() {
     var text_array = document.getElementById("text").value.split("\n");
-    pdgui.post("applying...");
     // clear out Pd's binbuf for our text object
     pdgui.pdsend(pd_object_callback, "clear");
     text_array.forEach(function (line) {
diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js
index 06d983929..f43d7f366 100644
--- a/pd/nw/pd_canvas.js
+++ b/pd/nw/pd_canvas.js
@@ -326,7 +326,6 @@ var canvas_events = (function() {
             text_keyup: function(evt) {
                 evt.stopPropagation();
                 if (evt.keyCode === 13) {
-                    pdgui.post("growing the svg...");
                     grow_svg_for_element(textbox());
                 }
                 //evt.preventDefault();
@@ -338,7 +337,6 @@ var canvas_events = (function() {
                 return false;
             },
             text_paste: function(evt) {
-                pdgui.post("text paste detected...");
                 evt.preventDefault();
                 document.execCommand("insertText", false,
                     evt.clipboardData.getData("text"));
@@ -496,17 +494,14 @@ var canvas_events = (function() {
         // nw menubar receives the event and doesn't propagate
         // to the DOM. But if we add the ability to toggle menubar
         // display, we might need to rely on this listener.
-        pdgui.post("cut detected by DOM listener");
         pdgui.pdsend(name, "cut");
     });
 
     // Copy event
     document.addEventListener("copy", function(evt) {
-        pdgui.post("copy detected by DOM listener");
         // On OSX, this event gets triggered when we're editing
         // inside an object/message box. So we only forward the
         // copy message to Pd if we're in a "normal" canvas state
-        pdgui.post("copy detected by DOM listener");
         if (canvas_events.get_state() === "normal") {
             pdgui.pdsend(name, "copy");
         }
diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js
index 24628ce80..d82c56cfc 100644
--- a/pd/nw/pdgui.js
+++ b/pd/nw/pdgui.js
@@ -582,6 +582,12 @@ function gui_post_error(objectid, loglevel, errormsg) {
 }
 
 function gui_legacy_tcl_command(file, line_number, text) {
+    // Print legacy tcl commands on the console. These may still be present in
+    // some parts of the code (usually externals) which haven't been converted
+    // to the new nw.js gui yet. Usually the presence of such commands
+    // indicates a bug that needs to be fixed. This information is most useful
+    // for developers, so you may want to comment out the following line if
+    // you don't want to see them.
     post("legacy tcl command at " + line_number + " of " + file + ": " + text);
 }
 
@@ -1006,7 +1012,6 @@ function external_doc_open(url) {
 exports.external_doc_open = external_doc_open;
 
 function gui_set_cwd(dummy, cwd) {
-    post("cwd from secondary instance is " + cwd);
     if (cwd !== ".") {
         pwd = cwd;
     }
@@ -1904,7 +1909,7 @@ function gui_canvas_select_line(cid, tag) {
     if (line !== null) {
         line.classList.add("selected_line");
     } else {
-        post("gui_canvas_select_line: can't find line");
+        //post("gui_canvas_select_line: can't find line");
     }
 }
 
@@ -1913,7 +1918,7 @@ function gui_canvas_deselect_line(cid, tag) {
     if (line !== null) {
         line.classList.remove("selected_line");
     } else {
-        post("gui_canvas_select_line: can't find line");
+        //post("gui_canvas_select_line: can't find line");
     }
 }
 
@@ -1923,7 +1928,7 @@ function gui_canvas_delete_line(cid, tag) {
     if (line !== null) {
         line.parentNode.removeChild(line);
     } else {
-        post("canvas_delete_line: error: the line doesn't exist");
+        //post("canvas_delete_line: error: the line doesn't exist");
     }
 }
 
@@ -2104,8 +2109,12 @@ function gui_gobj_erase(cid, tag) {
     if (g !== null) {
         g.parentNode.removeChild(g);
     } else {
-        post("gui_gobj_erase: gobj " + tag +
-            " didn't exist in the first place!");
+        // Unfortunately Pd can send messages
+        // to erase objects before they got created,
+        // or extra messages to delete objects. So
+        // we can't report an error here...
+        //post("gui_gobj_erase: gobj " + tag +
+        //    " didn't exist in the first place!");
     }
 }
 
@@ -2852,7 +2861,7 @@ function gui_iemgui_label_show_drag_handle(cid, tag, state, x, y, cnv_resize) {
             if (rect) {
                 rect.parentNode.removeChild(rect);
             } else {
-                post("couldnt delete the iemgui drag handle!");
+                post("error: couldn't delete the iemgui drag handle!");
             }
         }
     }
@@ -3014,7 +3023,7 @@ function gui_draw_erase_item(cid, tag) {
     if (item !== null) {
         item.parentNode.removeChild(item);
     } else {
-        post("uh oh... gui_draw_erase_item couldn't find the item...");
+        //post("uh oh... gui_draw_erase_item couldn't find the item...");
     }
 }
 
@@ -3234,7 +3243,6 @@ function gui_drawimage_new(obj_tag, file_path, canvasdir, flags) {
                 ext === ".jpeg" ||
                 ext === ".svg") {
 
-                post("we got an image at index " + i + ": " + files[i]);
                 // Now add an element to that array with the image data
                 drawimage_data.push({
                     type: ext === ".jpeg" ? "jpg" : ext.slice(1),
@@ -3263,7 +3271,6 @@ function gui_drawimage_new(obj_tag, file_path, canvasdir, flags) {
 function gui_drawimage_free(obj_tag) {
     var c = pd_cache.get(obj_tag);
     if (c) {
-        post("image: freed image data for " + obj_tag);
         pd_cache.free(obj_tag); // empty the image(s)
     } else {
         post("image: warning: no image data in cache to free");
@@ -4031,7 +4038,7 @@ function gui_cord_inspector_erase(cid) {
     if (ci !== null) {
         ci.parentNode.removeChild(ci);
     } else {
-        post("oops, trying to erase cord inspector that doesn't exist!");
+        //post("oops, trying to erase cord inspector that doesn't exist!");
     }
 }
 
@@ -4044,7 +4051,7 @@ function gui_cord_inspector_flash(cid, state) {
             ct.classList.remove("flash");
         }
     } else {
-        post("gui_cord_inspector_flash: cord inspector doesn't exist!");
+        //post("gui_cord_inspector_flash: cord inspector doesn't exist!");
     }
 }
 
@@ -4358,7 +4365,6 @@ var skin = exports.skin = (function () {
         },
         set: function (name) {
             preset = name;
-            post("trying to set...");
             for (id in patchwin) {
                 if (patchwin.hasOwnProperty(id) && patchwin[id]) {
                     set_css(patchwin[id].window);
diff --git a/pd/src/g_scalar.c b/pd/src/g_scalar.c
index 160c71ecb..8992e38cc 100644
--- a/pd/src/g_scalar.c
+++ b/pd/src/g_scalar.c
@@ -1026,7 +1026,6 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
         // we removed this because it caused infinite recursion
         // in the scalar-help.pd example
         //scalar_select(z, owner, 1);
-        post("here we are in scalar vis, selected...");
         scalar_drawselectrect(x, owner, 0);
         scalar_drawselectrect(x, owner, 1);
     }
-- 
GitLab