Author Topic: Nasty qeditor feature  (Read 415 times)

sinsi

  • Member
  • *****
  • Posts: 1182
Nasty qeditor feature
« on: July 11, 2019, 07:57:26 PM »
Found this one by accident. Edit any file, then drag and drop another file into the editor window and say goodbye to the original edit, no asking to save first.
Moral of the story: save often and let go of the mouse before you sneeze...
I can walk on water but stagger on beer bourbon.

jj2007

  • Member
  • *****
  • Posts: 9688
  • Assembler is fun ;-)
    • MasmBasic
Re: Nasty qeditor feature
« Reply #1 on: July 11, 2019, 09:11:06 PM »
My advice: Use a decent editor :badgrin:

Jokes apart: I just discovered by accident that Ms Word 2003 does something similar but equally dangerous: edit a macro in the VBA editor, exit Word, it will save them without asking.

So, where's the problem? I had a nice fat macro there, but for testing something I selected all, then inserted a say hello MsgBox... press Alt F4, Word quits without asking, on relaunch there is the MsgBox but the fat macro is gone forever :sad:

No idea whether newer versions are equally stupid - you have been warned :cool:

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Nasty qeditor feature
« Reply #2 on: July 11, 2019, 10:43:25 PM »
You could probably put a confirmation into it but it is an editor for programmers and the idea was to reduce the number of message boxes that pop up. If you have the problem again use the UNDO button and it magically restores what was there first.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

sinsi

  • Member
  • *****
  • Posts: 1182
Re: Nasty qeditor feature
« Reply #3 on: July 11, 2019, 11:11:32 PM »
Programmer or not,it's pretty basic to ask...
Undo doesn't work either.
I can walk on water but stagger on beer bourbon.

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Nasty qeditor feature
« Reply #4 on: July 12, 2019, 12:01:07 AM »
I can confirm the feature, also after the file dragged and dropped you close qeditor and there will be no question asking if you want to save it either... :icon_idea:
But you know hutch that i'm very happy with qeditor anyway  :thumbsup:  :mrgreen:
Felipe.

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Nasty qeditor feature
« Reply #5 on: July 12, 2019, 12:07:16 AM »
Probably hutch said:
Quote
"drag and drop? yeah, phuck that!"

 :joking:
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Nasty qeditor feature
« Reply #6 on: July 12, 2019, 09:48:06 AM »
The problem is I did not design the drag and drop in rich edit controls. Within the control you set a flag if anything is modified in the text which you use to trigger the "Save" operation but the drag and drop does not necessarily set the flag to indicate modified text. Now I have not properly understood what the problem is.

I opened 2 files in two instances of QE and selected all of one file and dropped it into the other instance of QE and it just inserted the text at the caret location. Click on UNDO button and it just undoes the drag and drop.

In the instance that was dragged from which leaves the edit window empty, just click on UNDO and it puts the full selected text back into the edit window. In both instances the modified flag is set and you have the option to save either when closing the instance.

At best as I can tell, it is a problem when you drop a complete file from something like Winfile.exe where the new OPEN operation just sets the flag to clear without saving the original content.

This code is probably where the problem comes from.

      case WM_DROPFILES
        mov fname, DropFileName(wParam)
        invoke Read_File_Inx,hEdit,fname
        invoke SetWindowText,hWnd,fname
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Nasty qeditor feature
« Reply #7 on: July 12, 2019, 10:59:11 AM »
Now I have not properly understood what the problem is.

I opened 2 files in two instances of QE and selected all of one file and dropped it into the other instance of QE and it just inserted the text at the caret location. Click on UNDO button and it just undoes the drag and drop.

In the instance that was dragged from which leaves the edit window empty, just click on UNDO and it puts the full selected text back into the edit window. In both instances the modified flag is set and you have the option to save either when closing the instance.

This is true i have the same result that you describe but... :thup:


At best as I can tell, it is a problem when you drop a complete file from something like Winfile.exe where the new OPEN operation just sets the flag to clear without saving the original content.

This is the issue that sinsi and i were talking about, it can happen with some file like myfile.txt too... :icon_idea:
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Nasty qeditor feature
« Reply #8 on: July 12, 2019, 11:08:44 AM »
I think I have tracked it down, I put a wrapper around the drag and drop code that will not let the operation continue if the edit content is not saved. Could I impose on you to test if this mod addresses the problem that sinsi reported ?

    ; ||||||||||||||||||||||||||||||||||||||||||||||||||||||||

      case WM_DROPFILES

        invoke SendMessage,hEdit,EM_GETMODIFY,0,0
        test eax, eax
        jnz @F
        mov fname, DropFileName(wParam)
        invoke Read_File_Inx,hEdit,fname
        invoke SetWindowText,hWnd,fname
        jmp DropOut
      @@:
        fn MessageBox,hWnd,"Please save existing content first","Current content is not saved",MB_OK

      DropOut:

    ; ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

sinsi

  • Member
  • *****
  • Posts: 1182
Re: Nasty qeditor feature
« Reply #9 on: July 12, 2019, 12:37:46 PM »
 :thumbsup:

It just needs to pop the same "File is not saved, save it now ?" dialog up.
I can walk on water but stagger on beer bourbon.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Nasty qeditor feature
« Reply #10 on: July 12, 2019, 12:49:49 PM »
I had a look at doing it that way but the internal structure uses 2 steps back before starting a new thread to save the file and there was no simple way to pass the dropped file name to the thread so I opted for a simpler technique that required the user to save the existing file first.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

felipe

  • Member
  • *****
  • Posts: 1249
  • Eagles are just great!
Re: Nasty qeditor feature
« Reply #11 on: July 13, 2019, 02:35:57 AM »
It does  :thup:. What are those bin files created when you run this qeditor version?
Felipe.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6662
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Nasty qeditor feature
« Reply #12 on: July 13, 2019, 02:47:19 AM »
They are the INI files but its more efficient to store them as binary rather than text so they have a "bin" extension. They were not designed to be edited.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: