The MASM Forum

Projects => MASM32 => Topic started by: sinsi on July 11, 2019, 07:57:26 PM

Title: Nasty qeditor feature
Post by: sinsi 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...
Title: Re: Nasty qeditor feature
Post by: jj2007 on July 11, 2019, 09:11:06 PM
My advice: Use a decent editor (http://masm32.com/board/index.php?topic=5314.0) :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:
Title: Re: Nasty qeditor feature
Post by: hutch-- 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.
Title: Re: Nasty qeditor feature
Post by: sinsi on July 11, 2019, 11:11:32 PM
Programmer or not,it's pretty basic to ask...
Undo doesn't work either.
Title: Re: Nasty qeditor feature
Post by: felipe 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:
Title: Re: Nasty qeditor feature
Post by: felipe on July 12, 2019, 12:07:16 AM
Probably hutch said:
Quote
"drag and drop? yeah, phuck that!"

 :joking:
Title: Re: Nasty qeditor feature
Post by: hutch-- 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
Title: Re: Nasty qeditor feature
Post by: felipe 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:
Title: Re: Nasty qeditor feature
Post by: hutch-- 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:

    ; ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Title: Re: Nasty qeditor feature
Post by: sinsi 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.
Title: Re: Nasty qeditor feature
Post by: hutch-- 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.
Title: Re: Nasty qeditor feature
Post by: felipe on July 13, 2019, 02:35:57 AM
It does  :thup:. What are those bin files created when you run this qeditor version?
Title: Re: Nasty qeditor feature
Post by: hutch-- 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.