FLTK logo

STR #3165

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.3 | SVN ⇄ GIT ]

STR #3165

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:2 - Specific to an operating system
Subsystem:WIN32
Summary:process does not end after closing all windows
Version:1.3-current
Created By:Belgiansteve
Assigned To:manolo
Fix Version:1.3-current (SVN: v10697)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:


Name/Time/Date Filename/Size  
 
#1 Belgiansteve
13:21 Nov 28, 2014
ex01.cpp
1k
 
     

Trouble Report Comments:


Name/Time/Date Text  
 
#1 Belgiansteve
13:21 Nov 28, 2014
The attached file shows an example program for which the process does not terminate after closing all windows, when the main window is closed first. To reproduce the error:
- Run the program.
- Create two (or more) child windows (note they are non-modal).
- Close the main window.
- Close all child windows.

After this, the process does not end. I only tried this on Win7, using FLTK 1.3.3. Not sure if it happens on other OS.

Thanks,

Steve
 
 
#2 Belgiansteve
16:11 Nov 28, 2014
Hi everyone,

I think I found the problem. The problem is a fix to an earlier STR #3097 that does not restore the proper window ownership relationship.

In Fl.cxx, line 1585, the code reads:
  for (int ii = 0; ii < count; ii++) {
    doit[ii]->hide();
    doit[ii]->show();
  }
  if (count) delete [] doit;

The problem here is that when the first window is shown (ii==0) the other child windows are still on the screen and it tries to make one of these child windows the parent (in Fl::make()) and Windows does not like that: CreateWindowEx returns NULL in Fl::make() (there should probably be a check for this).
The solution is:
  if (count)
  {
          for (int ii = 0; ii < count; ii++)  doit[ii]->hide();
          for (int ii = 0; ii < count; ii++)  { if (ii!=0) doit[0]->show(); doit[ii]->show(); }
          delete[] doit;
  }
This first hide all the windows which seems to avoid the issue. This makes the first window the parent of all the other non-modal windows. Note that I had to call show() on the first window in each iteration, since FLTK apparently makes the last shown() window the parent of any non-modal windows. Without this, a chain of non-modal windows is created that would make this entire issue even more complex.
Now, I think this still keeps the first window a non-modal window (at least as far as FLTK is concerned. Perhaps calling clear_modal_states() on this first window is necessary?)

This implements the idea that when the window to which other windows are modal is closed, it makes one of these dependent windows a normal window, and makes the other modal windows modal to this window (if you follow what I'm saying). Not sure if that is the desired behavior. What would happen on other OS? Anyways, this does seem to fix the issue.

Best,

Steve
 
 
#3 manolo
01:35 Apr 13, 2015
Fixed in Subversion repository.

Thanks for the solution.
 
     

Return to Bugs & Features ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.